I have never used JavaScript. In my application I am using SQL Server database 2005 which contains almost 2200 addresses of a particular city. I have to find the latitude and longitude of all these locations. For that I want to use JavaScript. Can someone guide me how to use JavaScript for finding latitude and longitude of multiple addresses?
Asked
Active
Viewed 422 times
1
-
Why does it need to be JavaScript? First build your server application and show it to us, then we might lead you to how to enhance it with JS. – Bergi Jun 28 '12 at 09:56
1 Answers
1
Try this :
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> <script type="text/javascript"> var geocoder = new google.maps.Geocoder(); var address = "new york"; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var latitude = results[0].geometry.location.lat(); var longitude = results[0].geometry.location.lng(); } }); </script>

Ravinder Singh
- 3,113
- 6
- 30
- 46
-
i tried this.it is working for a single address.but wen i use it for n number of addresses it is not working. – user1387035 Jun 28 '12 at 10:00
-
that's what i am saying, show me how you are putting the code in loop? – Ravinder Singh Jun 28 '12 at 10:38
-
Line 21 the address:address should be address:address[i]; no need for pastie you are iterating it wrong – ShrekOverflow Jun 28 '12 at 11:25