By default, clicking/dragging on a map will cause it to pan.
However, for an application I'm writing with Openlayers,
click/drag will cause a selection box to be drawn. Thus,
instead of the normal pan method, I wanted to have SHIFT be
a toggle for it, so if the user holds down SHIFT and then
drags, it will pan the map.
Is there a way to do this? I've tried capturing the mouse
position during the drag with a OpenLayers.Hanlder.Drag object,
but it seems to be very choppy - not smooth like the default
drag/pan behavior.
Here is the code I currently have for this selection+pan control:
selBoxControl = new OpenLayers.Control();
OpenLayers.Util.extend(selBoxControl, {
draw: function() {
this.selectionHandler = new OpenLayers.Handler.RegularPolygon(
selBoxControl,
{'done': doneSelectBox},
{sides:4, irregular: true, persist: true}
);
this.dragHandler = new OpenLayers.Handler.Drag(
selBoxControl,
{
'down': function(p) {
this.sx = p.x; this.sy = p.y;
},
'move' : function(p) {
var dx = this.sx - p.x;
var dy = this.sy - p.y;
olMap.pan(dx,dy);
this.sx = p.x;
this.sy = p.y;
}
},
{}
);
this.selectionHandler.keyMask = OpenLayers.Handler.MOD_NONE;
this.dragHandler.keyMask = OpenLayers.Handler.MOD_SHIFT;
this.selectionHandler.activate();
this.dragHandler.activate();
}
});
Thanks in advance for any help!
Scott Lewis
National Snow and Ice Data Center
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users