6

Chúng tôi đang gặp sự cố liên quan đến API Google Maps V3. Vấn đề là trong khi chúng tôi kéo Marker, bản đồ cũng bắt đầu kéo.Sự cố trên Internet Explorer + Màn hình cảm ứng Windows8

Chúng tôi đang gặp phải vấn đề này chỉ trên màn hình cảm ứng trong môi trường Windows 8 + Internet Explorer, tiền phạt trên màn hình NORMAL/Màn hình di động - IPaid/các trình duyệt khác (Safari và FireFox).

Chúng tôi sử dụng dưới đây giải pháp, nhưng nó throws lỗi (eval javascript error) trong Internet Explorer9 và 10:

google.maps.event.addListener(marker, 'dragstart', function(){ 
    mapObject.setOptions({ draggable: false }); 
}); 
google.maps.event.addListener(marker, 'dragend', function(){ 
    mapObject.setOptions({ draggable: true }); 
}); 

Sample code is here.

Chúng tôi cũng đã báo cáo vấn đề này ở đây: gmaps-api-issues

EDIT:

Chúng tôi đã một đăng tải một related question đây cũng có.

Trả lời

4

Một số thành công Cuối cùng (bản đồ vẫn di chuyển một chút nhưng có thể bỏ qua tại thời điểm này)!

khai báo hai biến:

var isAnyMarkerIsInDraggingState = false;// if a marker is in drag state this value will be TRUE otherwise FALSE 
var mapCenterPositionAtTheTimeWhenMarkerWasDragged;// Map Center Position 

Khi Marker được kéo:

google.maps.event.addListener(objMarker, 'dragstart', function() { 
     // Store map center position when a marker is dragged 
     mapCenterPositionAtTheTimeWhenMarkerWasDragged = mapObject.getCenter(); 
     isAnyMarkerIsInDraggingState = true; 
    }); 

Khi Marker được giảm (kéo kết thúc):

google.maps.event.addListener(objMarker, 'dragend', function() { 
    // Make Map draggable 
    // Set isAnyMarkerIsInDraggingState = false. Because no marker is in drag state 
    mapObject.setOptions({ draggable: true }); 
    isAnyMarkerIsInDraggingState = false; 
}); 
.210

Khi Map Kéo bắt đầu:

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 }); 
    } 
}); 

Khi Map là trong cách kéo nhà nước:

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); 
    } 
}); 

Complete sample code is here.