Вопрос

I have a heatmap and set of markers that are rendering fine in OpenLayers. Afterwards, when I change the center of the map programmatically using map.setCenter the heatmap appears offset by exactly double the change of center location. (So if the new center is 1km east, the heatmap appears offset by 2km east)

It's almost as though the redrawing of the heatmap layer is over compensating.

Has anyone come across this before and solved it? I've tried called heatmapLayer.redraw() to no avail.

I'm using OpenLayers 2.13.1 and Patrick Weid's heatmap.js' openlayers support.

Это было полезно?

Решение

I've managed to find a fix. No idea why this seems to work though when heatmaplayer.redraw() doesn't.

For the benefit of others:-

this.map.setCenter( new OpenLayers.LonLat(lon,lat).transform(
  this.transformWgs84, this.map.projection), zoom,true,true);

the second 'true' did the trick. According to the OpenLayers docs this should just force a zoom change. It seems to also force a heatmap layer redraw. (The first true parameter forces drag events)

Docs: http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.setCenter

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top