<html>
<title>Get Current Location</title>
<head>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script language="JavaScript" type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=geometry"></script>
<script type="text/javascript">
jQuery(function() {
var geocoder = new google.maps.Geocoder();
var add_r="Ahmedabad,India";
geocoder.geocode( { 'address': add_r}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
jQuery('#latitude').text(latitude);
jQuery('#longitude').text(longitude);
jQuery('#content1').text(results[0].formatted_address);
jQuery('#city').text(results[0].address_components[1].long_name);
jQuery('#state').text(results[0].address_components[2].long_name);
jQuery('#country').text(results[0].address_components[3].long_name);
jQuery('#postalcode').text(results[0].address_components[4].long_name);
}
});
});
</script>
<head>
<body>
<div>
<div>
Latitude =<b id="latitude"></b>
</div>
<div>
Longitude =<b id="longitude"></b>
</div>
<div>
City =<b id="city"></b>
</div>
<div>
State =<b id="state"></b>
</div>
<div>
Country =<b id="country"></b>
</div>
<div>
Postal Code =<b id="postalcode"></b>
</div>
<div>
Address =<b id="content1"></b>
</div>
</div>
</body>
</html>
<title>Get Current Location</title>
<head>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script language="JavaScript" type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=geometry"></script>
<script type="text/javascript">
jQuery(function() {
var geocoder = new google.maps.Geocoder();
var add_r="Ahmedabad,India";
geocoder.geocode( { 'address': add_r}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
jQuery('#latitude').text(latitude);
jQuery('#longitude').text(longitude);
jQuery('#content1').text(results[0].formatted_address);
jQuery('#city').text(results[0].address_components[1].long_name);
jQuery('#state').text(results[0].address_components[2].long_name);
jQuery('#country').text(results[0].address_components[3].long_name);
jQuery('#postalcode').text(results[0].address_components[4].long_name);
}
});
});
</script>
<head>
<body>
<div>
<div>
Latitude =<b id="latitude"></b>
</div>
<div>
Longitude =<b id="longitude"></b>
</div>
<div>
City =<b id="city"></b>
</div>
<div>
State =<b id="state"></b>
</div>
<div>
Country =<b id="country"></b>
</div>
<div>
Postal Code =<b id="postalcode"></b>
</div>
<div>
Address =<b id="content1"></b>
</div>
</div>
</body>
</html>
No comments:
Post a Comment