0
我有一組具有draggable=true
設置的圖像。這些圖像的目的是拖動,然後放到谷歌地圖視圖,並在放置位置創建一個標記。爲了防止地圖上出現重複圖像,我想禁用可拖動設置並更改不透明度。刪除可拖動的屬性
我的地圖可投放和相片可拖動的處理程序是
$("#photo"+i).draggable({
helper: "clone",
cursor: "move",
containment: 'body',
start: function(e){
$(this).addClass("fade");
currentPhoto = $(this);
}
});
$("#map").droppable({
drop: function(e){
var point = new google.maps.Point(e.pageX, e.pageY);
var data = {
"location": overlay.getProjection().fromDivPixelToLatLng(point),
"photo": currentPhoto
}
makeMarkers(data.location, $(data.photo).attr("src"), $(data.photo).attr('id'));
}
});
內部makeMarkers
,所述type
值用於確定是否正在對頁負載創建從數據庫檢索的值或作爲照片圖像的ID標記被拖拽。
function makeMarkers(location, title, type){
//variable and marker initialization here
if (type == "onload")
newMarker.setIcon(savedLocation);
else {
newMarker.setIcon(unsavedLocation);
$("img."+type).attr("draggable", "false");
$("img."+type).attr("opacity", "0.5");
console.log("Disabling draggability of " +type);
}
//marker event handlers here
}
我可以拖放圖像,並在該位置創建一個新的標記。但是,圖像屬性不變。如何啓用此功能