Created
December 22, 2016 17:01
This file contains 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
var map; | |
var latIni; | |
var lngIni; | |
var isNew=1; | |
function initMap() { | |
var myLatlng = new google.maps.LatLng(latIni,lngIni); | |
map = new google.maps.Map(document.getElementById('map'),{ | |
center: myLatlng, | |
zoom: 20, | |
disableDefaultUI: true | |
}); | |
map.addListener('click', function(e){ | |
placeMarkerAndPanTo(e.latLng, map); | |
}); | |
} | |
function placeMarkerAndPanTo(latLng, map) { | |
if (isNew==1) { | |
var marker = new google.maps.Marker({ | |
position: latLng, | |
map: map, | |
draggable: true | |
}); | |
map.panTo(latLng); | |
marker.addListener('drag', handleEvent); | |
marker.addListener('dragend', handleEvent); | |
isNew=0; | |
} | |
} | |
function handleEvent(event) { | |
$('#frmCoordenadas\\:oplLat').val(event.latLng.lat()); | |
$('#frmCoordenadas\\:oplLng').val(event.latLng.lng()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment