Exemplo n.º 1
0
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\MapStyle');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$custom_style_json = '[ { featureType: "water", elementType: "all", stylers: [ { hue: "#ff0008" }, { saturation: 71 }, { lightness: -43 }, { gamma: 0.83 } ] },{ featureType: "road", elementType: "all", stylers: [ { saturation: -24 }, { hue: "#1100ff" } ] },{ featureType: "landscape", elementType: "all", stylers: [ { hue: "#11ff00" }, { saturation: 100 }, { lightness: -34 } ] } ]';
$custom_style = new \PHPGoogleMaps\Overlay\MapStyle('Custom', $custom_style_json);
$map = new \PHPGoogleMaps\Map();
$map->addObject($custom_style);
// You must explicitly set the map types and include the custom style
$map->setMapTypes(array('roadmap', 'terrain', $custom_style));
$map->setCenter('San Diego, CA');
$map->setZoom(14);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Custom Map Styles - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
$map->printHeaderJS();
?>
Exemplo n.º 2
0
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Layer\\KmlLayer', '\\PHPGoogleMaps\\Layer\\KmlLayerDecorator');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$kml = new \PHPGoogleMaps\Layer\KmlLayer('http://local.yahooapis.com/MapsService/rss/trafficData.xml?appid=YahooDemo&city=new+york');
$map->addObject($kml);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>KML Layers - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
$map->printHeaderJS();
?>
	<?php 
$map->printMapJS();
?>
</head>
<body>
Exemplo n.º 3
0
<?php

