32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
|
|
|
class Gmap_Marker extends Gmap_Marker_Core
|
|
{
|
|
public function render($tabs = 0, $show = false)
|
|
{
|
|
// Create the tabs
|
|
$tabs = empty($tabs) ? '' : str_repeat("\t", $tabs);
|
|
|
|
// Marker ID
|
|
$marker = 'm'.++self::$id;
|
|
|
|
$output[] = 'var '.$marker.' = new google.maps.Marker(new google.maps.LatLng('.$this->latitude.', '.$this->longitude.'), {'.implode(",", $this->options).'});';
|
|
if ($html = $this->html)
|
|
{
|
|
$output[] = 'google.maps.Event.addListener('.$marker.', "click", function()';
|
|
$output[] = '{';
|
|
$output[] = "\t".$marker.'.openInfoWindowHtml(';
|
|
$output[] = "\t\t'".implode("'+\n\t\t$tabs'", explode("\n", $html))."'";
|
|
$output[] = "\t);";
|
|
$output[] = '});';
|
|
|
|
if($show)
|
|
{
|
|
$output[] = "map.openInfoWindowHtml(new google.maps.LatLng($this->latitude, $this->longitude), '$html');";
|
|
}
|
|
}
|
|
$output[] = 'map.addOverlay('.$marker.');';
|
|
|
|
return implode("\n".$tabs, $output);
|
|
}
|
|
} |