@@ -67,42 +67,42 @@ Simplest usage
67
67
68
68
To your presenter include (if you have PHP 5.4+)
69
69
70
+ ``` php
71
+ class MapPresenter extends Nette\Application\UI\Presenter
72
+ {
73
+ use \Oli\GoogleAPI\TMap;
70
74
71
- class MapPresenter extends Nette\Application\UI\Presenter
72
- {
73
- use \Oli\GoogleAPI\TMap;
74
-
75
- // ...
76
- }
77
-
75
+ // ...
76
+ }
77
+ ```
78
78
and to template
79
79
80
80
{control map}
81
81
82
82
83
83
Define map in component
84
84
=======================
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
+ }
85
94
86
- private $map;
87
- private $markers;
95
+ public function createComponentMap()
96
+ {
97
+ $map = $this->map->create();
98
+ $markers = $this->markers->create();
88
99
89
- public function __constructor(\Oli\GoogleAPI\IMapAPI $mapApi, \Oli\GoogleAPI\IMarkers $markers)
90
- {
91
- $this->map = $mapApi;
92
- $this->markers = $markers;
93
- }
100
+ // ...
94
101
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
+ ```
106
106
And in template
107
107
108
108
{* JS and HTML *}
@@ -171,34 +171,34 @@ config.neon
171
171
defaultIconPath: images/mapPoints
172
172
173
173
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);
190
182
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();
200
189
}
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
+ ```
202
202
Template
203
203
204
204
{block content}
0 commit comments