Book Image

PHP Ajax Cookbook

Book Image

PHP Ajax Cookbook

Overview of this book

Table of Contents (16 chapters)
PHP Ajax Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Searching a location within a Google Map


After looking at how to use the Google Map JavaScript API to embed a map in a web page, now let's look at a simple application to search the location within the Google Map using Google Map API's GeoCoder() class.

Getting ready

This tool has a very simple application with a simple interface. You can view its interface in the following image. It has a simple textbox where you can enter the values. The value can be any location, city, or landmark in the world. Then, the Google API's geocoder will find the location and point to it. The map will be centered to the location we're searching for, if that location is found. A red marker, which is the default marker provided by Google Map API, will be placed on the found location on the map.

Note

Geocoding is the process of converting an address like "619 Escuela Ave, Mountain View, CA" to a geographical coordinate system (37.394011, -122.095528) that is, into latitude and longitude.

When you click on the red marker...