Created
October 4, 2015 09:34
-
-
Save shohel/6599f8b96e9820dd8e4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function executeMap(x =''){ | |
var marker, map; | |
function initialize() { | |
var myLatlng = new google.maps.LatLng(29.350578853144864, 47.98828125); | |
var mapOptions = { | |
zoom: 10, | |
center: myLatlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
} | |
map = new google.maps.Map(document.getElementById('map_canvas'+x), mapOptions); | |
marker = new google.maps.Marker({ | |
position: myLatlng, | |
map: map, | |
title: 'Hello World!' | |
}); | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function (position) { | |
initialLocation = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); | |
map.setCenter(initialLocation); | |
}); | |
} | |
} | |
$(function() { | |
initialize(); | |
google.maps.event.addListener(map, 'click', function(event) { | |
var lat=event.latLng.lat(); | |
var lng=event.latLng.lng(); | |
//$('#latlng').val(lat+', '+lng); | |
$('#lat'+x).val(lat); | |
$('#long'+x).val(lng); | |
marker.animateTo(event.latLng); | |
}); | |
}); | |
} | |
executeMap(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment