Merge vector-2.4 branch back to trunk.
svn merge sandbox/vector-2.4/@2307 sandbox/vector-2.4/@HEAD trunk/openlayers/ git-svn-id: http://svn.openlayers.org/trunk/openlayers@2803 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
59
lib/OpenLayers/Control/DragPan.js
Normal file
59
lib/OpenLayers/Control/DragPan.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Handler/Drag.js
|
||||
*/
|
||||
OpenLayers.Control.DragPan = OpenLayers.Class.create();
|
||||
OpenLayers.Control.DragPan.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
/** @type OpenLayers.Control.TYPES */
|
||||
type: OpenLayers.Control.TYPE_TOOL,
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
draw: function() {
|
||||
this.handler = new OpenLayers.Handler.Drag( this,
|
||||
{"move": this.panMap, "up": this.panMapDone } );
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} xy Pixel of the up position
|
||||
*/
|
||||
panMap: function (xy) {
|
||||
var deltaX = this.handler.start.x - xy.x;
|
||||
var deltaY = this.handler.start.y - xy.y;
|
||||
var size = this.map.getSize();
|
||||
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
|
||||
size.h / 2 + deltaY);
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
|
||||
this.map.setCenter(newCenter, null, true);
|
||||
// this assumes xy won't be changed inside Handler.Drag
|
||||
// a safe bet for now, and saves us the extra call to clone().
|
||||
this.handler.start = xy;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} xy Pixel of the up position
|
||||
*/
|
||||
panMapDone: function (xy) {
|
||||
var deltaX = this.handler.start.x - xy.x;
|
||||
var deltaY = this.handler.start.y - xy.y;
|
||||
var size = this.map.getSize();
|
||||
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
|
||||
size.h / 2 + deltaY);
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
|
||||
this.map.setCenter(newCenter, null, false);
|
||||
// this assumes xy won't be changed inside Handler.Drag
|
||||
// a safe bet for now, and saves us the extra call to clone().
|
||||
this.handler.start = xy;
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.DragPan"
|
||||
});
|
||||
63
lib/OpenLayers/Control/DrawFeature.js
Normal file
63
lib/OpenLayers/Control/DrawFeature.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* Draws features on a vector layer when active.
|
||||
*
|
||||
* @class
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Feature/Vector.js
|
||||
*/
|
||||
OpenLayers.Control.DrawFeature = OpenLayers.Class.create();
|
||||
OpenLayers.Control.DrawFeature.prototype =
|
||||
OpenLayers.Class.inherit(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* @type OpenLayers.Layer.Vector
|
||||
*/
|
||||
layer: null,
|
||||
|
||||
/**
|
||||
* @type {Object} The functions that are sent to the handler for callback
|
||||
*/
|
||||
callbacks: {},
|
||||
|
||||
/**
|
||||
* @type {Function} Called after each feature is added
|
||||
*/
|
||||
featureAdded: function() {},
|
||||
|
||||
/**
|
||||
* Used to set non-default properties on the control's handler
|
||||
*
|
||||
* @type Object
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Layer.Vector} layer
|
||||
* @param {OpenLayers.Handler} handler
|
||||
* @param {Object} options
|
||||
*/
|
||||
initialize: function(layer, handler, options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.callbacks = OpenLayers.Util.extend({done: this.drawFeature},
|
||||
this.callbacks);
|
||||
this.layer = layer;
|
||||
this.handler = new handler(this, this.callbacks, this.handlerOptions);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
drawFeature: function(geometry) {
|
||||
var feature = new OpenLayers.Feature.Vector(geometry);
|
||||
this.layer.addFeatures([feature]);
|
||||
this.featureAdded(feature);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.DrawFeature"
|
||||
});
|
||||
48
lib/OpenLayers/Control/EditingToolbar.js
Normal file
48
lib/OpenLayers/Control/EditingToolbar.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control/Panel.js
|
||||
* @requires OpenLayers/Control/Navigation.js
|
||||
* @requires OpenLayers/Control/DrawFeature.js
|
||||
*/
|
||||
OpenLayers.Control.EditingToolbar = OpenLayers.Class.create();
|
||||
OpenLayers.Control.EditingToolbar.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control.Panel, {
|
||||
|
||||
/**
|
||||
* Create an editing toolbar for a given layer.
|
||||
* @param OpenLayers.Layer.Vector layer
|
||||
* @param Object options
|
||||
*/
|
||||
initialize: function(layer, options) {
|
||||
OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
|
||||
|
||||
this.addControls(
|
||||
[ new OpenLayers.Control.Navigation() ]
|
||||
);
|
||||
var controls = [
|
||||
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {'displayClass': 'olControlDrawFeaturePoint'}),
|
||||
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'}),
|
||||
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {'displayClass': 'olControlDrawFeaturePolygon'})
|
||||
];
|
||||
for (var i = 0; i < controls.length; i++) {
|
||||
controls[i].featureAdded = function(feature) { feature.state = OpenLayers.State.INSERT; }
|
||||
}
|
||||
this.addControls(controls);
|
||||
},
|
||||
|
||||
/**
|
||||
* calls the default draw, and then activates mouse defaults.
|
||||
*/
|
||||
draw: function() {
|
||||
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
|
||||
this.activateControl(this.controls[0]);
|
||||
return div;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.EditingToolbar"
|
||||
});
|
||||
@@ -7,6 +7,7 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Handler/Keyboard.js
|
||||
*/
|
||||
OpenLayers.Control.KeyboardDefaults = OpenLayers.Class.create();
|
||||
OpenLayers.Control.KeyboardDefaults.prototype =
|
||||
@@ -26,16 +27,16 @@ OpenLayers.Control.KeyboardDefaults.prototype =
|
||||
*
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Event.observe(document,
|
||||
'keypress',
|
||||
this.defaultKeyDown.bindAsEventListener(this));
|
||||
this.handler = new OpenLayers.Handler.Keyboard( this, {
|
||||
"keypress": this.defaultKeyPress });
|
||||
this.activate();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
* @param {Integer} code
|
||||
*/
|
||||
defaultKeyDown: function (evt) {
|
||||
switch(evt.keyCode) {
|
||||
defaultKeyPress: function (code) {
|
||||
switch(code) {
|
||||
case OpenLayers.Event.KEY_LEFT:
|
||||
this.map.pan(-50, 0);
|
||||
break;
|
||||
@@ -49,17 +50,11 @@ OpenLayers.Control.KeyboardDefaults.prototype =
|
||||
this.map.pan(0, 50);
|
||||
break;
|
||||
case 33: // Page Up
|
||||
this.map.zoomIn();
|
||||
break;
|
||||
case 34: // Page Down
|
||||
this.map.zoomOut();
|
||||
break;
|
||||
}
|
||||
switch(evt.charCode) {
|
||||
case 43: // +
|
||||
this.map.zoomIn();
|
||||
break;
|
||||
case 45: // -
|
||||
case 34: // Page Down
|
||||
this.map.zoomOut();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.LayerSwitcher = OpenLayers.Class.create();
|
||||
OpenLayers.Control.LayerSwitcher.prototype =
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
@@ -12,6 +11,10 @@ OpenLayers.Control.MouseDefaults = OpenLayers.Class.create();
|
||||
OpenLayers.Control.MouseDefaults.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
|
||||
/** WARNING WARNING WARNING!!!
|
||||
This class is DEPRECATED in 2.4 and will be removed by 3.0.
|
||||
If you need this functionality, use Control.Navigation instead!!! */
|
||||
|
||||
/** @type Boolean */
|
||||
performedDrag: false,
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ OpenLayers.Control.MousePosition.prototype =
|
||||
if (!this.element) {
|
||||
this.div.left = "";
|
||||
this.div.top = "";
|
||||
this.div.className = "olControlMousePosition";
|
||||
this.div.className = this.displayClass;
|
||||
this.element = this.div;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ OpenLayers.Control.MouseToolbar.Y = 300;
|
||||
OpenLayers.Control.MouseToolbar.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control.MouseDefaults, {
|
||||
|
||||
/** WARNING WARNING WARNING!!!
|
||||
This class is DEPRECATED in 2.4 and will be removed by 3.0.
|
||||
If you need this functionality, use Control.NavToolbar instead!!! */
|
||||
|
||||
mode: null,
|
||||
|
||||
buttons: null,
|
||||
|
||||
37
lib/OpenLayers/Control/NavToolbar.js
Normal file
37
lib/OpenLayers/Control/NavToolbar.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control/Panel.js
|
||||
* @requires OpenLayers/Control/Navigation.js
|
||||
* @requires OpenLayers/Control/ZoomBox.js
|
||||
*/
|
||||
OpenLayers.Control.NavToolbar = OpenLayers.Class.create();
|
||||
OpenLayers.Control.NavToolbar.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control.Panel, {
|
||||
|
||||
/**
|
||||
* Add our two mousedefaults controls.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.Panel.prototype.initialize.apply(this, arguments);
|
||||
this.addControls([
|
||||
new OpenLayers.Control.Navigation(),
|
||||
new OpenLayers.Control.ZoomBox()
|
||||
]);
|
||||
},
|
||||
|
||||
/**
|
||||
* calls the default draw, and then activates mouse defaults.
|
||||
*/
|
||||
draw: function() {
|
||||
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
|
||||
this.activateControl(this.controls[0]);
|
||||
return div;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.NavToolbar"
|
||||
});
|
||||
80
lib/OpenLayers/Control/Navigation.js
Normal file
80
lib/OpenLayers/Control/Navigation.js
Normal file
@@ -0,0 +1,80 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control/ZoomBox.js
|
||||
* @requires OpenLayers/Control/DragPan.js
|
||||
* @requires OpenLayers/Handler/MouseWheel.js
|
||||
*/
|
||||
OpenLayers.Control.Navigation = OpenLayers.Class.create();
|
||||
OpenLayers.Control.Navigation.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
|
||||
/** @type OpenLayers.Control.ZoomBox */
|
||||
dragPan: null,
|
||||
|
||||
/** @type OpenLayers.Control.ZoomBox */
|
||||
zoomBox: null,
|
||||
|
||||
/** @type OpenLayers.Handler.MouseWheel */
|
||||
wheelHandler: null,
|
||||
|
||||
activate: function() {
|
||||
this.dragPan.activate();
|
||||
this.wheelHandler.activate();
|
||||
this.zoomBox.activate();
|
||||
return OpenLayers.Control.prototype.activate.apply(this,arguments);
|
||||
},
|
||||
|
||||
deactivate: function() {
|
||||
this.zoomBox.deactivate();
|
||||
this.dragPan.deactivate();
|
||||
this.wheelHandler.deactivate();
|
||||
return OpenLayers.Control.prototype.deactivate.apply(this,arguments);
|
||||
},
|
||||
|
||||
draw: function() {
|
||||
this.map.events.register( "dblclick", this, this.defaultDblClick );
|
||||
this.dragPan = new OpenLayers.Control.DragPan({map: this.map});
|
||||
this.zoomBox = new OpenLayers.Control.ZoomBox(
|
||||
{map: this.map, keyMask: OpenLayers.Handler.MOD_SHIFT});
|
||||
this.dragPan.draw();
|
||||
this.zoomBox.draw();
|
||||
this.wheelHandler = new OpenLayers.Handler.MouseWheel(
|
||||
this, {"up" : this.wheelUp,
|
||||
"down": this.wheelDown} );
|
||||
this.activate();
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Event} evt
|
||||
*/
|
||||
defaultDblClick: function (evt) {
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
OpenLayers.Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/** User spun scroll wheel up
|
||||
*
|
||||
*/
|
||||
wheelUp: function(evt) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
|
||||
this.map.getZoom() + 1);
|
||||
},
|
||||
|
||||
/** User spun scroll wheel down
|
||||
*
|
||||
*/
|
||||
wheelDown: function(evt) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
|
||||
this.map.getZoom() - 1);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.Navigation"
|
||||
});
|
||||
@@ -10,6 +10,8 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/BaseTypes.js
|
||||
* @requires OpenLayers/Events.js
|
||||
*/
|
||||
OpenLayers.Control.OverviewMap = OpenLayers.Class.create();
|
||||
|
||||
@@ -31,7 +33,7 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
|
||||
/**
|
||||
* The overvew map size in pixels. Note that this is the size of the map
|
||||
* itself - the element that contains the map (class name
|
||||
* itself - the element that contains the map (default class name
|
||||
* olControlOverviewMapElement) may have padding or other style attributes
|
||||
* added via CSS.
|
||||
* @type OpenLayers.Size
|
||||
@@ -93,7 +95,7 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
|
||||
// create overview map DOM elements
|
||||
this.element = document.createElement('div');
|
||||
this.element.className = 'olControlOverviewMapElement';
|
||||
this.element.className = this.displayClass + 'Element';
|
||||
this.element.style.display = 'none';
|
||||
|
||||
this.mapDiv = document.createElement('div');
|
||||
@@ -110,7 +112,7 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
this.extentRectangle.style.backgroundImage = 'url(' +
|
||||
OpenLayers.Util.getImagesLocation() +
|
||||
'/blank.png)';
|
||||
this.extentRectangle.className = 'olControlOverviewMapExtentRectangle';
|
||||
this.extentRectangle.className = this.displayClass+'ExtentRectangle';
|
||||
this.mapDiv.appendChild(this.extentRectangle);
|
||||
|
||||
this.element.appendChild(this.mapDiv);
|
||||
@@ -148,18 +150,18 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
// Optionally add min/max buttons if the control will go in the
|
||||
// map viewport.
|
||||
if(!this.outsideViewport) {
|
||||
this.div.className = 'olControlOverviewMapContainer';
|
||||
this.div.className = this.displayClass + 'Container';
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
// maximize button div
|
||||
var img = imgLocation + 'layer-switcher-maximize.png';
|
||||
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
'olControlOverviewMapMaximizeButton',
|
||||
this.displayClass + 'MaximizeButton',
|
||||
null,
|
||||
new OpenLayers.Size(18,18),
|
||||
img,
|
||||
'absolute');
|
||||
this.maximizeDiv.style.display = 'none';
|
||||
this.maximizeDiv.className = 'olControlOverviewMapMaximizeButton';
|
||||
this.maximizeDiv.className = this.displayClass + 'MaximizeButton';
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
'click',
|
||||
this.maximizeControl.bindAsEventListener(this));
|
||||
@@ -179,7 +181,7 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
img,
|
||||
'absolute');
|
||||
this.minimizeDiv.style.display = 'none';
|
||||
this.minimizeDiv.className = 'olControlOverviewMapMinimizeButton';
|
||||
this.minimizeDiv.className = this.displayClass + 'MinimizeButton';
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
'click',
|
||||
this.minimizeControl.bindAsEventListener(this));
|
||||
|
||||
132
lib/OpenLayers/Control/Panel.js
Normal file
132
lib/OpenLayers/Control/Panel.js
Normal file
@@ -0,0 +1,132 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.Panel = OpenLayers.Class.create();
|
||||
OpenLayers.Control.Panel.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
/**
|
||||
* @type Array(OpenLayers.Control)
|
||||
*/
|
||||
controls: null,
|
||||
|
||||
/**
|
||||
* The control which is activated when the control is activated (turned
|
||||
* on), which also happens at instantiation.
|
||||
* @type OpenLayers.Control
|
||||
*/
|
||||
defaultControl: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {DOMElement} element
|
||||
* @param {String} base
|
||||
*/
|
||||
initialize: function(element) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
this.controls = [];
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
OpenLayers.Control.prototype.activate.apply(this, arguments);
|
||||
for(var i = 0; i < this.controls.length; i++) {
|
||||
if (this.controls[i] == this.defaultControl) {
|
||||
this.controls[i].activate();
|
||||
}
|
||||
}
|
||||
this.redraw();
|
||||
},
|
||||
deactivate: function() {
|
||||
OpenLayers.Control.prototype.deactivate.apply(this, arguments);
|
||||
for(var i = 0; i < this.controls.length; i++) {
|
||||
this.controls[i].deactivate();
|
||||
}
|
||||
this.redraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
for (var i = 0; i < this.controls.length; i++) {
|
||||
this.map.addControl(this.controls[i]);
|
||||
this.controls[i].deactivate();
|
||||
}
|
||||
this.activate();
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
redraw: function() {
|
||||
this.div.innerHTML = "";
|
||||
if (this.active) {
|
||||
for (var i = 0; i < this.controls.length; i++) {
|
||||
var element = document.createElement("div");
|
||||
var textNode = document.createTextNode(" ");
|
||||
if (this.controls[i].active) {
|
||||
element.className = this.controls[i].displayClass + "ItemActive";
|
||||
} else {
|
||||
element.className = this.controls[i].displayClass + "ItemInactive";
|
||||
}
|
||||
var onClick = function (ctrl, evt) {
|
||||
OpenLayers.Event.stop(evt ? evt : window.event);
|
||||
this.activateControl(ctrl);
|
||||
};
|
||||
var control = this.controls[i];
|
||||
element.onclick = onClick.bind(this, control);
|
||||
element.onmousedown = OpenLayers.Event.stop.bindAsEventListener();
|
||||
element.onmouseup = OpenLayers.Event.stop.bindAsEventListener();
|
||||
this.div.appendChild(element);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
activateControl: function (control) {
|
||||
if (!this.active) { return false; }
|
||||
if (control.type == OpenLayers.Control.TYPE_BUTTON) {
|
||||
control.trigger();
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < this.controls.length; i++) {
|
||||
if (this.controls[i] == control) {
|
||||
control.activate();
|
||||
} else {
|
||||
this.controls[i].deactivate();
|
||||
}
|
||||
}
|
||||
this.redraw();
|
||||
},
|
||||
|
||||
/**
|
||||
* To build a toolbar, you add a set of controls to it. addControls
|
||||
* lets you add a single control or a list of controls to the
|
||||
* Control Panel.
|
||||
* @param OpenLayers.Control
|
||||
*/
|
||||
addControls: function(controls) {
|
||||
if (!(controls instanceof Array)) {
|
||||
controls = [controls];
|
||||
}
|
||||
this.controls = this.controls.concat(controls);
|
||||
if (this.map) { // map.addControl() has already been called on the panel
|
||||
for (var i = 0; i < controls.length; i++) {
|
||||
map.addControl(controls[i]);
|
||||
controls[i].deactivate();
|
||||
}
|
||||
this.redraw();
|
||||
}
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.Panel"
|
||||
});
|
||||
|
||||
@@ -59,7 +59,7 @@ OpenLayers.Control.Permalink.prototype =
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
|
||||
if (!this.element) {
|
||||
this.div.className = 'olControlPermalink';
|
||||
this.div.className = this.displayClass;
|
||||
this.element = document.createElement("a");
|
||||
this.element.style.fontSize="smaller";
|
||||
this.element.innerHTML = "Permalink";
|
||||
|
||||
@@ -32,7 +32,7 @@ OpenLayers.Control.Scale.prototype =
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
if (!this.element) {
|
||||
this.element = document.createElement("div");
|
||||
this.div.className = "olControlScale";
|
||||
this.div.className = this.displayClass;
|
||||
this.element.style.fontSize="smaller";
|
||||
this.div.appendChild(this.element);
|
||||
}
|
||||
|
||||
106
lib/OpenLayers/Control/SelectFeature.js
Normal file
106
lib/OpenLayers/Control/SelectFeature.js
Normal file
@@ -0,0 +1,106 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* Draws features on a vector layer when active.
|
||||
*
|
||||
* @class
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Feature/Vector.js
|
||||
*/
|
||||
OpenLayers.Control.SelectFeature = OpenLayers.Class.create();
|
||||
OpenLayers.Control.SelectFeature.prototype =
|
||||
OpenLayers.Class.inherit(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* @type {OpenLayers.Layer.Vector}
|
||||
*/
|
||||
layer: null,
|
||||
|
||||
/**
|
||||
* @type {OpenLayers.Handler.Select}
|
||||
*/
|
||||
handler: null,
|
||||
|
||||
/**
|
||||
* @type {Object} The functions that are sent to the handler for callback
|
||||
*/
|
||||
callbacks: {},
|
||||
|
||||
/**
|
||||
* @type {Object} Hash of styles
|
||||
*/
|
||||
selectStyle: OpenLayers.Feature.Vector.style['select'],
|
||||
|
||||
/**
|
||||
* @type {Object} Hash of styles
|
||||
* @private
|
||||
*/
|
||||
originalStyle: null,
|
||||
|
||||
/**
|
||||
* @type {Boolean} Allow selection of multiple geometries
|
||||
*/
|
||||
multiple: false,
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Layer.Vector} layer
|
||||
* @param {OpenLayers.Handler} handler
|
||||
* @param {Object} options
|
||||
*/
|
||||
initialize: function(layer, options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.callbacks = OpenLayers.Util.extend({down: this.downFeature},
|
||||
this.callbacks);
|
||||
this.layer = layer;
|
||||
this.handler = new OpenLayers.Handler.Select(this, layer, this.callbacks);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
downFeature: function(geometry) {
|
||||
// Store feature style for restoration later
|
||||
if(geometry.feature.originalStyle == null) {
|
||||
geometry.feature.originalStyle = geometry.feature.style;
|
||||
}
|
||||
|
||||
if (this.multiple) {
|
||||
if(OpenLayers.Util.indexOf(this.layer.selectedFeatures, geometry.feature) > -1) {
|
||||
this.layer.renderer.drawGeometry(geometry, geometry.feature.originalStyle);
|
||||
OpenLayers.Util.removeItem(this.layer.selectedFeatures, geometry.feature);
|
||||
} else {
|
||||
this.layer.selectedFeatures.push(geometry.feature);
|
||||
this.layer.renderer.drawGeometry(geometry, this.selectStyle);
|
||||
}
|
||||
} else {
|
||||
if(OpenLayers.Util.indexOf(this.layer.selectedFeatures, geometry.feature) > -1) {
|
||||
this.layer.renderer.drawGeometry(geometry, geometry.feature.originalStyle);
|
||||
OpenLayers.Util.removeItem(this.layer.selectedFeatures, geometry.feature);
|
||||
} else {
|
||||
if (this.layer.selectedFeatures) {
|
||||
for (var i = 0; i < this.layer.selectedFeatures.length; i++) {
|
||||
this.layer.renderer.drawGeometry(this.layer.selectedFeatures[i].geometry, this.layer.selectedFeatures[i].originalStyle);
|
||||
}
|
||||
OpenLayers.Util.clearArray(this.layer.selectedFeatures);
|
||||
}
|
||||
this.layer.selectedFeatures.push(geometry.feature);
|
||||
this.layer.renderer.drawGeometry(geometry, this.selectStyle);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** Set the map property for the control.
|
||||
*
|
||||
* @param {OpenLayers.Map} map
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.handler.setMap(map);
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.SelectFeature"
|
||||
});
|
||||
42
lib/OpenLayers/Control/ZoomBox.js
Normal file
42
lib/OpenLayers/Control/ZoomBox.js
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Handler/Box.js
|
||||
*/
|
||||
OpenLayers.Control.ZoomBox = OpenLayers.Class.create();
|
||||
OpenLayers.Control.ZoomBox.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
/** @type OpenLayers.Control.TYPE_* */
|
||||
type: OpenLayers.Control.TYPE_TOOL,
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
draw: function() {
|
||||
this.handler = new OpenLayers.Handler.Box( this,
|
||||
{done: this.zoomBox}, {keyMask: this.keyMask} );
|
||||
},
|
||||
|
||||
zoomBox: function (position) {
|
||||
if (position instanceof OpenLayers.Bounds) {
|
||||
var minXY = this.map.getLonLatFromPixel(
|
||||
new OpenLayers.Pixel(position.left, position.bottom));
|
||||
var maxXY = this.map.getLonLatFromPixel(
|
||||
new OpenLayers.Pixel(position.right, position.top));
|
||||
var bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
|
||||
maxXY.lon, maxXY.lat);
|
||||
this.map.zoomToExtent(bounds);
|
||||
} else { // it's a pixel
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(position),
|
||||
this.map.getZoom() + 1);
|
||||
}
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.ZoomBox"
|
||||
});
|
||||
24
lib/OpenLayers/Control/ZoomToMaxExtent.js
Normal file
24
lib/OpenLayers/Control/ZoomToMaxExtent.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/* Copyright (c) 2006 MetaCarta, Inc., published under a modified BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
|
||||
* for the full text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* Imlements a very simple button control.
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class.create();
|
||||
OpenLayers.Control.ZoomToMaxExtent.prototype =
|
||||
OpenLayers.Class.inherit( OpenLayers.Control, {
|
||||
/** @type OpenLayers.Control.TYPE_* */
|
||||
type: OpenLayers.Control.TYPE_BUTTON,
|
||||
|
||||
trigger: function() {
|
||||
if (this.map) {
|
||||
this.map.zoomToMaxExtent();
|
||||
}
|
||||
},
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Control.ZoomToMaxExtent"
|
||||
});
|
||||
Reference in New Issue
Block a user