【发布时间】:2015-10-20 20:19:18
【问题描述】:
我有两种交互方式,一种是突出显示功能,第二种是放置一个带有功能名称的工具栏。将两者都注释掉,它们都非常快,留下任何一个,地图应用程序在 IE 和 Firefox(但不是 Chrome)中变慢。
map.addInteraction(new ol.interaction.Select({
condition: ol.events.condition.pointerMove,
layers: [stationLayer],
style: null // this is actually a style function but even as null it slows
}));
$(map.getViewport()).on('mousemove', function(evt) {
if(!dragging) {
var pixel = map.getEventPixel(evt.originalEvent);
var feature = null;
// this block directly below is the offending function, comment it out and it works fine
map.forEachFeatureAtPixel(pixel, function(f, l) {
if(f.get("type") === "station") {
feature = f;
}
});
// commenting out just below (getting the feature but doing nothing with it, still slow
if(feature) {
target.css("cursor", "pointer");
$("#FeatureTooltip").html(feature.get("name"))
.css({
top: pixel[1]-10,
left: pixel[0]+15
}).show();
} else {
target.css("cursor", "");
$("#FeatureTooltip").hide();
}
}
});
我的意思是这似乎是 OpenLayers-3 的一个问题,但我只是想确保我没有在这里忽略其他东西。
哦,是的,大约有 600 多分。这是很多,但并非不合理,所以我认为。放大以限制视图中的功能肯定会有所帮助。所以我猜这是一个功能问题。
【问题讨论】:
-
除了具有约 600 个点的图层之外,您在地图上还有其他矢量图层吗?
-
您在哪些版本的浏览器上遇到此问题?还有操作系统?
-
我有一个 CA 县图层(来自 kml),我不想与之交互(因此检查 forEachFeatureAtPixel 以确保它是一个车站功能)。现在就是这样。 Chrome 46.0.2490.71 m,IE 11.0.9600.18059,FF 38.01(刚刚更新到 41.02,同样的问题)。赢 7 专业版。
-
你选择一个正确的答案并完成这个帖子怎么样?
-
感谢您的帮助,但技术上没有解决方案,是吗?如果可以的话,我会赞成有用的建议,但我没有足够的声誉。现在,如果常见的礼仪是标记一个解决方案,即使它不是真的(因为这更像是一个我无法控制的错误),我肯定会这样做,但是,天哪,我显然是一个新帐户,没必要对此一味消极攻击。
标签: openlayers-3