必应地图pin's拖拽成功,但必应地图移动事件继续
Bing Map pin's dragend called successfully, but Bing Map move event continues
我使用了Bing Maps AJAX Control, Version 7.0。并在地图上显示大头针。要求是,用户可以拖放引脚,当引脚被拖放时,它应该移动到它的实际位置。
现在的问题是,当引脚的拖尾事件调用时,引脚成功地设置到其原始位置,但鼠标没有被释放,当鼠标移动时,地图也被移动。
代码如下:
var isPinDragged = false;
Microsoft.Maps.Events.addHandler(pin, 'dragstart', startDragDetails);
Microsoft.Maps.Events.addHandler(pin, 'drag', dragDetails);
Microsoft.Maps.Events.addHandler(pin, 'dragend', endDragDetails);
function startDragDetails(e) {
lastLocation = e.entity.getLocation();
currentLatitude = e.entity._location.latitude;
currentLongitude = e.entity._location.longitude;
isPinDragged = false;
$(e.entity.cm1002_er_etr.dom).find("img").removeClass("droppable");
}
dragDetails = function (e) {
isPinDragged = true;
};
endDragDetails = function (e) {
if (isPinDragged) {
isPinDragged = false;
$(e.entity.cm1002_er_etr.dom).find("img").addClass("droppable");
e.entity.setLocation(new Microsoft.Maps.Location(currentLatitude, currentLongitude)); //update pin: move back to old position
}
};
更新:我不知道,这个信息。多少帮助解决。我的引脚创建是动态的,会有N个no。每个用户登录的pin。
Microsoft.Maps.loadModule('Microsoft.Maps.Overlays.Style',
{
callback: function () {
map = new Microsoft.Maps.Map(document.getElementById("divDailyCashMap"), mapOptions);
var center = map.getCenter();
var loc = null;
var pin = null;
var pinLayers = new Microsoft.Maps.EntityCollection();
map.entities.push(pinLayers);
var infoboxLayers = new Microsoft.Maps.EntityCollection();
map.entities.push(infoboxLayers);
pinInfobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { visible: false });
infoboxLayers.push(pinInfobox);
$.each(codes, function (index, item) {
loc = new Microsoft.Maps.Location(item.Latitude, item.Longitude);
pin = new Microsoft.Maps.Pushpin(loc, { text: '', draggable: true });
pin.Title = item.Title;
pin.Description = item.CodeDescription;
Microsoft.Maps.Events.addHandler(pin, 'click', displayInfobox);
Microsoft.Maps.Events.addHandler(pin, 'dragstart', startDragDetails);
Microsoft.Maps.Events.addHandler(pin, 'drag', dragDetails);
Microsoft.Maps.Events.addHandler(pin, 'dragend', endDragDetails);
Microsoft.Maps.Events.addHandler(map, 'viewchange', hideInfobox);
Microsoft.Maps.Events.addHandler(map, 'mousemove', mousemoveDetails);
pinLayers.push(pin);
$(pin.cm1002_er_etr.dom).find('img').addClass("droppable").attr({ "data-pinid": item.Code, "data-lat": item.Latitude, "data-long": item.Longitude });
});
}
}
在您的dragDetail()函数中,尝试:
e.handled = true;
它将告诉事件引擎不应该触发其他底层事件。如果它不起作用,你也可以尝试添加这个:
return false;
相关文章:
- 加载自定义磁贴后的谷歌地图事件
- 如何从谷歌地图事件访问光标位置(即页面的x和y轴)
- 谷歌地图事件-获取点击元素的父级
- 访问谷歌地图事件中的Backbone.View功能
- 谷歌地图事件侦听器 jQuery
- 融合地图事件点击
- 来自JS库的谷歌地图事件
- 当任何谷歌地图事件被触发时,如何触发操作
- 在链接点击时触发谷歌地图事件侦听器
- 谷歌地图事件
- 如何跟踪谷歌地图事件
- 给出整个D3地图事件监听器
- 如何为必应地图事件创建闭包
- 为什么我的谷歌地图事件监听器不能正常工作
- 发送额外的参数在谷歌地图事件功能
- 谷歌地图事件对象的元素列表后缺少]
- 谷歌地图事件时间戳
- 如何执行谷歌地图事件"bounds_changed"只有一次
- 谷歌地图-事件监听器创建的标记商店定位器
- 如何在茉莉测试框架中处理谷歌地图事件