Avoid re-rendering map on every mousemove
This commit is contained in:
@@ -55,6 +55,7 @@ $.getJSON('data/countries.geojson', function(data) {
|
|||||||
|
|
||||||
var highlight;
|
var highlight;
|
||||||
var displayFeatureInfo = function(pixel) {
|
var displayFeatureInfo = function(pixel) {
|
||||||
|
var oldHighlight = highlight;
|
||||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
var coordinate = map.getCoordinateFromPixel(pixel);
|
||||||
var features = vectorSource.getAllFeaturesAtCoordinate(coordinate);
|
var features = vectorSource.getAllFeaturesAtCoordinate(coordinate);
|
||||||
var info = document.getElementById('info');
|
var info = document.getElementById('info');
|
||||||
@@ -66,7 +67,9 @@ var displayFeatureInfo = function(pixel) {
|
|||||||
info.innerHTML = ' ';
|
info.innerHTML = ' ';
|
||||||
highlight = undefined;
|
highlight = undefined;
|
||||||
}
|
}
|
||||||
|
if (highlight !== oldHighlight) {
|
||||||
map.render();
|
map.render();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(map.getViewport()).on('mousemove', function(evt) {
|
$(map.getViewport()).on('mousemove', function(evt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user