i can't publish the map: it's all offline. now i try to apply this example to my map, but the "strange thing" is that I don't receive a "620 error" from the geocode; the service works well, but probably I'm not able to return to the program the correct result (the var geocode is "undefined").
On 9 Lug, 15:38, "geocode...@gmail.com" <geocode...@gmail.com> wrote: > On Jul 9, 12:31 am, fil <fuxi...@gmail.com> wrote: > > > how can I modify it? > > Modify what? If you mean the geocoder, you can't. > > If you mean your code, you have to put any code that uses the returned > data in the callback function. > See this page from Mike Williams' tutorial (the tutorial is for v2, > but this topic is applicable to your problem) > Javascript Concepts - Part 2 Asynchronous > I/Ohttp://econym.org.uk/gmap/async.htm > > If you want specific suggestions on code, you should post a link to > your map (as requested in the posting guidelines), not code. > > -- Larry > > > > > On 8 Lug, 18:06, "geocode...@gmail.com" <geocode...@gmail.com> wrote: > > > > On Jul 8, 8:59 am, fil <fuxi...@gmail.com> wrote: > > > > > I've tryed some solutions and I have a new alert: > > > > > I've modified the function named converti_indirizzo > > > > > function converti_indirizzo(var1, var2) > > > > { > > > > if (geocoder) > > > > { > > > > geocoder.geocode( > > > > {'address' : var1+' '+var2}, function (results, status) > > > > { > > > > if (status == google.maps.GeocoderStatus.OK) > > > > { > > > > > var posizione = results[0].geometry.location; > > > > masticazzi = new google.maps.LatLng((posizione.lat()), > > > > posizione.lng())); > > > > > map.setCenter(results[0].geometry.location); > > > > > alert (masticazzi); > > > > return masticazzi;} > > > > > else > > > > { > > > > > } > > > > }); > > > > } > > > > } > > > > > now the alert print on the screen the lat and the lng of the place > > > > that I've specified. > > > > > but in the first function > > > > > downloadUrl("php_to_xml.php", function(data) > > > > { > > > > var xml = parseXml(data); > > > > var markers = > > > > xml.documentElement.getElementsByTagName("marker"); > > > > for (var i = 0; i < markers.length; i++) > > > > { > > > > var name = markers[i].getAttribute("Sigla"); > > > > var address = markers[i].getAttribute("Indirizzo"); > > > > var place = markers[i].getAttribute("Citta"); > > > > var geocodato = new google.maps.LatLng; > > > > geocodato = converti_indirizzo(address,place); > > > > alert (geocodato); > > > > var marker = new google.maps.Marker( > > > > { > > > > map: map, > > > > position: geocodato > > > > > }); > > > > > } > > > > > }); > > > > > the alert print on the screen "Undefined". > > > > > why? the function function converti_indirizzo return an > > > > "google.maps.LatLng" object, but it seems undefined... > > > > > the geocoding works, but i can't understand where i'm wrong. > > > > thanks in advance. > > > > The geocoding is asynchronous. > > > 1. you call the function converti_indirizzo > > > 2. it fires off a request to google's servers for the coordinates of > > > the given address > > > 3. it returns null > > > 4. sometime later the result comes back and the callback function > > > runs, bringing up the alert message, then returning the GLatLng (but > > > it doesn't have a caller, so it goes nowhere). > > > > -- Larry > > > > > On 8 Lug, 17:35, Rossko <ros...@culzean.clara.co.uk> wrote: > > > > > > > i don't have the information of lat and lng into the db, otherwise > > > > > > i'll use it! > > > > > > This is why I pointed you to the example that shows how to geocode a > > > > > set of addresses in your database, and store lat+long in your database > > > > > alongside each address. > > > > > > You do it once ; this is much better both for your users and for other > > > > > people using Google's services, than geocoding the same points every > > > > > time someone loads your map webpage. > > > > > > If any addresses fail geocoding, or come up with results you don't > > > > > want, you can fix them in your database - rather than have them fail > > > > > everytime someone looks at your map webpage.- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - -- 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 google-maps-js-api...@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.