Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store
Related Articles

Geocoding with PHP and the Google Maps API


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.


Other Options

In This Article

Additional Files