Skip to content

Commit 3e22feb

Browse files
committed
Update README.md
1 parent 548ff59 commit 3e22feb

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed

README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -67,42 +67,42 @@ Simplest usage
6767

6868
To your presenter include (if you have PHP 5.4+)
6969

70+
``` php
71+
class MapPresenter extends Nette\Application\UI\Presenter
72+
{
73+
use \Oli\GoogleAPI\TMap;
7074

71-
class MapPresenter extends Nette\Application\UI\Presenter
72-
{
73-
use \Oli\GoogleAPI\TMap;
74-
75-
// ...
76-
}
77-
75+
// ...
76+
}
77+
```
7878
and to template
7979

8080
{control map}
8181

8282

8383
Define map in component
8484
=======================
85+
``` php
86+
private $map;
87+
private $markers;
88+
89+
public function __constructor(\Oli\GoogleAPI\IMapAPI $mapApi, \Oli\GoogleAPI\IMarkers $markers)
90+
{
91+
$this->map = $mapApi;
92+
$this->markers = $markers;
93+
}
8594

86-
private $map;
87-
private $markers;
95+
public function createComponentMap()
96+
{
97+
$map = $this->map->create();
98+
$markers = $this->markers->create();
8899

89-
public function __constructor(\Oli\GoogleAPI\IMapAPI $mapApi, \Oli\GoogleAPI\IMarkers $markers)
90-
{
91-
$this->map = $mapApi;
92-
$this->markers = $markers;
93-
}
100+
// ...
94101

95-
public function createComponentMap()
96-
{
97-
$map = $this->map->create();
98-
$markers = $this->markers->create();
99-
100-
// ...
101-
102-
$map->addMarkers($markers);
103-
return $map;
104-
}
105-
102+
$map->addMarkers($markers);
103+
return $map;
104+
}
105+
```
106106
And in template
107107

108108
{* JS and HTML *}
@@ -171,34 +171,34 @@ config.neon
171171
defaultIconPath: images/mapPoints
172172

173173
Presenter
174-
175-
protected function createComponentGoogleMap()
176-
{
177-
$map = $this->map->create();
178-
179-
$map->setCoordinates(array(50.250718,14.583435))
180-
->setZoom(4)
181-
->setType(MapAPI::TERRAIN);
182-
183-
$markers = $this->markers->create();
184-
$markers->fitBounds();
185-
186-
if(count($markersFromDb) > 30)
187-
{
188-
$markers->isMarkerClusterer();
189-
}
174+
``` php
175+
protected function createComponentGoogleMap()
176+
{
177+
$map = $this->map->create();
178+
179+
$map->setCoordinates(array(50.250718,14.583435))
180+
->setZoom(4)
181+
->setType(MapAPI::TERRAIN);
190182

191-
foreach ($markersFromDb as $marker)
192-
{
193-
$markers->addMarker(array($marker->lat, $marker->lng), Marker::DROP)
194-
->setMessage(
195-
'<h1>'.$marker->title.'</h1><br />'.$marker->description
196-
)->setIcon($marker->icon);
197-
}
198-
$map->addMarkers($markers);
199-
return $map;
183+
$markers = $this->markers->create();
184+
$markers->fitBounds();
185+
186+
if(count($markersFromDb) > 30)
187+
{
188+
$markers->isMarkerClusterer();
200189
}
201-
190+
191+
foreach ($markersFromDb as $marker)
192+
{
193+
$markers->addMarker(array($marker->lat, $marker->lng), Marker::DROP)
194+
->setMessage(
195+
'<h1>'.$marker->title.'</h1><br />'.$marker->description
196+
)->setIcon($marker->icon);
197+
}
198+
$map->addMarkers($markers);
199+
return $map;
200+
}
201+
```
202202
Template
203203

204204
{block content}

0 commit comments

Comments
 (0)