Created
August 16, 2013 12:08
-
-
Save masstack/6249299 to your computer and use it in GitHub Desktop.
1
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
/* | |
jQuery(document).ready(function(){ | |
var myLatlng = new google.maps.LatLng(-34.397, 150.644); | |
var myOptions = { | |
zoom: 1, | |
center: myLatlng | |
// mapTypeId: google.maps.MapTypeId.ROADMAP | |
} | |
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
}) | |
*/ | |
/*function initialize() { | |
var myLatlng = new google.maps.LatLng(-34.397, 150.644); | |
var myOptions = { | |
zoom: 8, | |
center: myLatlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
} | |
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); | |
}*/ | |
jQuery(document).ready(function(){ | |
//console.log(myLocation); | |
jQuery('#map-canvas'); | |
// var myLatLng = new google.maps.LatLng(38.971154274048345, 1.415863037109375); | |
Init(); | |
jQuery('.widget-control-save').ajaxComplete(function(){ | |
Init(); | |
}) | |
}); | |
function Init(){ | |
var latlng = new google.maps.LatLng(myLocation.X, myLocation.Y); | |
var mapOptions = { | |
zoom: 3, | |
center: latlng, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
var map = new google.maps.Map(jQuery('body').find('.div_map')[1], mapOptions); | |
google.maps.event.addListener(map, 'click', function (event) { | |
addMarker(event.latLng); | |
var count = jQuery('.countMark').val(); | |
//console.log(count); | |
jQuery('.countMark').val(parseInt(++count)); | |
}) | |
//------------------------------------- | |
for(var i=0; i < jQuery('.countMark').val(); i++){ | |
//draw markers | |
} | |
//------------------------------------- | |
var allMarkers = []; | |
function addMarker() { | |
console.log(myLocation); | |
marker = new google.maps.Marker({ | |
map:map, | |
animation: google.maps.Animation.DROP, | |
position: new google.maps.LatLng(myLocation.X, myLocation.Y), | |
draggable: true | |
}); | |
if(myLocation.X =='' && myLocation.Y ==''){ | |
position: new google.maps.LatLng(49.95121990866206, 10.8984375); | |
} | |
google.maps.event.addListener(marker, 'click', toggleBounce); | |
google.maps.event.addListener(marker, 'dragend', function(event){ | |
jQuery('.loth').val(event.latLng.mb); | |
jQuery('.langh').val(event.latLng.nb); | |
//jQuery('.langh').val(marker.getPosition().lng()); | |
}) | |
} | |
} | |
/*function changeMarkerPosition(marker) { | |
var latlng = new google.maps.LatLng(-24.397, 140.644); | |
marker.setPosition(latlng); | |
}*/ | |
function toggleBounce() { | |
if (marker.getAnimation() != null) { | |
marker.setAnimation(null); | |
} else { | |
marker.setAnimation(google.maps.Animation.BOUNCE); | |
} | |
} | |
google.maps.event.addDomListener(window, 'load', Init); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment