PhpRiot
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

Generating Static Images of Google Maps

Introduction

One useful feature of Google Maps is the ability to generate a static image of any longitude and latitude that you desire, as opposed to using the normal JavaScript-based interactive map. In this article I will show you how to request such static images. We will then combine this technique with the geocoder we created in the article Geocoding with PHP and the Google Maps API.

Additionally, if you use Smarty you can make use of the plug-in I have included in this article as a bonus to help with generating static image requests.

There are a several restrictions you should be aware of before you get started. Firstly, the maximum dimensions of a generated map are 512 pixels high and wide. If you are really desperate to get around this restriction you could be creative in your programming and automatically request adjoining maps and join them together, however we won't be covering anything like this in this article.

The other restriction is that there is a limit of 1,000 unique image requests per day. Although your Google Maps API key is used in the request, this restriction applies to each viewer of your site, meaning it should almost never be a problem.

If you don't already have a Google Maps API key, you will need to create one for your web site for free at http://code.google.com/apis/maps/signup.html. Simply agree to the terms and conditions, and then enter your web site URL to create a key. Once created, copy the key to your editor as you will need it for the code samples in this article.

In This Article


Additional Files