示例#1
0
  /**
   * Marker/Map event sample
   *
   * @author Vincent Guillon <*****@*****.**>
   * @since 2009-10-02 16:56:25
   */
  public function executeSample2()
  {
    // Initialize the google map
    $gMap = new GMap();
    $gMap->setZoom(4);
    $gMap->setCenter(-25.363882, 131.044922);

    // Create marker
    $marker = new GMapMarker(-12.461334, 130.841904, array('title' => '"Hello World !"'));
    
    // Add event on marker
    $marker->addEvent(new GMapEvent('click', 'moveToMarker();'));
    
    // Add marker on the map
    $gMap->addMarker($marker);

    // Add event on the map
    $gMap->addEvent(new GMapEvent('click', 'gmapSample_AddConsoleLine("You just click on the map !")'));

    $this->gMap = $gMap;

    $this->setTemplate('sample1');

    // END OF ACTION
    $this->message = 'Simple events : <br /> - click marker to focus on<br /> - click on the map for test map event';
    $this->action_source = $this->functionToString('executeSample2');
    $this->generated_js = str_replace(' ', '&nbsp;', preg_replace('/^\n(.*)/', '$1', $this->gMap->getJavascript()));
  }
//
// Initialisation
//
define('GMAP_LIB_PATH', dirname(__FILE__) . '/../../lib/');
require_once GMAP_LIB_PATH . 'GMap.class.php';
//
// Controller
//
$gMap = new GMap();
$gMap->setZoom(4);
$gMap->setCenter(-25.363882, 131.044922);
$gMap->setHeight('500');
$gMap->setWidth('100%');
$marker = new GMapMarker(-25.363882, 131.044922, array('title' => '"Hello World!"'));
$marker->addEvent(new GMapEvent('click', 'map.set_zoom(8);'));
$gMap->addMarker($marker);
$gMap->addEvent(new GMapEvent('zoom_changed', 'setTimeout(moveToDarwin, 1500);'));
//
// View
//
?>

<?php 
require_once GMAP_LIB_PATH . 'helper/GMapHelper.php';
?>

<html>
  <head>
    <?php 
include_google_map_javascript_file($gMap);