On Aug 1, 5:54 pm, haibin <[email protected]> wrote: > hi please help me, i dont know what going on here.
Geocoding is asynchronous (as is clearly stated in the documentation). http://code.google.com/apis/maps/documentation/javascript/services.html#Geocoding > the follow is my > code > > function selectLocation(location){ > if (typeof(location) == 'object'){ > location2 = {'latLng':location}; > } > else { > location2 = {'address': $('#map_input').val()+' > '+location_default['country']}; > } > //location2 = {'address': $('#map_input').val()+' > '+location_default['country']}; > alert(location2['address']); > geocoder.geocode(location2, function(results, status){ > ........................... > }); > > my problem here is that if the location2 has the = {'address': > 'xxxxxxx'} value from the if else statement I am getting this > javascript error from firebug > > Invalid value for property <position>: homberg > [Break on this error] V[A].bindTo=function(a,b,c,d){c=c|| > a;v...a=a.f[1])?new Ue(a):cf}var ef=new Ue; main.js (line 28) > > no problem with if the location has ={'latLng': xxxxx} value. > > But when I uncomment the line "location2 = {'address': $ > ('#map_input').val()+' '+location_default['country']};" just before > the geocoder.gecode(....) no error occur > > Is there something wrong with my code? I can't run a debugger on it. You did that and it failed. I would say the answer is yes. You left out the callback function, which is the only place that the data returned from google will be available. Might I suggest that you look at the example provided in the documentation, see if that works for you and go from there? http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-simple.html -- Larry > > Thanks -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
