134
152
public function renderMap($container_id, $options = array(), $type = null)
136
// Get the type for this if it was not sent
137
if ($type === null) $type = $this->_driver->getDriverName();
138
// Lowercase the map type
139
$type = strtolower($type);
154
if (!isset(self::$_map_containers[$container_id]))
156
// Get the type for this if it was not sent
157
if ($type === null) $type = $this->_driver->getDriverName();
158
// Lowercase the map type
159
$type = strtolower($type);
161
// Save the container id and the type
162
self::$_map_containers[$container_id] = $type;
165
$map_script = $this->render("{$type}/map", array(
166
'query' => $this->query,
167
'latitude' => $this->latitude,
168
'longitude' => $this->longitude,
169
'container_id' => $container_id,
170
'options' => $options
173
// Register the javascript
174
Yii::app()->getClientScript()->registerScript("{$type}_map_js".(self::$_map_count++), $map_script, CClientScript::POS_READY);
177
// Render the map point
178
$this->renderPoint($this->latitude, $this->longitude, $container_id, $this->clean_query);
182
* Render a point on the map. By default it will render the points associated
183
* with the result in the last used container with the last used type. Make sure
184
* that you have already made a call to render map with the given container_id
188
* @param string $container_id
189
* @param string $description
191
public function renderPoint($lat, $lon, $container_id, $description=null)
193
// Validate the container
194
if (!isset(self::$_map_containers[$container_id]))
195
throw new GeoCode_Exception("Unknown map container '{$container_id}'");
198
$type = self::$_map_containers[$container_id];
141
199
// Render the view
142
$map_script = $this->render("{$type}_map", array(
143
'query' => $this->clean_query,
144
'latitude' => $this->latitude,
145
'longitude' => $this->longitude,
146
'container_id' => $container_id,
147
'options' => $options
200
$point_script = $this->render("{$type}/point", array(
201
'query' => $description,
202
'latitude' => ($lat === null) ? $this->latitude : $lat,
203
'longitude' => ($lon === null) ? $this->longitude : $lon,
150
206
// Register the javascript
151
Yii::app()->getClientScript()->registerScript("{$type}_map_js", $map_script, CClientScript::POS_READY);
207
Yii::app()->clientScript->registerScript("{$type}_point_js".(self::$_point_count++), $point_script, CClientScript::POS_READY);