PhpRiot
Download This Article
Download this article in PDF format with all listings and files.

Price: $5.00 AUD
(Approx. $4.45 USD)

More information
Related Articles
Related Books
Beginning Google Maps Applications with PHP and Ajax: From Novice to Professional

Beginning Google Maps Applications with PHP and Ajax: From Novice to Professional

There is much to like about this book. The explanations are straightforward, the code is...
Browse Articles
Ajax (4), APC (1), CAPTCHA (1), CSS (3), Debugging (1), File Upload (1), Google (3), Google Maps (2), JavaScript (11), JSON (2), MVC (1), MySQL (6), onbeforeunload (1), OOP (1), PHP (27), PhpDoc (1), PostgreSQL (6), Prototype (10), Reflection (1), RFC 1867 (1), Robots (1), Scriptaculous (1), SEO (1), Sessions (1), SimpleXML (1), Smarty (5), SOAP (1), SPL (1), Templates (2), W3C (1), XHTML (1), Zend Framework (1), Zend_Search_Lucene (1)

PhpRiot Newsletter
Your Email Address:

Geocoding with PHP and the Google Maps API

Conclusion

In this article we have looked closely at how to use the free geocoder web service provided to users of Google Maps. While there is also a geocoder than can be used within your JavaScript code when using the Google Maps API, not all users will necessarily have JavaScript. This means that if you do choose to use the JavaScript geocoder, you should not rely on the user being able to do so.

After learning how to perform a request and to understand the results, we implement a PHP solution made up of three classes: Geocoder, Placemark and Point, which make using the Google geocoder very straightforward.

We finished the article by implementing a simple web-based interface to the geocoder, which allowed users to enter an address and retrieve the resulting locations.

While we didn't implement a caching solution in this article, you should always try to minimize the number of geocoding requests that your application performs by saving the responses for future use. This is done not only increase performance but to also not go over the quota allocated by Google.

References

In This Article


Additional Files