[OpenLayers-Dev] Vector feature redrawing on map panning

Martin Saturka martin.saturka at sourcefabric.org
Wed Mar 16 08:39:39 EDT 2011


Hi,
when you pan a Google map with some points of interest outside the
current map view, those POIs are drawn immediately when they get into
the map view, i.e. during the panning. It is not so at the OL based
maps. We do some event checking (plus putting hooks at some controls,
as shown below) to force POI rendering (one way to force it is by
calling the map.setCenter method). Is there a better way to do that,
please?

Apropos, it looks that this behavior changes somewhat during
OpenLayers development.

// some hooks put inside to handle POI rendering
OpenLayers.Control.DragPanMod = OpenLayers.Class(OpenLayers.Control.DragPan, {
    panMapDone: function(pixel) {
        OpenLayers.Hooks.DragPan.panMapDone(this);
    },
    panMap: function(xy) {
        this.panned = true;

        this.map.pan(this.handler.last.x - xy.x, this.handler.last.y -
xy.y, {dragging: this.handler.dragging, animate: false});

        OpenLayers.Hooks.DragPan.panMap(this);
    },

    CLASS_NAME: "OpenLayers.Control.DragPan"
});

M.

-- 
Martin Saturka
Software Engineer, Sourcefabric
www.sourcefabric.org


More information about the Dev mailing list