Created
August 10, 2010 12:24
-
-
Save vaclavbohac/517183 to your computer and use it in GitHub Desktop.
Usage example of Gmaps component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{block content} | |
<div id="header"> | |
<h1>It works!</h1> | |
<h2>Congratulations on your first Nette Framework powered page.</h2> | |
</div> | |
<div> | |
<p>{$message}</p> | |
{control Gmaps, 'center' => 'Prague', 'width' => 600, 'height' => 600, 'controls' => FALSE} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Gmaps Component Example | |
* | |
* @copyright Copyright (c) 2010 Vaclav Bohac | |
* @package Gmaps | |
*/ | |
/** | |
* Homepage presenter. | |
* | |
* @author Vaclav Bohac | |
* @package Gmaps | |
*/ | |
class HomepagePresenter extends BasePresenter | |
{ | |
/** | |
* Component factory | |
* @param string $name - name of the component | |
* @return IComponent | |
*/ | |
public function createComponent($name) | |
{ | |
switch ($name) { | |
case 'Gmaps': | |
$Gmaps = new Gmaps($this, $name); | |
// Marker with exact coordinates. | |
$Gmaps->addMarker(array(49.595388, 17.251872), 'Olomouc'); | |
// Marker destination will be searched. | |
$Gmaps->addMarker('Pardubice', 'Město Pardubice'); | |
// Find route from Praha to Ostrava. | |
$Gmaps->setDirections('Praha', 'Ostrava', Gmaps\Directions::DRIVING); | |
// Add some waypoints to route. | |
$Gmaps->directions->addWaypoint(array('Brno', 'Havlíčkův Brod')); | |
// Create new polygon from set of points. | |
$points = array ( | |
new Gmaps\Coordinates(49.884017217246544, 16.898345947265625), | |
new Gmaps\Coordinates(49.87693780072525, 17.8692626953125), | |
new Gmaps\Coordinates(49.509494511039705, 17.475299835205078), | |
new Gmaps\Coordinates(49.884017217246544, 16.898345947265625), | |
); | |
$Gmaps->addPolygon($points); | |
return $Gmaps; | |
break; | |
default: | |
return parent::createComponent($name); | |
break; | |
} | |
} | |
public function renderDefault() | |
{ | |
$this->template->message = 'Google Maps as Nette Component in action!'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment