PHP Classes
elePHPant
Icontem

File: GmapBuilderDemo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Steve  >  GMapBuilder  >  GmapBuilderDemo.php  >  Download  
File: GmapBuilderDemo.php
Role: Example script
Content type: text/plain
Description: Demo template for using GMapBuilder
Class: GMapBuilder
Present world maps on Web pages using Google Maps
Author: By
Last change: Fixed some bugs in the demo template. It had been tested with an older version of GMapBuilder. Works now.
Date: 8 years ago
Size: 2,844 bytes
 

Contents

Class file image Download
<?php
/* GmapBuilderDemo.php - Template to demonstrate use of the GMapBuilder class.
 * For this template to work, you need to sign up to use the Google Map API and get a
 * map key. Google map keys are site specific.
 * THE EXAMPLE MAP KEY SHOWN IN THIS FILE WILL NOT WORK ON YOUR PAGE!!!
 *
 */
 
 
include_once('GMapBuilder.php');
 
 
// This is the Google Map key. You'll need to get your own, this one won't work for your site!
$GoogleMapKey = "ABQIAAAASTTcmW1CDKxSczq45tYcYRRwm0Nj5uyqMWBGJ038n7cCIwuHOxRqfQRWefX7tsfSavaZG5JSX1rylQ";

 
// Instantiate a new GMapBuilder object." .
        
 // print "GMapBulderDemo: Instantiating new map class...<br />\n";
 
$map = new GMapBuilder($GoogleMapKey);
 
 
$map->setHeight(400); // Define the height and width, in pixels
 
$map->setWidth(300);
 
$map->setZoomLevel(7); // Set the map zoom level.
 
 // If you want to set CSS styles other than the height and width on the
 // map div, use setMapDivStyle to add them." .
        
 
$map->setMapDivStyle("float: right; margin-right: 30px;");
 
 
// Define the center point of the map.
 
$latitude = 42.789;
 
$longitude = -76.324;
 
$map->setCenter($longitude, $latitude);
 
 
// Add a marker to the map. You can put in as many as you want.
 // The html will be shown inside the marker box when the marker is clicked.

 
$latitude = 42.789;
 
$longitude = -76.324;
 
$html = "<em>This is a point</em>";
 
$map->addMarker($longitude, $latitude, $html);
 
 
$latitude = 42.891;
 
$longitude = -76.401;
 
$html = "<em>This is yet another point</em>";
 
$map->addMarker($longitude, $latitude, $html);
 
 
// Add any additional javascript, as a string. This can be used to e.g., to add polylines to the map.
 
$jsString = "x = 0;";
 
$map->addAdditionalJS($jsString);
 
 
/************************
 * Output the page. *
 ************************/
 
 
echo "<html>";
 echo
"<head>";
 
 
// In the head of the page, output the script that fetches the Google API
 
echo $map->getGoogleMapAPIScript();

 echo
"</head>";

 
/* After the head of the page, output the <body> tag. If you have other
 * onload functions, you can use your own <body> tag instead, but be sure to include
 * onload = WaitToRun(); in your <body> tag. This is necessary to compensate for a
 * bug in IE in which the map javascript runs before the map div tag is rendered.
 */
 
echo $map->getMapBodyTag();
 
 
// At the location on the page where you want the map, output the map div
 
echo $map->getMapDiv();
 
 
// Add the map javascript.
 
echo $map->getWaitToRunScript();
 
 
// That's it. You should see a map on your page!
 
 // This is for debugging, so you can see what the class is doing internally . . .
 // echo "<plaintext>" . $map->toString() . "</plaintext>";
 
 
echo "</body>";
 echo
"</html>";
?>