Get latitude and longitude
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
$(document).ready(function () {
var geocoder = new google.maps.Geocoder();
var address = "India";
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(latitude + " " +longitude);
var myCenter = new google.maps.LatLng(latitude, longitude);
}
else {
var myCenter = new google.maps.LatLng(25.204849, 55.270783);
}
});
});
Ref:
https://jsfiddle.net/hn3hj5jy/
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
$(document).ready(function () {
var geocoder = new google.maps.Geocoder();
var address = "India";
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(latitude + " " +longitude);
var myCenter = new google.maps.LatLng(latitude, longitude);
}
else {
var myCenter = new google.maps.LatLng(25.204849, 55.270783);
}
});
});
Ref:
https://jsfiddle.net/hn3hj5jy/
No comments:
Post a Comment