Ticket #507: MY_Gmap_Marker.php

File MY_Gmap_Marker.php, 0.8 kB (added by samsoffes, 9 months ago)
Line 
1<?php defined('SYSPATH') or die('No direct script access.');
2
3class Gmap_Marker extends Gmap_Marker_Core {
4
5    public function render($tabs = 0)
6    {
7        // Create the tabs
8        $tabs = empty($tabs) ? '' : str_repeat("\t", $tabs);
9
10        $output = array();
11        $var = 'm'.mt_rand();
12        $output[] = 'var '.$var.' = new GMarker(new GLatLng('.$this->latitude.', '.$this->longitude.'));';
13        if ($html = $this->html)
14        {
15            $output[] = 'GEvent.addListener('.$var.', "click", function()';
16            $output[] = '{';
17            $output[] = "\t".$var.'.openInfoWindowHtml(';
18            $output[] = "\t\t'".implode("'+\n\t\t$tabs'", explode("\n", $html))."'";
19            $output[] = "\t);";
20            $output[] = '});';
21        }
22        $output[] = 'map.addOverlay('.$var.');';
23
24        return implode("\n".$tabs, $output);
25    }
26
27} // End Gmap Marker