我有兩種交互風格,一種突出顯示此功能,另一種突出顯示此功能,第二種顯示特徵名稱爲tooltop。評論都出來了,它們非常快,離開,地圖應用程序在IE和Firefox(但不是Chrome)中變慢。使用任何瀏覽器在OpenLayers 3中進行非常緩慢的懸停交互除了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,同一問題)。 Win 7專業版。 – wowohweewah