javascript - Multiple addresses (not LatLongs) in Google Maps -


ladies , gents,

long version

i have database full of addresses need plot on google maps, , embed within webpage. addresses displayed textually, rather latlong, so:

"22 sesame street, little village, little town, ab1 9yz"

and said, have number of these, , need plotting on 1 map.

i'm happy using jquery/javascript, php, xml, etc it.

i see lot of sites doing this, seemingly easily, example:

i don't, however, know whether yell uses latlongs it, or full addresses. regardless, have addresses hand.

short version

need plot multiple, textual addresses in 1 google maps window, , embed within site.

disclaimer

i've searched on web on week, unable find definitive answer. did find might have been classed answer (no, not possible), find difficult believe in day in age, things can site relatively easily, now.

maybe i'm being optimistic...

any of can give absolutely golden, , appreciated!

thanks much!

dan!

you need geocode addresses, i.e. convert them lat/lng coordinates, , add them.

if you're using google, obvious choice use google's geocoder.

you can either use server-side google maps geocoding api, where, if create account , api key, can geocode addresses this:

https://maps.googleapis.com/maps/api/geocode/json?address=1600+amphitheatre+parkway,+mountain+view,+ca&key=api_key 

the returned json includes, among other things, lat/lng. use place on map.

alternatively (and better solution), can use client side javascript geocoder built javascript api, in manner similar following:

var geocoder = new google.maps.geocoder(); var address = "mountain view, ca" geocoder.geocode( { 'address': address}, function(results, status) {   if (status == google.maps.geocoderstatus.ok) {     // results contains multiple locations, ordered estimated relevance     var marker = new google.maps.marker({         map: map,         position: results[0].geometry.location     });   } else {     alert("geocode not successful following reason: " + status);   } }); 

this article provides example of client side strategy want employ.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -