Google Maps With PHP And Phproogle

Bookmark on del.icio.us

This examples shows how to use the PHPRO phproogle class to create a google map with ease. Creating a Google Map is quick and simple with this class and avoids the complex world that is the Google Maps API.


<?php

/*** include the phroogle class definition ***/
include 'phproogle.class.php';

try
{

/*** a new phproogle instance ***/
$map = new phproogleMap();

/*** the google api key ***/
$map->apiKey = 'YOUR_GOOGLE_API_KEY_HERE';

/*** zoom is 0 - 19 ***/
$map->mapZoom = 14;

/*** the map width ***/
$map->mapWidth = 350;

/*** the map height ***/
$map->mapHeight = 300;

/*** set the map type ***/
$map->mapType = 'normal';

/*** set the map center ***/
$map->mapCenter = array(-33.862828, 151.216974);

/*** add some markers with latitude and longitude  ***/
$map->addMarker(-33.858362, 151.214876, '<h2>Sydney Opera House</h2><p>For those with culture</p>');
$map->addMarker(-33.862828,151.216974, '<h3>Royal Botanic Gardens</h2><a href="http://phpro.org">A link here</a>');

/*** add some controls ***/
$map->addGoogleMapControl('GMapTypeControl');
$map->addGoogleMapControl('GSmallMapControl');
$map->addGoogleMapControl('GOverviewMapControl');

/*** add some marker addresses ***/
$map->addMarkerAddress('2 Pitt St Sydney NSW Australia', '<h2>Head Office</h2>');
$map->addMarkerAddress('122 Pitt St Sydney NSW Australia', '<h2>The Factory</h2>');

/*** set the map div id ***/
$map->mapDivID = 'map';
}
catch(
Exception $e )
{
echo
$e->getMessage();
}
?>

<html>
<head>
<?php echo $map->googleJS(); ?>
</head>
<body>
<?php echo $map->drawMap(); ?>
</body>
</html>

  1. No comments yet.

  1. No trackbacks yet.