Link copied to clipboard
Post by Mark Lucovsky, Software EngineerThe
Google Ajax Search API is designed to work seamlessly with the
Google Maps API. One way it adds instant value is to allow your
Maps-based applications to execute a search, then take the search results and plot them on a map. Our model for this is simple and straightforward — each search result is a
JavaScript object that contains a number of properties including a URL, title, array of phone numbers, street address, city, latitude and longitude, etc. Therefore, adding a search result to a map is as simple as:
var latLng = GLatLng(parseFloat(result.lat), parseFloat(result.lng));
var marker = new GMarker(latLng);
myMap.addOverlay(marker);
The AJAX Search API team produced a number of simple sample applications to teach the basics of search-integrated Maps mashups. Two of the most popular samples are
My Favorite Places and
My Phone List, so take a look and see if they inspire you to add Search to your Maps mashups!
(An example of this search-enhanced Maps mashup idea is the
Google Gadget we built using these two APIs — check out the new
Google Map Search Gadget.)
Related post: Add Map Search to your site