October 27, 2016
Hot Topics:

Building a Geocoding Web Service

  • November 28, 2005
  • By Jason Gilmore
  • Send Email »
  • More Articles »

Displaying the Google Map

Now that the coordinates have been retrieved, all you need to do is pass them into the appropriate Google Maps API method. To do so, paste the following code into the PHP Web services client (geocodeclient.php), being sure to place it below the closing PHP delimiter (?>). You'll also need to replace ADD_YOUR_KEY_HERE with your Google Maps API key. If you haven't yet registered for your key, see the instructions found in the opening installment of this series.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  <html xmlns="http://www.w3.org/1999/xhtml">
    <script src="http://maps.google.com/maps?file=api&v=1
         &key=ADD_YOUR_KEY_HERE" type="text/javascript">
    <div id="map" style="width: 400px; height: 300px"></div>
    <script type="text/javascript">
    var map = new GMap(document.getElementById("map"));
    new GPoint(<?php echo $longitude;?>, <?php echo $latitude;?>), 3);
    var point = 
    new GPoint(<?php echo $longitude;?>, <?php echo $latitude;?>);
    var marker = new GMarker(point);

Execute the geocodeclient.php script anew and you'll see the following map:


There you have it! A custom, end-to-end Web mapping solution built entirely from open source and freely available services.

About the Author

W. Jason Gilmore (http://www.wjgilmore.com/) is the open source editor for Apress. He's the author of the best-selling Beginning PHP 5 and MySQL: Novice to Professional (Apress, 2004. 758pp.). Along with Robert Treat, Jason is the co-author of the forthcoming Beginning PHP 5 and PostgreSQL 8: From Novice to Professional, due out at the conclusion of 2005. Jason loves receiving e-mail, so don't hesitate to write him at wjATwjgilmore.com.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel