-1

How to override moveTo and moveByPx methods of OpenLayers.Map for eliminate "movestart" event triggering for any actions except zooming ?

4

1 回答 1

-1
map = new OpenLayers.Map("map");

OpenLayers.Map.prototype.moveByPx = function (a, b) { 
    var c = this.size.w / 2, 
        d = this.size.h / 2, 
        e = c + a, 
        f = d + b, 
        g = this.baseLayer.wrapDateLine, 
        h = 0, 
        k = 0;

    this.restrictedExtent && (h = c, k = d, g = !1);

    a = g || e <= this.maxPx.x - h && e >= this.minPx.x + h ? Math.round(a) : 0;
    b = f <= this.maxPx.y - k && f >= this.minPx.y + k ? Math.round(b) : 0;

    if (a || b) { 
        this.dragging || (this.dragging = !0);
        this.center = null;
        a && (this.layerContainerOriginPx.x -= a, this.minPx.x -= a, this.maxPx.x -= a);
        b && (this.layerContainerOriginPx.y -= b, this.minPx.y -= b, this.maxPx.y -= b);
        this.applyTransform();
        d = 0;
        for (e = this.layers.length; d < e; ++d) 
            c = this.layers[d], c.visibility && (c === this.baseLayer || c.inRange) && (c.moveByPx(a, b), c.events.triggerEvent("move"));
        this.events.triggerEvent("move") 
    } 
}

map.events.register("movestart", map, function (e) {
  My Code...
});
于 2013-06-19T08:02:43.767 回答