// This is for my examples
require '_system/config.php';
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
//
$marker = \PHPGoogleMaps\Overlay\Marker::createFromUserLocation(array('geolocation_high_accuracy' => true, 'geolocation_timeout' => 10000));
$map->addObject($marker);
// If you want to set geolocation options you must call enableGeolocation() explicitly
// Otherwise it will be called for you when you use geolocation functions
$map->enableGeolocation(5000, true);
$map->centerOnUser(\PHPGoogleMaps\Service\Geocoder::geocode('New York, NY'));
$map->setWidth('500px');
$map->setHeight('500px');
$map->setZoom(16);
// Set the callbacks
$map->setGeolocationFailCallback('geofail');
$map->setGeolocationSuccessCallback('geosuccess');
// Set the loading content. This will display while the browser geolocates the user.
$map->setLoadingContent('<div style="background:#eee;height:300px;padding: 200px 0 0 0;text-align:center;"><img src="_images/loading.gif" style="display:block; margin: auto;"><p>Locating you...</p></div>');
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Geolocation - <?php 
Exemplo n.º 4
0
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
// If location is set
if (isset($_GET['location']) && strlen($_GET['location'])) {
    // Create a PDO Geocode Cache connection and pass it to the caching geocoder
    try {
        $geoPDO = new \PHPGoogleMaps\Service\GeocodeCachePDO('localhost', 'username', 'password', 'database');
    } catch (PDOException $e) {
        die('Unable to connect to database');
    }
    $caching_geo = new \PHPGoogleMaps\Service\CachingGeocoder($geoPDO);
    // Geocode the location with the caching geocoded
    $geocode_result = $caching_geo->geocode($_GET['location']);
    if ($geocode_result instanceof \PHPGoogleMaps\Core\PositionAbstract) {
        // Create a map
        $map = new \PHPGoogleMaps\Map();
        $marker = \PHPGoogleMaps\Overlay\Marker::createFromPosition($geocode_result);
        $map->addObject($marker);
        $map->disableAutoEncompass();
        $map->setZoom(13);
        $map->setCenter($geocode_result);
    } else {
        $location = $geocode_result->location;
        $error = $geocode_result->error;
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
Exemplo n.º 5
0
<?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\\Layer\\FusionTable', '\\PHPGoogleMaps\\Layer\\FusionTableDecorator');
// Create a map
$map = new \PHPGoogleMaps\Map();
// Create a fusion table for CT
$ft_ct_options = array('query' => 'SELECT location FROM 232192 WHERE state_province_abbrev="CT"');
$ft_ct = new \PHPGoogleMaps\Layer\FusionTable(232192, $ft_ct_options);
// Create a fusion table for RI
$ft_ri_options = array('query' => 'SELECT location FROM 232192 WHERE state_province_abbrev="RI"');
$ft_ri = new \PHPGoogleMaps\Layer\FusionTable(232192, $ft_ri_options);
// Add the CT fusion table to the map and get the decorator for later use
$ft_ct_map = $map->addObject($ft_ct);
// Add the RI fusion table to the map
$map->addObject($ft_ri);
// Set map options
$map->setCenter('Connecticut');
$map->setZoom(7);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Fusion Tables - <?php 
Exemplo n.º 6
0
<?php

// 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();
$map = new \PHPGoogleMaps\Map();
$map->enableAdsense('pub-9317852351271673', 'small_rectangle');
$map->setCenter('New York, NY');
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Adsense - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
$map->printHeaderJS();
?>
	<?php 
$map->printMapJS();
?>
</head>
<body>
Exemplo n.º 7
0
<?php

// This is for the examples
require '_system/config.php';
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$map->enableStreetView();
$map->setCenter('Anchorage, AK');
$map2 = new \PHPGoogleMaps\Map(array('map_id' => 'map2'));
$map2->enableStreetView(array('addressControl' => false, 'enableCloseButton' => false), 'container');
$map2->setCenter('San Diego, CA');
$map3 = new \PHPGoogleMaps\Map(array('map_id' => 'map3'));
try {
    $map3->enableStreetView(array('position' => 'New Haven, CT'));
} catch (GeocodeException $e) {
    echo $e->error;
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Streetview - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
Exemplo n.º 8
0
<?php

// This is just for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Service\\Geocoder', '\\PHPGoogleMaps\\Service\\GeocodeError', '\\PHPGoogleMaps\\Service\\GeocodeResult', '\\PHPGoogleMaps\\Service\\GeocodeException');
// Autoloader stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
// Geocode a location and set the center of the map
// If geocode fails fallback to a different map center
// If no center is set the map will not display
$geocode = \PHPGoogleMaps\Service\Geocoder::geocode('San Diego, CA');
if ($geocode instanceof \PHPGoogleMaps\Service\GeocodeResult) {
    // Set center of map to geocoded location
    $map->setCenter($geocode);
} else {
    $map->setCenter('New York, NY');
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Geocoding - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
Exemplo n.º 9
0
<?php

// 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">
Exemplo n.º 10
0
<?php

// This is for my examples
require '_system/config.php';
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$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>
Exemplo n.º 11
0
<?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();
Exemplo n.º 12
0
<?php

// This is for the examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\GroundOverlay', '\\PHPGoogleMaps\\Overlay\\GroundOverlayDecorator');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$go = new \PHPGoogleMaps\Overlay\GroundOverlay('http://www.volunteer.blogs.com/winewaves/images/san_diego_postcard.jpg', \PHPGoogleMaps\Service\Geocoder::geocode('San Diego, CA'), \PHPGoogleMaps\Service\Geocoder::geocode('Balboa Park San Diego, CA'));
$map->addObject($go);
$map->setCenter(\PHPGoogleMaps\Service\Geocoder::geocode('San Diego, CA'));
$map->setZoom(14);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Ground Overlays - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
$map->printHeaderJS();
?>
	<?php 
$map->printMapJS();
?>
Exemplo n.º 13
0
<?php

// This is for my examples
require '_system/config.php';
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$marker = \PHPGoogleMaps\Overlay\Marker::createFromUserLocation(array('geolocation_high_accuracy' => true, 'geolocation_timeout' => 10000));
$map->addObject($marker);
$map->centerOnUser(\PHPGoogleMaps\Service\Geocoder::geocode('New Haven, CT'));
$map->setWidth('100%');
$map->setHeight('100%');
$map->enableMobile();
$map->disableAutoEncompass();
$map->setZoom(14);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Geolocation - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<style type="text/css">
	html,body{ height:100%;width:100%;padding:0;margin:0 }
	</style>
Exemplo n.º 14
0
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Layer\\PanoramioLayer', '\\PHPGoogleMaps\\Layer\\PanoramioLayerDecorator');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$panoramio = new \PHPGoogleMaps\Layer\PanoramioLayer();
$panoramio->setTag('beach');
//$panoramio->setUserID( 4106947 );
$map->addObject($panoramio);
$map->setCenter('San Diego, CA');
$map->setZoom(10);
$map->disableAutoEncompass();
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Panoramio - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
$map->printHeaderJS();
?>
<?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();
$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_decorator = $map->addObject($marker);
    // You have to add the event handler after the marker has been added to a map
    $click_handler = new \PHPGoogleMaps\Event\EventListener($marker_decorator, 'click', 'function(){alert("You clicked " + ' . $marker_decorator . '.content);}');
    $map->addObject($click_handler);
}
// Diable infowindows so that only the alternate click handler gets triggered
$map->disableInfoWindows();
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Alternate Click Handlers - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
Exemplo n.º 16
0
<?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; }
Exemplo n.º 17
0
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\Marker', '\\PHPGoogleMaps\\Overlay\\MarkerDecorator', '\\PHPGoogleMaps\\Overlay\\MarkerGroup', '\\PHPGoogleMaps\\Overlay\\MarkerGroupDecorator');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$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
Exemplo n.º 18
0
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Core\\CustomControl');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$custom_control_outer_options = array('style.backgroundColor' => 'white', 'style.borderStyle' => 'solid', 'style.borderWidth' => '2px', 'style.cursor' => 'pointer', 'style.textAlign' => 'center', 'title' => 'Click to say hi', 'style.margin' => '5px');
$custom_control_inner_options = array('style.fontFamily' => 'Arial,sans-serif', 'style.fontSize' => '12px', 'style.paddingLeft' => '4px', 'style.paddingRight' => '4px', 'innerHTML' => '<b>Custom1</b>');
// Create a control and add a listener
$custom_control = new \PHPGoogleMaps\Core\CustomControl($custom_control_outer_options, $custom_control_inner_options, 'BOTTOM_LEFT');
$custom_control->addListener('click', 'function(){ alert("You clicked Custom1"); }');
$map->addObject($custom_control);
// Create a control and event, attaching the event to the control
// This has the added benefit of being able to remove the event later using $event
$custom_control_inner_options['innerHTML'] = '<b>Custom2</b>';
$custom_control2 = new \PHPGoogleMaps\Core\CustomControl($custom_control_outer_options, $custom_control_inner_options, 'BOTTOM_LEFT');
$custom_control2_map = $map->addObject($custom_control2);
$event = new \PHPGoogleMaps\Event\DomEventListener($custom_control2_map, 'click', 'function(){ alert("You clicked Custom2"); }');
$map->addObject($event);
$map->setCenter('San Diego, CA');
$map->setZoom(14);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
Exemplo n.º 19
0
            $location = $_GET['location'];
            $location_options = $geocode_result->response->results;
        } else {
            $position = $geocode_result;
        }
    } else {
        $location = $geocode_result->location;
        $error = $geocode_result->error;
    }
}
if (isset($_GET['geocoded_location'])) {
    list($location, $lat, $lng) = explode('|', $_GET['geocoded_location']);
    $position = new \PHPGoogleMaps\Core\LatLng($lat, $lng, $location);
}
if (isset($position)) {
    $map = new \PHPGoogleMaps\Map();
    $marker = \PHPGoogleMaps\Overlay\Marker::createFromPosition($position, array('content' => $position->location));
    $map->addObject($marker);
    $map->disableAutoEncompass();
    $map->setZoom(13);
    $map->setCenter($position);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Geocoding - <?php 
echo PAGE_TITLE;
?>
Exemplo n.º 20
0
<?php

// This is for the examples
require '_system/config.php';
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map_options = array('map_id' => 'map23', 'draggable' => false, 'center' => 'San Diego, CA', 'height' => '600px', 'width' => '600px', 'zoom' => 10, 'bicycle_layer' => true);
$map = new \PHPGoogleMaps\Map($map_options);
?>

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

<h1>Map Options</h1>
Exemplo n.º 21
0
<?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;
?>
Exemplo n.º 22
0
<?php

// This is for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\Polyline', '\\PHPGoogleMaps\\Overlay\\Poly', '\\PHPGoogleMaps\\Overlay\\PolyDecorator');
// Autoload stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
use PHPGoogleMaps\Service\Geocoder;
$polyline_paths = array(Geocoder::geocode('San Diego, CA'), Geocoder::geocode('Austin, TX'), Geocoder::geocode('New Haven, CT'), Geocoder::geocode('Seattle, WA'));
$polyline_options = array('strokeColor' => '#0000ff', 'clickable' => false);
$polyline = new \PHPGoogleMaps\Overlay\Polyline($polyline_paths, $polyline_options);
$polyline->addPath('San Francisco, CA');
$map->disableAutoEncompass();
$map->setCenter('Austin, TX');
$map->setZoom(3);
$polyline_map = $map->addObject($polyline);
?>

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>Polylines - <?php 
echo PAGE_TITLE;
?>
</title>
	<link rel="stylesheet" type="text/css" href="_css/style.css">
	<?php 
Exemplo n.º 23
0
<?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();
?>
Exemplo n.º 24
0
<?php

// This is just for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\Marker', '\\PHPGoogleMaps\\Overlay\\MarkerDecorator');
// Autoloader stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
$map = new \PHPGoogleMaps\Map();
$map->setWidth(800);
$map->setHeight(400);
$map->setZoom(2);
$map->disableAutoEncompass();
$map->setCenterCoords(39.91, 116.38);
// Get the photo data from the marker cluster page
$json = json_decode(str_replace('var data = ', '', file_get_contents('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/data.json')));
// Add 1000 markers using the lat/lng from the photo data
for ($i = 0; $i < 1000; $i++) {
    $marker = \PHPGoogleMaps\Overlay\Marker::createFromPosition(new \PHPGoogleMaps\Core\LatLng($json->photos[$i]->latitude, $json->photos[$i]->longitude));
    $marker->setContent(sprintf('<img src="%s" style="width: 200px">', $json->photos[$i]->photo_file_url));
    $map->addObject($marker);
}
// Set cluster options
$cluster_options = array('maxZoom' => 10, 'gridSize' => null);
$map->enableClustering('http://www.galengrover.com/projects/php-google-maps/examples/_js/markerclusterer.js', $cluster_options);
?>

<!DOCTYPE html>
<html lang="en">
<head>
Exemplo n.º 25
0
<?php

// This is just for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Overlay\\Marker', '\\PHPGoogleMaps\\Overlay\\MarkerDecorator', '\\PHPGoogleMaps\\Overlay\\MarkerIcon');
// Autoloader stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$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
Exemplo n.º 26
0
<?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; }
Exemplo n.º 27
0
<?php

