示例#1
0
 */
include dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(10, new lime_output_color());
$t->diag('GMap Tests');
/** @var $gMap GMap */
$gMap = new GMap();
$gMap->addMarker(new GMapMarker(51.245475, 6.821373));
$gMap->addMarker(new GMapMarker(46.262248, 6.115969));
$gMap->addMarker(new GMapMarker(48.848959, 2.341577));
$gMap->addMarker(new GMapMarker(48.718952, 2.21918));
$gMap->addMarker(new GMapMarker(47.37642, 8.547995));
$t->diag('->getWidth test');
$t->is($gMap->getWidth(), 512, 'Correct width');
$t->is($gMap->getHeight(), 512, 'Correct height');
$gMap->setWidth(256);
$gMap->setHeight(128);
$t->is($gMap->getWidth(), 256, 'Correct width');
$t->is($gMap->getHeight(), 128, 'Correct height');
$gMap->setWidth(512);
$gMap->setHeight(512);
$t->diag('->getMarkersCenterCoord test');
$t->is($gMap->getMarkersCenterCoord()->__toString(), '48.7538615, 5.3835875', 'The center of our markers is ok');
$gMap->centerOnMarkers();
$t->is($gMap->getCenterCoord()->__toString(), '48.7538615, 5.3835875', 'The center of the map is ok');
$t->diag('->getMarkersFittingZoom test');
$t->is($gMap->getMarkersFittingZoom(), 7, 'The zoom on our markers is ok');
$gMap->zoomOnMarkers();
$t->is($gMap->getZoom(), 7, 'The zoom of the map is ok');
$gMap->centerAndZoomOnMarkers();
$t->is($gMap->getCenterCoord()->__toString(), '48.7538615, 5.3835875', 'The center of the map is ok');
$t->is($gMap->getZoom(), 7, 'The zoom of the map is ok');
<?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