javascript - Google Map GetLocation Return String -


i have piece of code ,

geocoder = new gclientgeocoder(); var state;  function addaddresstomap(response) {   if (!response || response.status.code != 200) {     alert("sorry, unable geocode address");   }    else {     place = response.placemark[0];     state = place.addressdetails.country.administrativearea.administrativeareaname;   } }  // showlocation() called when click on search button // in form.  geocodes address entered form // , adds marker map @ location. function showlocation() {   var address = "mutiara damansara";   geocoder.getlocations(address, addaddresstomap);    return state; } 

alright , updated codes . try instantiate showlocation() , variable state isn't being updated addaddresstomap function .

thanks

your updated code helps see picture little better.

it looks addaddresstomap() expecting response variable function arguments.

when it's called geocoder.getlocations(address,addaddresstomap) there's no response passed.

so, first if statement !response true, , state remains unset.

to fix, need pass when call addaddresstomap(). looks xmlhttprequest (ajax) object somewhere else in script.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -