How to get location latitude and longitude by address in javascript

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type=”text/javascript” src=”http://maps.google.com/maps/api/js?sensor=false”></script&gt;
<script type=”text/javascript”>

var geocoder = new google.maps.Geocoder();
var address = “נמל תל אביב”;

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();
alert(“lat : “+latitude + ” long : “+longitude);
}
});
</script>
</body>
</html>

Advertisements
This entry was posted in כללי and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s