// This is just for my examples
require '_system/config.php';
$relevant_code = array('\\PHPGoogleMaps\\Service\\DrivingDirections', '\\PHPGoogleMaps\\Service\\WalkingDirections', '\\PHPGoogleMaps\\Service\\BicyclingDirections', '\\PHPGoogleMaps\\Service\\Directions', '\\PHPGoogleMaps\\Service\\DirectionsDecorator');
// Autoloader stuff
require '../PHPGoogleMaps/Core/Autoloader.php';
$map_loader = new SplClassLoader('PHPGoogleMaps', '../');
$map_loader->register();
// Create a new map and set some options
$map = new \PHPGoogleMaps\Map();
$map->setCenter('USA');
$map->setZoom(3);
// If origin and destination are set add directions
if (isset($_GET['origin'], $_GET['destination']) && strlen($_GET['origin']) && strlen($_GET['destination'])) {
    try {
        $directions = new \PHPGoogleMaps\Service\DrivingDirections($_GET['origin'], $_GET['destination']);
        if (isset($_GET['waypoint']) && $_GET['waypoint'] != '') {
            $directions->addWaypoint($_GET['waypoint']);
        }
        $map->addObject($directions);
    } catch (\PHPGoogleMaps\Service\GeocodeException $e) {
        $error = $e;
    }
}
?>

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