2012-08-06 115 views
3

我有一個頁面,其中包含建築物的衛星視圖和對齊的平面圖覆蓋圖。有些圖片需要與建築物內的特定位置相關聯,因此我想拖動圖片,將其放在地圖上,並將位置數據用於其他任務。在Google地圖上啓用拖放的準確標記位置

我有這個概念在

http://130.111.148.131/JMCTour/admin/setCoordinates.php?floor=1, 

工作,但標記準確性極不理想。如果您去該網站並放置一個標記,您可以看到位置差異很大。這是真實的,無論使用

point = (pageX, pageY), 
point = (screenX, screenY), 
location = overlay.getProjection().fromDivPixelToLatLng(point), 
location = overlay.getProjection().fromcontainerPixelToLatLng(point) 

我的代碼是

//draggable handler of each photo 
$(".photo").draggable({ 
    helper: "clone", 
    cursor: "move", 
    containment: $("#photosGallery") ? $("#container") : "document" 

}); 

//droppable handler of the map div 
$("#map").droppable({ 
    drop: function(e){ 
    var point = new google.maps.Point(e.pageX, e.pageY); 
    var data = { 
     "location": overlay.getProjection().fromDivPixelToLatLng(point) 
    }; 

    placeMarker(data); 
    } 
}); 

//create a new marker overlay at point 
function placeMarker(location){ 
    var marker = new google.maps.Marker({ 
    position: location.location, 
    map: map, 
    zIndex: 1000, 
    draggable: true 
    }); 
} 

我想有精度工作。儘管確實可以放置一個位置並將其拖到正確的位置,但在第一個位置準確定位會非常有幫助

回答

1

我有一個old V2 demo here,這可能對您有所幫助。當您放下標記時,它會得到精確的緯度/經度,精度爲6位小數。 您的代碼的問題是,e.pageX,e.pageY與整個頁面有關,而不僅僅是包含地圖的div。

相關問題