Witam
Kod dla mapy google pozwala dynamicznie wyświetlać dane LAT,LONG w polach input po przesunięciu markera, jak można uzyskać ten efekt sam efekt w odwrotną stronę? tj. po wpisaniu w input danych LAT,LONG by dynamicznie marker się do nich dostosował?
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
(function($) {
$(window).load(function() {
var latitude = parseFloat($(\'#ItemMapLatitude\').val()),
longitude = parseFloat($(\'#ItemMapLongitude\').val()),
zoom = parseInt($(\'#ItemMapZoom\').val()),
setMarkerPosition = function(latitude, longitude) {
$(\'#ItemMapLatitude\').val(latitude);
$(\'#ItemMapLongitude\').val(longitude);
},
setZoom = function(z) {
$(\'#ItemMapZoom\').val(z);
};
var options = {
zoom: zoom,
center: new google.maps.LatLng(latitude, longitude),
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: true,
navigationControl: true,
disableDefaultUI: true
};
var map = new google.maps.Map(document.getElementById(\'addMap\'), options);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map,
draggable: true,
title: \'\'
});
google.maps.event.addListener(marker, \'mouseup\', function() {
setMarkerPosition(marker.getPosition().lat(), marker.getPosition().lng());
});
google.maps.event.addListener(map, \'zoom_changed\', function() {
setZoom(map.getZoom());
});
});
})(jQuery);
</script>
<input type="text" name="lat" step="any" type="number" value="51.98" id="ItemMapLatitude" />
<input type="text" name="long" step="any" type="number" value="19.31" id="ItemMapLongitude" />
Ten post edytował maksik 18.09.2014, 13:40:22