<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\Marker', '\\PHPGoogleMaps\\Overlay\\MarkerIcon');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$locations = array('New York, NY', 'San Diego, CA', 'Dallas, TX', 'Seattle, WA', 'Miami, FL', 'Atlanta, GA', 'Boise, ID', 'Green Bay, WI', 'Detroit, MI', 'Denver, CO', 'Phoenix, AZ', 'Portland, OR', 'Chicago, IL', 'New Orleans, LA', 'San Francisco, CA', 'Las Vegas, NV');
foreach ($locations as $i => $location) {
    $marker = \PHPGoogleMaps\Overlay\Marker::createFromLocation($location, array('title' => $location, 'content' => "{$location} marker"));
    $marker->setIcon(sprintf("http://www.galengrover.com/projects/php-google-maps/examples/_images/blue%s.png", chr($i++ + 65)));
    $map->addObject($marker);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Advanced 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 }
	#map_sidebar *, .infowindow * {padding:0;margin:0;}
	#map_sidebar { float:left;margin-left:20px;overflow:auto;height:500px; border:1px solid #ddd;width:200px;font-size:.8em; }
<?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; }
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
// Create a marker
$marker1_options = array('title' => 'Custom marker icon', 'content' => 'This marker uses a custom icon');
$marker1 = \PHPGoogleMaps\Overlay\Marker::createFromLocation('New York, NY', $marker1_options);
// Create a marker icon or the icon and shadow
$icon1 = new \PHPGoogleMaps\Overlay\MarkerIcon('http://www.galengrover.com/projects/php-google-maps/examples/_images/yellow_marker.png');
$shadow1 = new \PHPGoogleMaps\Overlay\MarkerIcon('http://www.galengrover.com/projects/php-google-maps/examples/_images/yellow_marker_shadow.png');
// Set the x anchor point to 11
// y anchor point defaults to image height
$shadow1->setAnchor(11);
// Attach the icon and shadow to the marker
$marker1->setIcon($icon1)->setShadow($shadow1);
// Create another marker
$marker2_options = array('title' => 'Custom marker icon', 'content' => 'This marker uses a custom icon with a sprite to limit http connections');
$marker2 = \PHPGoogleMaps\Overlay\Marker::createFromLocation('New Haven, CT', $marker2_options);
// This one will use a sprite for the icon and shadow
$icon2 = \PHPGoogleMaps\Overlay\MarkerIcon::create('http://www.galengrover.com/projects/php-google-maps/examples/_images/purple_marker_sprite.png', array('height' => 34));
// Height and width default to size of the image
$shadow2_options = array('height' => 24, 'origin_x' => 0, 'origin_y' => 34, 'anchor_x' => 11, 'anchor_y' => 24);
// Create another icon from the same image
$shadow2 = new \PHPGoogleMaps\Overlay\MarkerIcon('http://www.galengrover.com/projects/php-google-maps/examples/_images/purple_marker_sprite.png', $shadow2_options);
// Attach the icon and shadow to the second marker
$marker2->setIcon($icon2)->setShadow($shadow2);
// Add the markers to the map
$map->addObjects(array($marker1, $marker2));
?>

<!DOCTYPE html>
<html lang="en">
<head>
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
use PHPGoogleMaps\Overlay\Marker, PHPGoogleMaps\Overlay\MarkerGroup;
$map = new \PHPGoogleMaps\Map();
$markers[] = Marker::createFromLocation('New York, NY')->addToGroups(array('North', 'East', 'New York'));
$markers[] = Marker::createFromLocation('Syracuse, NY')->addToGroups(array('North', 'East', 'New York'));
$markers[] = Marker::createFromLocation('San Diego, CA')->addToGroups(array('South', 'West', 'California'));
$markers[] = Marker::createFromLocation('San Francisco, CA')->addToGroups(array('West', 'California'));
$markers[] = Marker::createFromLocation('Houston, TX')->addToGroups(array('South', 'Mid West', 'Texas'));
$markers[] = Marker::createFromLocation('Dallas, TX')->addToGroups(array('South', 'Mid West', 'Texas'));
$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>
Example #5
0
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$map2 = new \PHPGoogleMaps\Map(array('map_id' => 'map2'));
$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 
Example #6
0
// This is just for my examples
require '_system/config.php';
// Autoloader stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
// Create a new map
$map = new \PHPGoogleMaps\Map();
// Create some circle options
$circle_options = array('fillColor' => '#00ff00', 'strokeWeight' => 1, 'fillOpacity' => 0.05, 'clickable' => false);
// Create a circle with radius of 100m
$circle = \PHPGoogleMaps\Overlay\Circle::createFromLocation('San Diego, CA', 100, $circle_options);
// Create some marker options
$marker_options = array('title' => 'San Diego, CA', 'content' => '<p><strong>San Diego, CA</strong></p>', 'draggable' => true);
// Create a marker
$marker = \PHPGoogleMaps\Overlay\Marker::createFromLocation('San Diego, CA', $marker_options);
// Add the circle and marker to the map
$circle_map = $map->addObject($circle);
$marker_map = $map->addObject($marker);
// Set map options
$map->setCenter('San Diego, CA');
$map->setZoom(15);
$map->disableAutoEncompass();
// bind the center of the circle to the position of the marker
$map->bind($circle_map, 'center', $marker_map, 'position');
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\Marker', '\\PHPGoogleMaps\\Overlay\\MarkerDecorator');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$marker1_options = array('title' => 'New York, NY', 'content' => '<p><strong>New York, NY info window</strong></p>');
$marker1 = \PHPGoogleMaps\Overlay\Marker::createFromLocation('New York, NY', $marker1_options);
$marker2_options = array('title' => 'San Diego, CA', 'content' => '<p><strong>San Diego, CA info window</strong></p>');
$marker2 = \PHPGoogleMaps\Overlay\Marker::createFromPosition(new \PHPGoogleMaps\Core\LatLng(32.7153292, -117.1572551), $marker2_options);
// Add both markers to the map
// We need to be able to remove marker1 so we get a decorator for it
$marker1_map = $map->addObject($marker1);
$map->addObject($marker2);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Marker Basics - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
$map->printHeaderJS();