Skip to content

Instantly share code, notes, and snippets.

@vaclavbohac
Created August 10, 2010 12:24
Show Gist options
  • Save vaclavbohac/517183 to your computer and use it in GitHub Desktop.
Save vaclavbohac/517183 to your computer and use it in GitHub Desktop.
Usage example of Gmaps component
{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>
<?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