Geocoding with Google Maps API (Multiple markers)
While working on a restaurant meta-search engine, I wanted to display the restaurants on the map. Google Maps API was what I needed. It is well documented and easy to use. Also, gives you plenty of options to customize your map to your needs. To display a marker at an address, basically you can use a function like below:
//Function creates a marker for given address and places it on the map
function placeAddressOnMap(address) {
gc.geocode({'address': address}, function (res, status) {
if (status == google.maps.GeocoderStatus.OK) {
new google.maps.Marker({
position: res[0].geometry.location,
map: map
});
}
});
}
and call this function for the array of addresses you have. See this working demo of the multiple marker placement.
Categories: Google, JavaScript, Maps, Programming address to geocode, google maps api, JavaScript, meta-search engine, restaurants