Also this time I reply to a comment with a post, given the general interest. Armando asked me if it was possible, through Google Maps, Latitude and Longitude obtain from a city name or street. The answer is yes! Using the Google Maps API geocoding service you can directly ask Google trasfromare our textual information (state, city, street) in geographical coordinates. You can try a sample online direct on the documementazione Google.
The main object that allows this is GClientGeocoder . . Using the method getLatLng() you can convert a string into an object address GLatLng .
NOTE: remember to include the need to apply for a free Google API key: see How to add Google Map in your Web on how to get the API key. This will be used for the inclusion of the script, in the form:
1 |
Where is 'ABCDEFG', it should be replaced with the key that Google releases free: Get key Google .
The use of this object is really simple, as most of the API provided by Google:
1 2 3 4 5 6 7 8 9 10 11 12 13 | / / Create the object GClientGeocoder new GClientGeocoder ( ) ; var geocoder = new GClientGeocoder (); / / The address is just a text, it could also be just a city 'via salaria, roma, italia' ; var address = 'Via Salaria, Rome, Italy'; address , geocoder. getLatLng (address, point ) { function (point) { ! point ) { if (point) { address + ' non trovato' ) ; alert (address + 'not found'); { Else {} 'Latitudine = ' + point. lat ( ) + ' Longitudine = ' + point. lng ( ) ) ; alert ('Latitude =' + point. lat () + 'Longitude =' + point. lng ()); } } ); |
For completeness, I also show how to perform the reverse process at this point. Adding an event to our map, in fact, it is possible to know what are the values of Latitude and Longitude:
1 2 3 4 5 6 | map , "click" , GEvent. AddListener (map, "click", overlay , point ) { function (overlay, point) { "Latitudine = " + point. lat ( ) + " Longitudine = " + point. lng ( ) ; myHtml var = "Latitude =" + point. lat () + "Longitude =" + point. lng (); point , myHtml ) ; map. openInfoWindow (point, myHtml); } ); |











[...] Full of [...]
Great thank you!
goods!
pour ceux here developpe en local, vous pouvez utiliser http://localhost pour la demande de cle google
Thank you for your help.
Even more simple and fully automatic is:
http://mygeoposition.com
Thanks I was looking for this
[...] For example, you can use the service provided by Google Geocoding and discussed in Google Maps: how to get Latitude and Longitude from an address. On Apple iPhone, or iPad, you can however overcome this obstacle by using so [...]
I state that I am a Beginner_________.
I'm trying to insert into mysite the google map, getting latitude and longitude with the object GClientGeocoder.
But I have not figured out how to do ....
And 'possible to have a complete example starting from
and ending at
THANKS for the help!
Thanks for the article.
It was just what I was looking for.
I managed to fully integrate this functionality into my site.