<?php // This is for my examples require '_system/config.php'; $relevant_code = array('\\PHPGoogleMaps\\Overlay\\Marker'); // Autoload stuff require '../PHPGoogleMaps/Core/Autoloader.php'; $map_loader = new SplClassLoader('PHPGoogleMaps', '../'); $map_loader->register(); $map = new \PHPGoogleMaps\Map(); $marker1 = \PHPGoogleMaps\Overlay\Marker::createFromLocation('New York, NY', array('title' => 'New York, NY', 'content' => 'New York marker')); $marker2 = \PHPGoogleMaps\Overlay\Marker::createFromPosition(new \PHPGoogleMaps\Core\LatLng(32.7153292, -117.1572551), array('title' => 'San Diego, CA', 'content' => 'San Diego marker')); $marker3 = \PHPGoogleMaps\Overlay\Marker::createFromLocation('Dallas, TX', array('title' => 'Dallas, TX', 'content' => 'Dallas marker')); $map->addObjects(array($marker1, $marker2, $marker3)); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Simple Sidebar - <?php echo PAGE_TITLE; ?> </title> <link rel="stylesheet" type="text/css" href="_css/style.css"> <style type="text/css"> #map, #map_sidebar { float: left } .sidebar { list-style:none; margin:0 0 0 10px;padding:0;width: 200px; } .sidebar li { margin-bottom: 2px; } .sidebar p { background-color: #eee;margin:0; padding: 5px;cursor: pointer; } .sidebar p:hover { background-color: #ddd; }
<?php // This is for my examples require '_system/config.php'; $relevant_code = array('\\PHPGoogleMaps\\Overlay\\Circle', '\\PHPGoogleMaps\\Overlay\\Rectangle', '\\PHPGoogleMaps\\Overlay\\Shape', '\\PHPGoogleMaps\\Overlay\\ShapeDecorator'); // Autoload stuff require '../PHPGoogleMaps/Core/Autoloader.php'; $map_loader = new SplClassLoader('PHPGoogleMaps', '../'); $map_loader->register(); $map = new \PHPGoogleMaps\Map(); $circle_options = array('fillColor' => '#00ff00', 'strokeWeight' => 1, 'fillOpacity' => 0.05, 'clickable' => false); $circle = \PHPGoogleMaps\Overlay\Circle::createFromLocation('San Diego, CA', 1000, $circle_options); $rectangle_options = array('fillColor' => '#ff0000', 'strokeWeight' => 3, 'fillOpacity' => 0.05); $rectangle = new \PHPGoogleMaps\Overlay\Rectangle('San Diego, CA', \PHPGoogleMaps\Service\Geocoder::geocode('Balboa Park San Diego, CA'), $rectangle_options); $map->addObjects(array($circle, $rectangle)); $map->setCenter('San Diego, CA'); $map->setZoom(14); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Shapes - <?php echo PAGE_TITLE; ?> </title> <link rel="stylesheet" type="text/css" href="_css/style.css"> <?php $map->printHeaderJS(); ?>
$markers[] = Marker::createFromLocation('Orlando, FL')->addToGroups(array('South', 'East', 'Florida')); $markers[] = Marker::createFromLocation('Tampa, FL')->addToGroups(array('South', 'East', 'Florida')); $markers[] = Marker::createFromLocation('Detroit, MI')->addToGroups(array('North', 'East', 'Michigan')); $markers[] = Marker::createFromLocation('Ann Arbor, MI')->addToGroups(array('North', 'East', 'Michigan')); $markers[] = Marker::createFromLocation('Seattle, WA')->addToGroups(array('North', 'West')); $markers[] = Marker::createFromLocation('Denver, CO')->addToGroups(array('Mid West')); // It is also possible to add groups this way // Pass an array of markers to `addMarkers()` // This just calls `addToGroup()` on the marker //$group_ca = MarkerGroup::create( 'California' )->addMarkers( array() ); //$group_tx = MarkerGroup::create( 'Texas' )->addMarkers( array() ); //$group_fl = MarkerGroup::create( 'Florida' )->addMarkers( array(); //$group_mi = MarkerGroup::create( 'Michigan' )->addMarkers( array() ); // Groups aren't added to map // The markers associated with them are $map->addObjects($markers); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Marker Groups - <?php echo PAGE_TITLE; ?> </title> <link rel="stylesheet" type="text/css" href="_css/style.css"> <?php $map->printHeaderJS(); ?> <?php
// Autoloader stuff require '../PHPGoogleMaps/Core/Autoloader.php'; $map_loader = new SplClassLoader('PHPGoogleMaps', '../'); $map_loader->register(); // This is just for my examples require '_system/config.php'; $relevant_code = array('\\PHPGoogleMaps\\Event\\EventListener', '\\PHPGoogleMaps\\Event\\DomEventListener', '\\PHPGoogleMaps\\Event\\EventListenerDecorator'); // Create new map $map = new \PHPGoogleMaps\Map(); // Create 2 events $event1 = new \PHPGoogleMaps\Event\EventListener($map, 'idle', 'function(){alert("the map is loaded");}', true); $event2 = new \PHPGoogleMaps\Event\EventListener($map, 'click', 'add_marker'); // Create a DOM event $dom_event1 = new \PHPGoogleMaps\Event\DomEventListener('add_random_marker', 'click', 'add_random_marker'); $map->addObjects(array($event1, $dom_event1)); // Add this event with addObject() so we can use the return value to remove the event $event2_map = $map->addObject($event2); // Set map options $map->setCenter('San Diego, CA'); $map->setZoom(14); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Event Listeners - <?php echo PAGE_TITLE; ?> </title>
$map3 = new \PHPGoogleMaps\Map(array('map_id' => 'map3')); $locations = array('New York, NY', 'San Diego, CA', 'Miami, FL', 'Chicago, IL', 'Las Vegas, NV', 'Austin, TX', 'Portland, OR', 'Washington, D.C.'); $marker_sizes = array('tiny', 'mid', 'small', 'normal'); foreach ($locations as $i => $location) { $marker = \PHPGoogleMaps\Overlay\Marker::createFromLocation($location, array('static' => array('label' => substr($location, 0, 1), 'color' => sprintf('0x%s%s%s', dechex(str_pad(mt_rand(0, 255), 2, '0')), dechex(str_pad(mt_rand(0, 255), 2, '0')), dechex(str_pad(mt_rand(0, 255), 2, '0'))), 'size' => $marker_sizes[array_rand($marker_sizes)]))); $map->addObject($marker); $map2->addObject($marker); } $marker = \PHPGoogleMaps\Overlay\Marker::createFromLocation('New Haven, CT'); $icon = new \PHPGoogleMaps\Overlay\MarkerIcon('http://galengrover.com/projects/php-google-maps/examples/_images/bullseye_marker.png'); $marker->setStaticVar('flat', true); $marker->setIcon($icon); $marker2 = \PHPGoogleMaps\Overlay\Marker::createFromLocation('New York, NY'); $icon2 = new \PHPGoogleMaps\Overlay\MarkerIcon('http://galengrover.com/projects/php-google-maps/examples/_images/yellow_marker.png'); $marker2->setIcon($icon2); $map3->addObjects(array($marker, $marker2)); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Static Maps - <?php echo PAGE_TITLE; ?> </title> <link rel="stylesheet" type="text/css" href="_css/style.css"> <?php $map->printHeaderJS(); ?> <?php