예제 #1
0
 /**
  * GMapInfoWindow sample
  *
  * @author Vincent Guillon <*****@*****.**>
  * @since 2009-10-02 17:16:44
  */
 public function executeSample3()
 {
     // Initialize the google map
     $gMap = new GMap();
     $gMap->setZoom(13);
     $gMap->setCenter(-12.461334, 130.841904);
     // Create GMapInfoWindow
     $info_window = new GMapInfoWindow('<div>Your HTML content here !</div>');
     // Create marker
     $marker = new GMapMarker(-12.461334, 130.841904, array('title' => '"Darwin"'));
     $marker->addHtmlInfoWindow($info_window);
     $gMap->addMarker($marker);
     $this->gMap = $gMap;
     $this->setTemplate('sample1');
     // END OF ACTION
     $this->message = 'Simple GMapInfoWindow : click marker to open info window';
     $this->action_source = $this->functionToString('executeSample3');
 }
<?php

//
// 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 
<?php

/**
 *
 * @author fabriceb
 * @since Feb 16, 2009 fabriceb
 */
include dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(3, new lime_output_color());
$t->diag('GMap Tests');
/** @var $gMap GMap */
$gMap = new GMap();
$tab = '  ';
$new_line = "\n";
$separator = $new_line . $tab . $tab;
$gMap->setCenter(47, 52);
$t->is($gMap->optionsToJs(), '{' . $separator . $tab . 'center: new google.maps.LatLng(47, 52),' . $separator . $tab . 'mapTypeId: google.maps.MapTypeId.ROADMAP' . $separator . '}', 'correct output with center set');
$gMap->setZoom(8);
$t->is($gMap->optionsToJs(), '{' . $separator . $tab . 'center: new google.maps.LatLng(47, 52),' . $separator . $tab . 'zoom: 8,' . $separator . $tab . 'mapTypeId: google.maps.MapTypeId.ROADMAP' . $separator . '}', 'correct output with zoom set');
$t->is($gMap->getJavascript(), $new_line . $tab . 'var map = null;' . $new_line . $tab . '//  Call this function when the page has been loaded' . $new_line . $tab . 'function initialize()' . $new_line . $tab . '{' . $new_line . $tab . $tab . 'var mapOptions = {' . $new_line . $tab . $tab . $tab . 'center: new google.maps.LatLng(47, 52),' . $new_line . $tab . $tab . $tab . 'zoom: 8,' . $new_line . $tab . $tab . $tab . 'mapTypeId: google.maps.MapTypeId.ROADMAP' . $new_line . $tab . $tab . '};' . $new_line . $tab . $tab . 'map = new google.maps.Map(document.getElementById("map"), mapOptions);' . $new_line . $tab . '}' . $new_line . 'window.onload = function(){initialize()};' . $new_line, 'correct output with zoom set');