// 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 echo PAGE_TITLE;
<?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>
<?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>