Touch Screen - Marker Drag n Drop Issue
http://stackoverflow.com/questions/16098971/touch-screen-error-while-setting-draggable-property-of-google-map
HTML
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<div id="map_canvas" style="border: 1px solid black; width: 1000px; height: 500px;">
map div
</div>
JavaScript
var isAnyMarkerIsInDraggingState = false;
var mapCenterPositionAtTheTimeWhenMarkerWasDragged;
var initialLocation = new google.maps.LatLng(59.312608,18.070107);
var mapOptions = { zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: initialLocation
};
var mapObject = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
google.maps.event.addListener(mapObject, 'dragstart', function () {
// isAnyMarkerIsInDraggingState = true: means the user is dragging a marker.
// If the user is dragging the Marker then don't allow the Map to be Dragged
if (isAnyMarkerIsInDraggingState) {
mapObject.setOptions({ draggable: false });
}
});
google.maps.event.addListener(mapObject, 'drag', function () {
// isAnyMarkerIsInDraggingState = true: means the user is dragging a marker.
// If the user is dragging the Marker then don't allow the Map to be Dragged and set its CenterPosition
// to mapCenterPositionAtTheTimeWhenMarkerWasDragged
if (isAnyMarkerIsInDraggingState) {
mapObject.setCenter(mapCenterPositionAtTheTimeWhenMarkerWasDragged);
}
});
function dropMarker() {
var objMarker = new google.maps.Marker({
position: mapObject.getCenter(),
map: mapObject,
draggable: true,
animation: google.maps.Animation.DROP
});
google.maps.event.addListener(objMarker, 'dragstart', function () {
// Store map center position when a marker is dragged
mapCenterPositionAtTheTimeWhenMarkerWasDragged = mapObject.getCenter();
isAnyMarkerIsInDraggingState = true;
});
google.maps.event.addListener(objMarker, 'dragend', function () {
// Make Map draggable
// Set isAnyMarkerIsInDraggingState = false. Because no marker is in drag state
mapObject.setOptions({...