Update OpenLayers to 2.13.1
Signed-off-by: Michal Čihař <michal@cihar.com>
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 342 B |
|
Before Width: | Height: | Size: 451 B After Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 249 B After Width: | Height: | Size: 220 B |
|
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 758 B |
|
Before Width: | Height: | Size: 831 B After Width: | Height: | Size: 703 B |
|
Before Width: | Height: | Size: 967 B After Width: | Height: | Size: 753 B |
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 484 B After Width: | Height: | Size: 378 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 247 B |
|
Before Width: | Height: | Size: 481 B After Width: | Height: | Size: 373 B |
|
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 360 B |
|
Before Width: | Height: | Size: 359 B After Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 882 B |
|
Before Width: | Height: | Size: 463 B After Width: | Height: | Size: 350 B |
@ -1,12 +0,0 @@
|
||||
OpenLayers
|
||||
==========
|
||||
|
||||
This directory contains the source code for OpenLayers.
|
||||
|
||||
phpMyAdmin Developers: When updating the minified/concatened version of
|
||||
OpenLayers in js/openlayers under the main directory, make certain that the
|
||||
material under this directory is the complete, corresponding source for the
|
||||
minified/concatenated version.
|
||||
|
||||
Last retrieved from:
|
||||
https://github.com/openlayers/openlayers/tree/release-2.10/lib
|
||||
@ -208,7 +208,7 @@ if (!window.console || !console.firebug) { (function()
|
||||
consoleBody = doc.getElementById("log");
|
||||
layout();
|
||||
flush();
|
||||
}
|
||||
};
|
||||
|
||||
var baseURL = getFirebugURL();
|
||||
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
(function() {
|
||||
if (!window.console || !console.firebug) {
|
||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
||||
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
||||
|
||||
if (!window.console || !console.firebug) {
|
||||
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
||||
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
||||
|
||||
window.console = {};
|
||||
for (var i = 0; i < names.length; ++i)
|
||||
window.console[names[i]] = function() {}
|
||||
}
|
||||
window.console = {};
|
||||
for (var i = 0; i < names.length; ++i)
|
||||
window.console[names[i]] = function() {}
|
||||
}
|
||||
})();
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007, Google Inc.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Google Inc. nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* Sets up google.gears.*, which is *the only* supported way to access Gears.
|
||||
*
|
||||
* Circumvent this file at your own risk!
|
||||
*
|
||||
* In the future, Gears may automatically define google.gears.* without this
|
||||
* file. Gears may use these objects to transparently fix bugs and compatibility
|
||||
* issues. Applications that use the code below will continue to work seamlessly
|
||||
* when that happens.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
// We are already defined. Hooray!
|
||||
if (window.google && google.gears) {
|
||||
return;
|
||||
}
|
||||
|
||||
var factory = null;
|
||||
|
||||
// Firefox
|
||||
if (typeof GearsFactory != 'undefined') {
|
||||
factory = new GearsFactory();
|
||||
} else {
|
||||
// IE
|
||||
try {
|
||||
factory = new ActiveXObject('Gears.Factory');
|
||||
// privateSetGlobalObject is only required and supported on WinCE.
|
||||
if (factory.getBuildInfo().indexOf('ie_mobile') != -1) {
|
||||
factory.privateSetGlobalObject(this);
|
||||
}
|
||||
} catch (e) {
|
||||
// Safari
|
||||
if ((typeof navigator.mimeTypes != 'undefined')
|
||||
&& navigator.mimeTypes["application/x-googlegears"]) {
|
||||
factory = document.createElement("object");
|
||||
factory.style.display = "none";
|
||||
factory.width = 0;
|
||||
factory.height = 0;
|
||||
factory.type = "application/x-googlegears";
|
||||
document.documentElement.appendChild(factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// *Do not* define any objects if Gears is not installed. This mimics the
|
||||
// behavior of Gears defining the objects in the future.
|
||||
if (!factory) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now set up the objects, being careful not to overwrite anything.
|
||||
//
|
||||
// Note: In Internet Explorer for Windows Mobile, you can't add properties to
|
||||
// the window object. However, global objects are automatically added as
|
||||
// properties of the window object in all browsers.
|
||||
if (!window.google) {
|
||||
google = {};
|
||||
}
|
||||
|
||||
if (!google.gears) {
|
||||
google.gears = {factory: factory};
|
||||
}
|
||||
})();
|
||||
@ -1,69 +1,122 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/*
|
||||
* @requires OpenLayers/BaseTypes.js
|
||||
* @requires OpenLayers/Lang/en.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
* TODO: In 3.0, we will stop supporting build profiles that include
|
||||
* OpenLayers.js. This means we will not need the singleFile and scriptFile
|
||||
* variables, because we don't have to handle the singleFile case any more.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
* Before creating the OpenLayers namespace, check to see if
|
||||
* OpenLayers.singleFile is true. This occurs if the
|
||||
* OpenLayers/SingleFile.js script is included before this one - as is the
|
||||
* case with single file builds.
|
||||
* case with old single file build profiles that included both
|
||||
* OpenLayers.js and OpenLayers/SingleFile.js.
|
||||
*/
|
||||
var singleFile = (typeof OpenLayers == "object" && OpenLayers.singleFile);
|
||||
|
||||
/**
|
||||
* Cache for the script location returned from
|
||||
* OpenLayers._getScriptLocation
|
||||
* Relative path of this script.
|
||||
*/
|
||||
var scriptLocation;
|
||||
|
||||
var scriptName = (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js";
|
||||
|
||||
/*
|
||||
* If window.OpenLayers isn't set when this script (OpenLayers.js) is
|
||||
* evaluated (and if singleFile is false) then this script will load
|
||||
* *all* OpenLayers scripts. If window.OpenLayers is set to an array
|
||||
* then this script will attempt to load scripts for each string of
|
||||
* the array, using the string as the src of the script.
|
||||
*
|
||||
* Example:
|
||||
* (code)
|
||||
* <script type="text/javascript">
|
||||
* window.OpenLayers = [
|
||||
* "OpenLayers/Util.js",
|
||||
* "OpenLayers/BaseTypes.js"
|
||||
* ];
|
||||
* </script>
|
||||
* <script type="text/javascript" src="../lib/OpenLayers.js"></script>
|
||||
* (end)
|
||||
* In this example OpenLayers.js will load Util.js and BaseTypes.js only.
|
||||
*/
|
||||
var jsFiles = window.OpenLayers;
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers
|
||||
* The OpenLayers object provides a namespace for all things OpenLayers
|
||||
*/
|
||||
window.OpenLayers = {
|
||||
|
||||
/**
|
||||
* Property: _scriptName
|
||||
* {String} Relative path of this script.
|
||||
*/
|
||||
_scriptName: (!singleFile) ? "lib/OpenLayers.js" : "OpenLayers.js",
|
||||
|
||||
/**
|
||||
* Function: _getScriptLocation
|
||||
* Return the path to this script.
|
||||
* Method: _getScriptLocation
|
||||
* Return the path to this script. This is also implemented in
|
||||
* OpenLayers/SingleFile.js
|
||||
*
|
||||
* Returns:
|
||||
* {String} Path to this script
|
||||
*/
|
||||
_getScriptLocation: function () {
|
||||
if (scriptLocation != undefined) {
|
||||
return scriptLocation;
|
||||
}
|
||||
scriptLocation = "";
|
||||
var isOL = new RegExp("(^|(.*?\\/))(" + OpenLayers._scriptName + ")(\\?|$)");
|
||||
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
for (var i=0, len=scripts.length; i<len; i++) {
|
||||
var src = scripts[i].getAttribute('src');
|
||||
if (src) {
|
||||
var match = src.match(isOL);
|
||||
if(match) {
|
||||
scriptLocation = match[1];
|
||||
_getScriptLocation: (function() {
|
||||
var r = new RegExp("(^|(.*?\\/))(" + scriptName + ")(\\?|$)"),
|
||||
s = document.getElementsByTagName('script'),
|
||||
src, m, l = "";
|
||||
for(var i=0, len=s.length; i<len; i++) {
|
||||
src = s[i].getAttribute('src');
|
||||
if(src) {
|
||||
m = src.match(r);
|
||||
if(m) {
|
||||
l = m[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scriptLocation;
|
||||
}
|
||||
return (function() { return l; });
|
||||
})(),
|
||||
|
||||
/**
|
||||
* APIProperty: ImgPath
|
||||
* {String} Set this to the path where control images are stored, a path
|
||||
* given here must end with a slash. If set to '' (which is the default)
|
||||
* OpenLayers will use its script location + "img/".
|
||||
*
|
||||
* You will need to set this property when you have a singlefile build of
|
||||
* OpenLayers that either is not named "OpenLayers.js" or if you move
|
||||
* the file in a way such that the image directory cannot be derived from
|
||||
* the script location.
|
||||
*
|
||||
* If your custom OpenLayers build is named "my-custom-ol.js" and the images
|
||||
* of OpenLayers are in a folder "/resources/external/images/ol" a correct
|
||||
* way of including OpenLayers in your HTML would be:
|
||||
*
|
||||
* (code)
|
||||
* <script src="/path/to/my-custom-ol.js" type="text/javascript"></script>
|
||||
* <script type="text/javascript">
|
||||
* // tell OpenLayers where the control images are
|
||||
* // remember the trailing slash
|
||||
* OpenLayers.ImgPath = "/resources/external/images/ol/";
|
||||
* </script>
|
||||
* (end code)
|
||||
*
|
||||
* Please remember that when your OpenLayers script is not named
|
||||
* "OpenLayers.js" you will have to make sure that the default theme is
|
||||
* loaded into the page by including an appropriate <link>-tag,
|
||||
* e.g.:
|
||||
*
|
||||
* (code)
|
||||
* <link rel="stylesheet" href="/path/to/default/style.css" type="text/css">
|
||||
* (end code)
|
||||
*/
|
||||
ImgPath : ''
|
||||
};
|
||||
|
||||
/**
|
||||
* OpenLayers.singleFile is a flag indicating this file is being included
|
||||
* in a Single File Library build of the OpenLayers Library.
|
||||
@ -73,276 +126,304 @@
|
||||
*
|
||||
* When we *are* part of a SFL build we do not dynamically include the
|
||||
* OpenLayers library code as it will be appended at the end of this file.
|
||||
*/
|
||||
*/
|
||||
if(!singleFile) {
|
||||
var jsfiles = new Array(
|
||||
"OpenLayers/Util.js",
|
||||
"OpenLayers/BaseTypes.js",
|
||||
"OpenLayers/BaseTypes/Class.js",
|
||||
"OpenLayers/BaseTypes/Bounds.js",
|
||||
"OpenLayers/BaseTypes/Element.js",
|
||||
"OpenLayers/BaseTypes/LonLat.js",
|
||||
"OpenLayers/BaseTypes/Pixel.js",
|
||||
"OpenLayers/BaseTypes/Size.js",
|
||||
"OpenLayers/Console.js",
|
||||
"OpenLayers/Tween.js",
|
||||
"Rico/Corner.js",
|
||||
"Rico/Color.js",
|
||||
"OpenLayers/Ajax.js",
|
||||
"OpenLayers/Events.js",
|
||||
"OpenLayers/Request.js",
|
||||
"OpenLayers/Request/XMLHttpRequest.js",
|
||||
"OpenLayers/Projection.js",
|
||||
"OpenLayers/Map.js",
|
||||
"OpenLayers/Layer.js",
|
||||
"OpenLayers/Icon.js",
|
||||
"OpenLayers/Marker.js",
|
||||
"OpenLayers/Marker/Box.js",
|
||||
"OpenLayers/Popup.js",
|
||||
"OpenLayers/Tile.js",
|
||||
"OpenLayers/Tile/Image.js",
|
||||
"OpenLayers/Tile/Image/IFrame.js",
|
||||
"OpenLayers/Tile/WFS.js",
|
||||
"OpenLayers/Layer/Image.js",
|
||||
"OpenLayers/Layer/SphericalMercator.js",
|
||||
"OpenLayers/Layer/EventPane.js",
|
||||
"OpenLayers/Layer/FixedZoomLevels.js",
|
||||
"OpenLayers/Layer/Google.js",
|
||||
"OpenLayers/Layer/Google/v3.js",
|
||||
"OpenLayers/Layer/VirtualEarth.js",
|
||||
"OpenLayers/Layer/Yahoo.js",
|
||||
"OpenLayers/Layer/HTTPRequest.js",
|
||||
"OpenLayers/Layer/Grid.js",
|
||||
"OpenLayers/Layer/MapGuide.js",
|
||||
"OpenLayers/Layer/MapServer.js",
|
||||
"OpenLayers/Layer/MapServer/Untiled.js",
|
||||
"OpenLayers/Layer/KaMap.js",
|
||||
"OpenLayers/Layer/KaMapCache.js",
|
||||
"OpenLayers/Layer/MultiMap.js",
|
||||
"OpenLayers/Layer/Markers.js",
|
||||
"OpenLayers/Layer/Text.js",
|
||||
"OpenLayers/Layer/WorldWind.js",
|
||||
"OpenLayers/Layer/ArcGIS93Rest.js",
|
||||
"OpenLayers/Layer/WMS.js",
|
||||
"OpenLayers/Layer/WMS/Untiled.js",
|
||||
"OpenLayers/Layer/WMS/Post.js",
|
||||
"OpenLayers/Layer/WMTS.js",
|
||||
"OpenLayers/Layer/ArcIMS.js",
|
||||
"OpenLayers/Layer/GeoRSS.js",
|
||||
"OpenLayers/Layer/Boxes.js",
|
||||
"OpenLayers/Layer/XYZ.js",
|
||||
"OpenLayers/Layer/TMS.js",
|
||||
"OpenLayers/Layer/TileCache.js",
|
||||
"OpenLayers/Layer/Zoomify.js",
|
||||
"OpenLayers/Popup/Anchored.js",
|
||||
"OpenLayers/Popup/AnchoredBubble.js",
|
||||
"OpenLayers/Popup/Framed.js",
|
||||
"OpenLayers/Popup/FramedCloud.js",
|
||||
"OpenLayers/Feature.js",
|
||||
"OpenLayers/Feature/Vector.js",
|
||||
"OpenLayers/Feature/WFS.js",
|
||||
"OpenLayers/Handler.js",
|
||||
"OpenLayers/Handler/Click.js",
|
||||
"OpenLayers/Handler/Hover.js",
|
||||
"OpenLayers/Handler/Point.js",
|
||||
"OpenLayers/Handler/Path.js",
|
||||
"OpenLayers/Handler/Polygon.js",
|
||||
"OpenLayers/Handler/Feature.js",
|
||||
"OpenLayers/Handler/Drag.js",
|
||||
"OpenLayers/Handler/RegularPolygon.js",
|
||||
"OpenLayers/Handler/Box.js",
|
||||
"OpenLayers/Handler/MouseWheel.js",
|
||||
"OpenLayers/Handler/Keyboard.js",
|
||||
"OpenLayers/Control.js",
|
||||
"OpenLayers/Control/Attribution.js",
|
||||
"OpenLayers/Control/Button.js",
|
||||
"OpenLayers/Control/ZoomBox.js",
|
||||
"OpenLayers/Control/ZoomToMaxExtent.js",
|
||||
"OpenLayers/Control/DragPan.js",
|
||||
"OpenLayers/Control/Navigation.js",
|
||||
"OpenLayers/Control/MouseDefaults.js",
|
||||
"OpenLayers/Control/MousePosition.js",
|
||||
"OpenLayers/Control/OverviewMap.js",
|
||||
"OpenLayers/Control/KeyboardDefaults.js",
|
||||
"OpenLayers/Control/PanZoom.js",
|
||||
"OpenLayers/Control/PanZoomBar.js",
|
||||
"OpenLayers/Control/ArgParser.js",
|
||||
"OpenLayers/Control/Permalink.js",
|
||||
"OpenLayers/Control/Scale.js",
|
||||
"OpenLayers/Control/ScaleLine.js",
|
||||
"OpenLayers/Control/Snapping.js",
|
||||
"OpenLayers/Control/Split.js",
|
||||
"OpenLayers/Control/LayerSwitcher.js",
|
||||
"OpenLayers/Control/DrawFeature.js",
|
||||
"OpenLayers/Control/DragFeature.js",
|
||||
"OpenLayers/Control/ModifyFeature.js",
|
||||
"OpenLayers/Control/Panel.js",
|
||||
"OpenLayers/Control/SelectFeature.js",
|
||||
"OpenLayers/Control/NavigationHistory.js",
|
||||
"OpenLayers/Control/Measure.js",
|
||||
"OpenLayers/Control/WMSGetFeatureInfo.js",
|
||||
"OpenLayers/Control/WMTSGetFeatureInfo.js",
|
||||
"OpenLayers/Control/Graticule.js",
|
||||
"OpenLayers/Control/TransformFeature.js",
|
||||
"OpenLayers/Control/SLDSelect.js",
|
||||
"OpenLayers/Geometry.js",
|
||||
"OpenLayers/Geometry/Rectangle.js",
|
||||
"OpenLayers/Geometry/Collection.js",
|
||||
"OpenLayers/Geometry/Point.js",
|
||||
"OpenLayers/Geometry/MultiPoint.js",
|
||||
"OpenLayers/Geometry/Curve.js",
|
||||
"OpenLayers/Geometry/LineString.js",
|
||||
"OpenLayers/Geometry/LinearRing.js",
|
||||
"OpenLayers/Geometry/Polygon.js",
|
||||
"OpenLayers/Geometry/MultiLineString.js",
|
||||
"OpenLayers/Geometry/MultiPolygon.js",
|
||||
"OpenLayers/Geometry/Surface.js",
|
||||
"OpenLayers/Renderer.js",
|
||||
"OpenLayers/Renderer/Elements.js",
|
||||
"OpenLayers/Renderer/SVG.js",
|
||||
"OpenLayers/Renderer/Canvas.js",
|
||||
"OpenLayers/Renderer/VML.js",
|
||||
"OpenLayers/Layer/Vector.js",
|
||||
"OpenLayers/Layer/Vector/RootContainer.js",
|
||||
"OpenLayers/Strategy.js",
|
||||
"OpenLayers/Strategy/Filter.js",
|
||||
"OpenLayers/Strategy/Fixed.js",
|
||||
"OpenLayers/Strategy/Cluster.js",
|
||||
"OpenLayers/Strategy/Paging.js",
|
||||
"OpenLayers/Strategy/BBOX.js",
|
||||
"OpenLayers/Strategy/Save.js",
|
||||
"OpenLayers/Strategy/Refresh.js",
|
||||
"OpenLayers/Filter.js",
|
||||
"OpenLayers/Filter/FeatureId.js",
|
||||
"OpenLayers/Filter/Logical.js",
|
||||
"OpenLayers/Filter/Comparison.js",
|
||||
"OpenLayers/Filter/Spatial.js",
|
||||
"OpenLayers/Protocol.js",
|
||||
"OpenLayers/Protocol/HTTP.js",
|
||||
"OpenLayers/Protocol/SQL.js",
|
||||
"OpenLayers/Protocol/SQL/Gears.js",
|
||||
"OpenLayers/Protocol/WFS.js",
|
||||
"OpenLayers/Protocol/WFS/v1.js",
|
||||
"OpenLayers/Protocol/WFS/v1_0_0.js",
|
||||
"OpenLayers/Protocol/WFS/v1_1_0.js",
|
||||
"OpenLayers/Protocol/SOS.js",
|
||||
"OpenLayers/Protocol/SOS/v1_0_0.js",
|
||||
"OpenLayers/Layer/PointTrack.js",
|
||||
"OpenLayers/Layer/GML.js",
|
||||
"OpenLayers/Style.js",
|
||||
"OpenLayers/Style2.js",
|
||||
"OpenLayers/StyleMap.js",
|
||||
"OpenLayers/Rule.js",
|
||||
"OpenLayers/Format.js",
|
||||
"OpenLayers/Format/XML.js",
|
||||
"OpenLayers/Format/Context.js",
|
||||
"OpenLayers/Format/ArcXML.js",
|
||||
"OpenLayers/Format/ArcXML/Features.js",
|
||||
"OpenLayers/Format/GML.js",
|
||||
"OpenLayers/Format/GML/Base.js",
|
||||
"OpenLayers/Format/GML/v2.js",
|
||||
"OpenLayers/Format/GML/v3.js",
|
||||
"OpenLayers/Format/Atom.js",
|
||||
"OpenLayers/Format/KML.js",
|
||||
"OpenLayers/Format/GeoRSS.js",
|
||||
"OpenLayers/Format/WFS.js",
|
||||
"OpenLayers/Format/WFSCapabilities.js",
|
||||
"OpenLayers/Format/WFSCapabilities/v1.js",
|
||||
"OpenLayers/Format/WFSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/WFSCapabilities/v1_1_0.js",
|
||||
"OpenLayers/Format/WFSDescribeFeatureType.js",
|
||||
"OpenLayers/Format/WMSDescribeLayer.js",
|
||||
"OpenLayers/Format/WMSDescribeLayer/v1_1.js",
|
||||
"OpenLayers/Format/WKT.js",
|
||||
"OpenLayers/Format/OSM.js",
|
||||
"OpenLayers/Format/GPX.js",
|
||||
"OpenLayers/Format/Filter.js",
|
||||
"OpenLayers/Format/Filter/v1.js",
|
||||
"OpenLayers/Format/Filter/v1_0_0.js",
|
||||
"OpenLayers/Format/Filter/v1_1_0.js",
|
||||
"OpenLayers/Format/SLD.js",
|
||||
"OpenLayers/Format/SLD/v1.js",
|
||||
"OpenLayers/Format/SLD/v1_0_0.js",
|
||||
"OpenLayers/Format/OWSCommon/v1.js",
|
||||
"OpenLayers/Format/OWSCommon/v1_0_0.js",
|
||||
"OpenLayers/Format/OWSCommon/v1_1_0.js",
|
||||
"OpenLayers/Format/CSWGetDomain.js",
|
||||
"OpenLayers/Format/CSWGetDomain/v2_0_2.js",
|
||||
"OpenLayers/Format/CSWGetRecords.js",
|
||||
"OpenLayers/Format/CSWGetRecords/v2_0_2.js",
|
||||
"OpenLayers/Format/WFST.js",
|
||||
"OpenLayers/Format/WFST/v1.js",
|
||||
"OpenLayers/Format/WFST/v1_0_0.js",
|
||||
"OpenLayers/Format/WFST/v1_1_0.js",
|
||||
"OpenLayers/Format/Text.js",
|
||||
"OpenLayers/Format/JSON.js",
|
||||
"OpenLayers/Format/GeoJSON.js",
|
||||
"OpenLayers/Format/WMC.js",
|
||||
"OpenLayers/Format/WMC/v1.js",
|
||||
"OpenLayers/Format/WMC/v1_0_0.js",
|
||||
"OpenLayers/Format/WMC/v1_1_0.js",
|
||||
"OpenLayers/Format/WMSCapabilities.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1_0.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1_1.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_3.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_3_0.js",
|
||||
"OpenLayers/Format/WMSGetFeatureInfo.js",
|
||||
"OpenLayers/Format/SOSCapabilities.js",
|
||||
"OpenLayers/Format/SOSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/SOSGetObservation.js",
|
||||
"OpenLayers/Format/SOSGetFeatureOfInterest.js",
|
||||
"OpenLayers/Format/OWSContext.js",
|
||||
"OpenLayers/Format/OWSContext/v0_3_1.js",
|
||||
"OpenLayers/Format/WMTSCapabilities.js",
|
||||
"OpenLayers/Format/WMTSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Layer/WFS.js",
|
||||
"OpenLayers/Control/GetFeature.js",
|
||||
"OpenLayers/Control/MouseToolbar.js",
|
||||
"OpenLayers/Control/NavToolbar.js",
|
||||
"OpenLayers/Control/PanPanel.js",
|
||||
"OpenLayers/Control/Pan.js",
|
||||
"OpenLayers/Control/ZoomIn.js",
|
||||
"OpenLayers/Control/ZoomOut.js",
|
||||
"OpenLayers/Control/ZoomPanel.js",
|
||||
"OpenLayers/Control/EditingToolbar.js",
|
||||
"OpenLayers/Symbolizer.js",
|
||||
"OpenLayers/Symbolizer/Point.js",
|
||||
"OpenLayers/Symbolizer/Line.js",
|
||||
"OpenLayers/Symbolizer/Polygon.js",
|
||||
"OpenLayers/Symbolizer/Text.js",
|
||||
"OpenLayers/Symbolizer/Raster.js",
|
||||
"OpenLayers/Lang.js",
|
||||
"OpenLayers/Lang/en.js"
|
||||
); // etc.
|
||||
if (!jsFiles) {
|
||||
jsFiles = [
|
||||
"OpenLayers/BaseTypes/Class.js",
|
||||
"OpenLayers/Util.js",
|
||||
"OpenLayers/Util/vendorPrefix.js",
|
||||
"OpenLayers/Animation.js",
|
||||
"OpenLayers/BaseTypes.js",
|
||||
"OpenLayers/BaseTypes/Bounds.js",
|
||||
"OpenLayers/BaseTypes/Date.js",
|
||||
"OpenLayers/BaseTypes/Element.js",
|
||||
"OpenLayers/BaseTypes/LonLat.js",
|
||||
"OpenLayers/BaseTypes/Pixel.js",
|
||||
"OpenLayers/BaseTypes/Size.js",
|
||||
"OpenLayers/Console.js",
|
||||
"OpenLayers/Tween.js",
|
||||
"OpenLayers/Kinetic.js",
|
||||
"OpenLayers/Events.js",
|
||||
"OpenLayers/Events/buttonclick.js",
|
||||
"OpenLayers/Events/featureclick.js",
|
||||
"OpenLayers/Request.js",
|
||||
"OpenLayers/Request/XMLHttpRequest.js",
|
||||
"OpenLayers/Projection.js",
|
||||
"OpenLayers/Map.js",
|
||||
"OpenLayers/Layer.js",
|
||||
"OpenLayers/Icon.js",
|
||||
"OpenLayers/Marker.js",
|
||||
"OpenLayers/Marker/Box.js",
|
||||
"OpenLayers/Popup.js",
|
||||
"OpenLayers/Tile.js",
|
||||
"OpenLayers/Tile/Image.js",
|
||||
"OpenLayers/Tile/Image/IFrame.js",
|
||||
"OpenLayers/Tile/UTFGrid.js",
|
||||
"OpenLayers/Layer/Image.js",
|
||||
"OpenLayers/Layer/SphericalMercator.js",
|
||||
"OpenLayers/Layer/EventPane.js",
|
||||
"OpenLayers/Layer/FixedZoomLevels.js",
|
||||
"OpenLayers/Layer/Google.js",
|
||||
"OpenLayers/Layer/Google/v3.js",
|
||||
"OpenLayers/Layer/HTTPRequest.js",
|
||||
"OpenLayers/Layer/Grid.js",
|
||||
"OpenLayers/Layer/MapGuide.js",
|
||||
"OpenLayers/Layer/MapServer.js",
|
||||
"OpenLayers/Layer/KaMap.js",
|
||||
"OpenLayers/Layer/KaMapCache.js",
|
||||
"OpenLayers/Layer/Markers.js",
|
||||
"OpenLayers/Layer/Text.js",
|
||||
"OpenLayers/Layer/WorldWind.js",
|
||||
"OpenLayers/Layer/ArcGIS93Rest.js",
|
||||
"OpenLayers/Layer/WMS.js",
|
||||
"OpenLayers/Layer/WMTS.js",
|
||||
"OpenLayers/Layer/ArcIMS.js",
|
||||
"OpenLayers/Layer/GeoRSS.js",
|
||||
"OpenLayers/Layer/Boxes.js",
|
||||
"OpenLayers/Layer/XYZ.js",
|
||||
"OpenLayers/Layer/UTFGrid.js",
|
||||
"OpenLayers/Layer/OSM.js",
|
||||
"OpenLayers/Layer/Bing.js",
|
||||
"OpenLayers/Layer/TMS.js",
|
||||
"OpenLayers/Layer/TileCache.js",
|
||||
"OpenLayers/Layer/Zoomify.js",
|
||||
"OpenLayers/Layer/ArcGISCache.js",
|
||||
"OpenLayers/Popup/Anchored.js",
|
||||
"OpenLayers/Popup/Framed.js",
|
||||
"OpenLayers/Popup/FramedCloud.js",
|
||||
"OpenLayers/Feature.js",
|
||||
"OpenLayers/Feature/Vector.js",
|
||||
"OpenLayers/Handler.js",
|
||||
"OpenLayers/Handler/Click.js",
|
||||
"OpenLayers/Handler/Hover.js",
|
||||
"OpenLayers/Handler/Point.js",
|
||||
"OpenLayers/Handler/Path.js",
|
||||
"OpenLayers/Handler/Polygon.js",
|
||||
"OpenLayers/Handler/Feature.js",
|
||||
"OpenLayers/Handler/Drag.js",
|
||||
"OpenLayers/Handler/Pinch.js",
|
||||
"OpenLayers/Handler/RegularPolygon.js",
|
||||
"OpenLayers/Handler/Box.js",
|
||||
"OpenLayers/Handler/MouseWheel.js",
|
||||
"OpenLayers/Handler/Keyboard.js",
|
||||
"OpenLayers/Control.js",
|
||||
"OpenLayers/Control/Attribution.js",
|
||||
"OpenLayers/Control/Button.js",
|
||||
"OpenLayers/Control/CacheRead.js",
|
||||
"OpenLayers/Control/CacheWrite.js",
|
||||
"OpenLayers/Control/ZoomBox.js",
|
||||
"OpenLayers/Control/ZoomToMaxExtent.js",
|
||||
"OpenLayers/Control/DragPan.js",
|
||||
"OpenLayers/Control/Navigation.js",
|
||||
"OpenLayers/Control/PinchZoom.js",
|
||||
"OpenLayers/Control/TouchNavigation.js",
|
||||
"OpenLayers/Control/MousePosition.js",
|
||||
"OpenLayers/Control/OverviewMap.js",
|
||||
"OpenLayers/Control/KeyboardDefaults.js",
|
||||
"OpenLayers/Control/PanZoom.js",
|
||||
"OpenLayers/Control/PanZoomBar.js",
|
||||
"OpenLayers/Control/ArgParser.js",
|
||||
"OpenLayers/Control/Permalink.js",
|
||||
"OpenLayers/Control/Scale.js",
|
||||
"OpenLayers/Control/ScaleLine.js",
|
||||
"OpenLayers/Control/Snapping.js",
|
||||
"OpenLayers/Control/Split.js",
|
||||
"OpenLayers/Control/LayerSwitcher.js",
|
||||
"OpenLayers/Control/DrawFeature.js",
|
||||
"OpenLayers/Control/DragFeature.js",
|
||||
"OpenLayers/Control/ModifyFeature.js",
|
||||
"OpenLayers/Control/Panel.js",
|
||||
"OpenLayers/Control/SelectFeature.js",
|
||||
"OpenLayers/Control/NavigationHistory.js",
|
||||
"OpenLayers/Control/Measure.js",
|
||||
"OpenLayers/Control/WMSGetFeatureInfo.js",
|
||||
"OpenLayers/Control/WMTSGetFeatureInfo.js",
|
||||
"OpenLayers/Control/Graticule.js",
|
||||
"OpenLayers/Control/TransformFeature.js",
|
||||
"OpenLayers/Control/UTFGrid.js",
|
||||
"OpenLayers/Control/SLDSelect.js",
|
||||
"OpenLayers/Control/Zoom.js",
|
||||
"OpenLayers/Geometry.js",
|
||||
"OpenLayers/Geometry/Collection.js",
|
||||
"OpenLayers/Geometry/Point.js",
|
||||
"OpenLayers/Geometry/MultiPoint.js",
|
||||
"OpenLayers/Geometry/Curve.js",
|
||||
"OpenLayers/Geometry/LineString.js",
|
||||
"OpenLayers/Geometry/LinearRing.js",
|
||||
"OpenLayers/Geometry/Polygon.js",
|
||||
"OpenLayers/Geometry/MultiLineString.js",
|
||||
"OpenLayers/Geometry/MultiPolygon.js",
|
||||
"OpenLayers/Renderer.js",
|
||||
"OpenLayers/Renderer/Elements.js",
|
||||
"OpenLayers/Renderer/SVG.js",
|
||||
"OpenLayers/Renderer/Canvas.js",
|
||||
"OpenLayers/Renderer/VML.js",
|
||||
"OpenLayers/Layer/Vector.js",
|
||||
"OpenLayers/Layer/PointGrid.js",
|
||||
"OpenLayers/Layer/Vector/RootContainer.js",
|
||||
"OpenLayers/Strategy.js",
|
||||
"OpenLayers/Strategy/Filter.js",
|
||||
"OpenLayers/Strategy/Fixed.js",
|
||||
"OpenLayers/Strategy/Cluster.js",
|
||||
"OpenLayers/Strategy/Paging.js",
|
||||
"OpenLayers/Strategy/BBOX.js",
|
||||
"OpenLayers/Strategy/Save.js",
|
||||
"OpenLayers/Strategy/Refresh.js",
|
||||
"OpenLayers/Filter.js",
|
||||
"OpenLayers/Filter/FeatureId.js",
|
||||
"OpenLayers/Filter/Logical.js",
|
||||
"OpenLayers/Filter/Comparison.js",
|
||||
"OpenLayers/Filter/Spatial.js",
|
||||
"OpenLayers/Filter/Function.js",
|
||||
"OpenLayers/Protocol.js",
|
||||
"OpenLayers/Protocol/HTTP.js",
|
||||
"OpenLayers/Protocol/WFS.js",
|
||||
"OpenLayers/Protocol/WFS/v1.js",
|
||||
"OpenLayers/Protocol/WFS/v1_0_0.js",
|
||||
"OpenLayers/Protocol/WFS/v1_1_0.js",
|
||||
"OpenLayers/Protocol/CSW.js",
|
||||
"OpenLayers/Protocol/CSW/v2_0_2.js",
|
||||
"OpenLayers/Protocol/Script.js",
|
||||
"OpenLayers/Protocol/SOS.js",
|
||||
"OpenLayers/Protocol/SOS/v1_0_0.js",
|
||||
"OpenLayers/Layer/PointTrack.js",
|
||||
"OpenLayers/Style.js",
|
||||
"OpenLayers/Style2.js",
|
||||
"OpenLayers/StyleMap.js",
|
||||
"OpenLayers/Rule.js",
|
||||
"OpenLayers/Format.js",
|
||||
"OpenLayers/Format/QueryStringFilter.js",
|
||||
"OpenLayers/Format/XML.js",
|
||||
"OpenLayers/Format/XML/VersionedOGC.js",
|
||||
"OpenLayers/Format/Context.js",
|
||||
"OpenLayers/Format/ArcXML.js",
|
||||
"OpenLayers/Format/ArcXML/Features.js",
|
||||
"OpenLayers/Format/GML.js",
|
||||
"OpenLayers/Format/GML/Base.js",
|
||||
"OpenLayers/Format/GML/v2.js",
|
||||
"OpenLayers/Format/GML/v3.js",
|
||||
"OpenLayers/Format/Atom.js",
|
||||
"OpenLayers/Format/EncodedPolyline.js",
|
||||
"OpenLayers/Format/KML.js",
|
||||
"OpenLayers/Format/GeoRSS.js",
|
||||
"OpenLayers/Format/WFS.js",
|
||||
"OpenLayers/Format/OWSCommon.js",
|
||||
"OpenLayers/Format/OWSCommon/v1.js",
|
||||
"OpenLayers/Format/OWSCommon/v1_0_0.js",
|
||||
"OpenLayers/Format/OWSCommon/v1_1_0.js",
|
||||
"OpenLayers/Format/WCSCapabilities.js",
|
||||
"OpenLayers/Format/WCSCapabilities/v1.js",
|
||||
"OpenLayers/Format/WCSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/WCSCapabilities/v1_1_0.js",
|
||||
"OpenLayers/Format/WFSCapabilities.js",
|
||||
"OpenLayers/Format/WFSCapabilities/v1.js",
|
||||
"OpenLayers/Format/WFSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/WFSCapabilities/v1_1_0.js",
|
||||
"OpenLayers/Format/WFSDescribeFeatureType.js",
|
||||
"OpenLayers/Format/WMSDescribeLayer.js",
|
||||
"OpenLayers/Format/WMSDescribeLayer/v1_1.js",
|
||||
"OpenLayers/Format/WKT.js",
|
||||
"OpenLayers/Format/CQL.js",
|
||||
"OpenLayers/Format/OSM.js",
|
||||
"OpenLayers/Format/GPX.js",
|
||||
"OpenLayers/Format/Filter.js",
|
||||
"OpenLayers/Format/Filter/v1.js",
|
||||
"OpenLayers/Format/Filter/v1_0_0.js",
|
||||
"OpenLayers/Format/Filter/v1_1_0.js",
|
||||
"OpenLayers/Format/SLD.js",
|
||||
"OpenLayers/Format/SLD/v1.js",
|
||||
"OpenLayers/Format/SLD/v1_0_0.js",
|
||||
"OpenLayers/Format/SLD/v1_0_0_GeoServer.js",
|
||||
"OpenLayers/Format/OWSCommon.js",
|
||||
"OpenLayers/Format/OWSCommon/v1.js",
|
||||
"OpenLayers/Format/OWSCommon/v1_0_0.js",
|
||||
"OpenLayers/Format/OWSCommon/v1_1_0.js",
|
||||
"OpenLayers/Format/CSWGetDomain.js",
|
||||
"OpenLayers/Format/CSWGetDomain/v2_0_2.js",
|
||||
"OpenLayers/Format/CSWGetRecords.js",
|
||||
"OpenLayers/Format/CSWGetRecords/v2_0_2.js",
|
||||
"OpenLayers/Format/WFST.js",
|
||||
"OpenLayers/Format/WFST/v1.js",
|
||||
"OpenLayers/Format/WFST/v1_0_0.js",
|
||||
"OpenLayers/Format/WFST/v1_1_0.js",
|
||||
"OpenLayers/Format/Text.js",
|
||||
"OpenLayers/Format/JSON.js",
|
||||
"OpenLayers/Format/GeoJSON.js",
|
||||
"OpenLayers/Format/WMC.js",
|
||||
"OpenLayers/Format/WMC/v1.js",
|
||||
"OpenLayers/Format/WMC/v1_0_0.js",
|
||||
"OpenLayers/Format/WMC/v1_1_0.js",
|
||||
"OpenLayers/Format/WCSGetCoverage.js",
|
||||
"OpenLayers/Format/WMSCapabilities.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1_0.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1_1.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_3.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_3_0.js",
|
||||
"OpenLayers/Format/WMSCapabilities/v1_1_1_WMSC.js",
|
||||
"OpenLayers/Format/WMSGetFeatureInfo.js",
|
||||
"OpenLayers/Format/SOSCapabilities.js",
|
||||
"OpenLayers/Format/SOSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/SOSGetFeatureOfInterest.js",
|
||||
"OpenLayers/Format/SOSGetObservation.js",
|
||||
"OpenLayers/Format/OWSContext.js",
|
||||
"OpenLayers/Format/OWSContext/v0_3_1.js",
|
||||
"OpenLayers/Format/WMTSCapabilities.js",
|
||||
"OpenLayers/Format/WMTSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/WPSCapabilities.js",
|
||||
"OpenLayers/Format/WPSCapabilities/v1_0_0.js",
|
||||
"OpenLayers/Format/WPSDescribeProcess.js",
|
||||
"OpenLayers/Format/WPSExecute.js",
|
||||
"OpenLayers/Format/XLS.js",
|
||||
"OpenLayers/Format/XLS/v1.js",
|
||||
"OpenLayers/Format/XLS/v1_1_0.js",
|
||||
"OpenLayers/Format/OGCExceptionReport.js",
|
||||
"OpenLayers/Control/GetFeature.js",
|
||||
"OpenLayers/Control/NavToolbar.js",
|
||||
"OpenLayers/Control/PanPanel.js",
|
||||
"OpenLayers/Control/Pan.js",
|
||||
"OpenLayers/Control/ZoomIn.js",
|
||||
"OpenLayers/Control/ZoomOut.js",
|
||||
"OpenLayers/Control/ZoomPanel.js",
|
||||
"OpenLayers/Control/EditingToolbar.js",
|
||||
"OpenLayers/Control/Geolocate.js",
|
||||
"OpenLayers/Symbolizer.js",
|
||||
"OpenLayers/Symbolizer/Point.js",
|
||||
"OpenLayers/Symbolizer/Line.js",
|
||||
"OpenLayers/Symbolizer/Polygon.js",
|
||||
"OpenLayers/Symbolizer/Text.js",
|
||||
"OpenLayers/Symbolizer/Raster.js",
|
||||
"OpenLayers/Lang.js",
|
||||
"OpenLayers/Lang/en.js",
|
||||
"OpenLayers/Spherical.js",
|
||||
"OpenLayers/TileManager.js",
|
||||
"OpenLayers/WPSClient.js",
|
||||
"OpenLayers/WPSProcess.js"
|
||||
]; // etc.
|
||||
}
|
||||
|
||||
var agent = navigator.userAgent;
|
||||
var docWrite = (agent.match("MSIE") || agent.match("Safari"));
|
||||
if(docWrite) {
|
||||
var allScriptTags = new Array(jsfiles.length);
|
||||
}
|
||||
var host = OpenLayers._getScriptLocation() + "lib/";
|
||||
for (var i=0, len=jsfiles.length; i<len; i++) {
|
||||
if (docWrite) {
|
||||
allScriptTags[i] = "<script src='" + host + jsfiles[i] +
|
||||
// use "parser-inserted scripts" for guaranteed execution order
|
||||
// http://hsivonen.iki.fi/script-execution/
|
||||
var scriptTags = new Array(jsFiles.length);
|
||||
var host = OpenLayers._getScriptLocation() + "lib/";
|
||||
for (var i=0, len=jsFiles.length; i<len; i++) {
|
||||
scriptTags[i] = "<script src='" + host + jsFiles[i] +
|
||||
"'></script>";
|
||||
} else {
|
||||
var s = document.createElement("script");
|
||||
s.src = host + jsfiles[i];
|
||||
var h = document.getElementsByTagName("head").length ?
|
||||
document.getElementsByTagName("head")[0] :
|
||||
document.body;
|
||||
h.appendChild(s);
|
||||
}
|
||||
}
|
||||
if (docWrite) {
|
||||
document.write(allScriptTags.join(""));
|
||||
if (scriptTags.length > 0) {
|
||||
document.write(scriptTags.join(""));
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
/**
|
||||
* Constant: VERSION_NUMBER
|
||||
*
|
||||
* This constant identifies the version of OpenLayers.
|
||||
*
|
||||
* When asking questions or reporting issues, make sure to include the output of
|
||||
* OpenLayers.VERSION_NUMBER in the question or issue-description.
|
||||
*/
|
||||
OpenLayers.VERSION_NUMBER="OpenLayers 2.10 -- $Revision$";
|
||||
OpenLayers.VERSION_NUMBER="Release 2.13.1";
|
||||
|
||||
@ -1,678 +0,0 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Request/XMLHttpRequest.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
|
||||
OpenLayers.ProxyHost = "";
|
||||
//OpenLayers.ProxyHost = "examples/proxy.cgi?url=";
|
||||
|
||||
/**
|
||||
* Ajax reader for OpenLayers
|
||||
*
|
||||
* @uri url to do remote XML http get
|
||||
* @param {String} 'get' format params (x=y&a=b...)
|
||||
* @who object to handle callbacks for this request
|
||||
* @complete the function to be called on success
|
||||
* @failure the function to be called on failure
|
||||
*
|
||||
* example usage from a caller:
|
||||
*
|
||||
* caps: function(request) {
|
||||
* -blah-
|
||||
* },
|
||||
*
|
||||
* OpenLayers.loadURL(url,params,this,caps);
|
||||
*
|
||||
* Notice the above example does not provide an error handler; a default empty
|
||||
* handler is provided which merely logs the error if a failure handler is not
|
||||
* supplied
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Function: OpenLayers.nullHandler
|
||||
* @param {} request
|
||||
*/
|
||||
OpenLayers.nullHandler = function(request) {
|
||||
OpenLayers.Console.userError(OpenLayers.i18n("unhandledRequest", {'statusText':request.statusText}));
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: OpenLayers.loadURL
|
||||
* Background load a document. For more flexibility in using XMLHttpRequest,
|
||||
* see the <OpenLayers.Request> methods.
|
||||
*
|
||||
* Parameters:
|
||||
* uri - {String} URI of source doc
|
||||
* params - {String} or {Object} GET params. Either a string in the form
|
||||
* "?hello=world&foo=bar" (do not forget the leading question mark)
|
||||
* or an object in the form {'hello': 'world', 'foo': 'bar}
|
||||
* caller - {Object} object which gets callbacks
|
||||
* onComplete - {Function} Optional callback for success. The callback
|
||||
* will be called with this set to caller and will receive the request
|
||||
* object as an argument. Note that if you do not specify an onComplete
|
||||
* function, <OpenLayers.nullHandler> will be called (which pops up a
|
||||
* user friendly error message dialog).
|
||||
* onFailure - {Function} Optional callback for failure. In the event of
|
||||
* a failure, the callback will be called with this set to caller and will
|
||||
* receive the request object as an argument. Note that if you do not
|
||||
* specify an onComplete function, <OpenLayers.nullHandler> will be called
|
||||
* (which pops up a user friendly error message dialog).
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Request.XMLHttpRequest>} The request object. To abort loading,
|
||||
* call request.abort().
|
||||
*/
|
||||
OpenLayers.loadURL = function(uri, params, caller,
|
||||
onComplete, onFailure) {
|
||||
|
||||
if(typeof params == 'string') {
|
||||
params = OpenLayers.Util.getParameters(params);
|
||||
}
|
||||
var success = (onComplete) ? onComplete : OpenLayers.nullHandler;
|
||||
var failure = (onFailure) ? onFailure : OpenLayers.nullHandler;
|
||||
|
||||
return OpenLayers.Request.GET({
|
||||
url: uri, params: params,
|
||||
success: success, failure: failure, scope: caller
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: OpenLayers.parseXMLString
|
||||
* Parse XML into a doc structure
|
||||
*
|
||||
* Parameters:
|
||||
* text - {String}
|
||||
*
|
||||
* Returns:
|
||||
* {?} Parsed AJAX Responsev
|
||||
*/
|
||||
OpenLayers.parseXMLString = function(text) {
|
||||
|
||||
//MS sucks, if the server is bad it dies
|
||||
var index = text.indexOf('<');
|
||||
if (index > 0) {
|
||||
text = text.substring(index);
|
||||
}
|
||||
|
||||
var ajaxResponse = OpenLayers.Util.Try(
|
||||
function() {
|
||||
var xmldom = new ActiveXObject('Microsoft.XMLDOM');
|
||||
xmldom.loadXML(text);
|
||||
return xmldom;
|
||||
},
|
||||
function() {
|
||||
return new DOMParser().parseFromString(text, 'text/xml');
|
||||
},
|
||||
function() {
|
||||
var req = new XMLHttpRequest();
|
||||
req.open("GET", "data:" + "text/xml" +
|
||||
";charset=utf-8," + encodeURIComponent(text), false);
|
||||
if (req.overrideMimeType) {
|
||||
req.overrideMimeType("text/xml");
|
||||
}
|
||||
req.send(null);
|
||||
return req.responseXML;
|
||||
}
|
||||
);
|
||||
|
||||
return ajaxResponse;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Ajax
|
||||
*/
|
||||
OpenLayers.Ajax = {
|
||||
|
||||
/**
|
||||
* Method: emptyFunction
|
||||
*/
|
||||
emptyFunction: function () {},
|
||||
|
||||
/**
|
||||
* Method: getTransport
|
||||
*
|
||||
* Returns:
|
||||
* {Object} Transport mechanism for whichever browser we're in, or false if
|
||||
* none available.
|
||||
*/
|
||||
getTransport: function() {
|
||||
return OpenLayers.Util.Try(
|
||||
function() {return new XMLHttpRequest();},
|
||||
function() {return new ActiveXObject('Msxml2.XMLHTTP');},
|
||||
function() {return new ActiveXObject('Microsoft.XMLHTTP');}
|
||||
) || false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: activeRequestCount
|
||||
* {Integer}
|
||||
*/
|
||||
activeRequestCount: 0
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Ajax.Responders
|
||||
* {Object}
|
||||
*/
|
||||
OpenLayers.Ajax.Responders = {
|
||||
|
||||
/**
|
||||
* Property: responders
|
||||
* {Array}
|
||||
*/
|
||||
responders: [],
|
||||
|
||||
/**
|
||||
* Method: register
|
||||
*
|
||||
* Parameters:
|
||||
* responderToAdd - {?}
|
||||
*/
|
||||
register: function(responderToAdd) {
|
||||
for (var i = 0; i < this.responders.length; i++){
|
||||
if (responderToAdd == this.responders[i]){
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.responders.push(responderToAdd);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: unregister
|
||||
*
|
||||
* Parameters:
|
||||
* responderToRemove - {?}
|
||||
*/
|
||||
unregister: function(responderToRemove) {
|
||||
OpenLayers.Util.removeItem(this.reponders, responderToRemove);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: dispatch
|
||||
*
|
||||
* Parameters:
|
||||
* callback - {?}
|
||||
* request - {?}
|
||||
* transport - {?}
|
||||
*/
|
||||
dispatch: function(callback, request, transport) {
|
||||
var responder;
|
||||
for (var i = 0; i < this.responders.length; i++) {
|
||||
responder = this.responders[i];
|
||||
|
||||
if (responder[callback] &&
|
||||
typeof responder[callback] == 'function') {
|
||||
try {
|
||||
responder[callback].apply(responder,
|
||||
[request, transport]);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
OpenLayers.Ajax.Responders.register({
|
||||
/**
|
||||
* Function: onCreate
|
||||
*/
|
||||
onCreate: function() {
|
||||
OpenLayers.Ajax.activeRequestCount++;
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: onComplete
|
||||
*/
|
||||
onComplete: function() {
|
||||
OpenLayers.Ajax.activeRequestCount--;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Ajax.Base
|
||||
*/
|
||||
OpenLayers.Ajax.Base = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Ajax.Base
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.options = {
|
||||
method: 'post',
|
||||
asynchronous: true,
|
||||
contentType: 'application/xml',
|
||||
parameters: ''
|
||||
};
|
||||
OpenLayers.Util.extend(this.options, options || {});
|
||||
|
||||
this.options.method = this.options.method.toLowerCase();
|
||||
|
||||
if (typeof this.options.parameters == 'string') {
|
||||
this.options.parameters =
|
||||
OpenLayers.Util.getParameters(this.options.parameters);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Ajax.Request
|
||||
* *Deprecated*. Use <OpenLayers.Request> method instead.
|
||||
*
|
||||
* Inherit:
|
||||
* - <OpenLayers.Ajax.Base>
|
||||
*/
|
||||
OpenLayers.Ajax.Request = OpenLayers.Class(OpenLayers.Ajax.Base, {
|
||||
|
||||
/**
|
||||
* Property: _complete
|
||||
*
|
||||
* {Boolean}
|
||||
*/
|
||||
_complete: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Ajax.Request
|
||||
*
|
||||
* Parameters:
|
||||
* url - {String}
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(url, options) {
|
||||
OpenLayers.Ajax.Base.prototype.initialize.apply(this, [options]);
|
||||
|
||||
if (OpenLayers.ProxyHost && OpenLayers.String.startsWith(url, "http")) {
|
||||
url = OpenLayers.ProxyHost + encodeURIComponent(url);
|
||||
}
|
||||
|
||||
this.transport = OpenLayers.Ajax.getTransport();
|
||||
this.request(url);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: request
|
||||
*
|
||||
* Parameters:
|
||||
* url - {String}
|
||||
*/
|
||||
request: function(url) {
|
||||
this.url = url;
|
||||
this.method = this.options.method;
|
||||
var params = OpenLayers.Util.extend({}, this.options.parameters);
|
||||
|
||||
if (this.method != 'get' && this.method != 'post') {
|
||||
// simulate other verbs over post
|
||||
params['_method'] = this.method;
|
||||
this.method = 'post';
|
||||
}
|
||||
|
||||
this.parameters = params;
|
||||
|
||||
if (params = OpenLayers.Util.getParameterString(params)) {
|
||||
// when GET, append parameters to URL
|
||||
if (this.method == 'get') {
|
||||
this.url += ((this.url.indexOf('?') > -1) ? '&' : '?') + params;
|
||||
} else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
|
||||
params += '&_=';
|
||||
}
|
||||
}
|
||||
try {
|
||||
var response = new OpenLayers.Ajax.Response(this);
|
||||
if (this.options.onCreate) {
|
||||
this.options.onCreate(response);
|
||||
}
|
||||
|
||||
OpenLayers.Ajax.Responders.dispatch('onCreate',
|
||||
this,
|
||||
response);
|
||||
|
||||
this.transport.open(this.method.toUpperCase(),
|
||||
this.url,
|
||||
this.options.asynchronous);
|
||||
|
||||
if (this.options.asynchronous) {
|
||||
window.setTimeout(
|
||||
OpenLayers.Function.bind(this.respondToReadyState, this, 1),
|
||||
10);
|
||||
}
|
||||
|
||||
this.transport.onreadystatechange =
|
||||
OpenLayers.Function.bind(this.onStateChange, this);
|
||||
this.setRequestHeaders();
|
||||
|
||||
this.body = this.method == 'post' ?
|
||||
(this.options.postBody || params) : null;
|
||||
this.transport.send(this.body);
|
||||
|
||||
// Force Firefox to handle ready state 4 for synchronous requests
|
||||
if (!this.options.asynchronous &&
|
||||
this.transport.overrideMimeType) {
|
||||
this.onStateChange();
|
||||
}
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onStateChange
|
||||
*/
|
||||
onStateChange: function() {
|
||||
var readyState = this.transport.readyState;
|
||||
if (readyState > 1 && !((readyState == 4) && this._complete)) {
|
||||
this.respondToReadyState(this.transport.readyState);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setRequestHeaders
|
||||
*/
|
||||
setRequestHeaders: function() {
|
||||
var headers = {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*',
|
||||
'OpenLayers': true
|
||||
};
|
||||
|
||||
if (this.method == 'post') {
|
||||
headers['Content-type'] = this.options.contentType +
|
||||
(this.options.encoding ? '; charset=' + this.options.encoding : '');
|
||||
|
||||
/* Force "Connection: close" for older Mozilla browsers to work
|
||||
* around a bug where XMLHttpRequest sends an incorrect
|
||||
* Content-length header. See Mozilla Bugzilla #246651.
|
||||
*/
|
||||
if (this.transport.overrideMimeType &&
|
||||
(navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) {
|
||||
headers['Connection'] = 'close';
|
||||
}
|
||||
}
|
||||
// user-defined headers
|
||||
if (typeof this.options.requestHeaders == 'object') {
|
||||
var extras = this.options.requestHeaders;
|
||||
|
||||
if (typeof extras.push == 'function') {
|
||||
for (var i = 0, length = extras.length; i < length; i += 2) {
|
||||
headers[extras[i]] = extras[i+1];
|
||||
}
|
||||
} else {
|
||||
for (var i in extras) {
|
||||
headers[i] = extras[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var name in headers) {
|
||||
this.transport.setRequestHeader(name, headers[name]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: success
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} -
|
||||
*/
|
||||
success: function() {
|
||||
var status = this.getStatus();
|
||||
return !status || (status >=200 && status < 300);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getStatus
|
||||
*
|
||||
* Returns:
|
||||
* {Integer} - Status
|
||||
*/
|
||||
getStatus: function() {
|
||||
try {
|
||||
return this.transport.status || 0;
|
||||
} catch (e) {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: respondToReadyState
|
||||
*
|
||||
* Parameters:
|
||||
* readyState - {?}
|
||||
*/
|
||||
respondToReadyState: function(readyState) {
|
||||
var state = OpenLayers.Ajax.Request.Events[readyState];
|
||||
var response = new OpenLayers.Ajax.Response(this);
|
||||
|
||||
if (state == 'Complete') {
|
||||
try {
|
||||
this._complete = true;
|
||||
(this.options['on' + response.status] ||
|
||||
this.options['on' + (this.success() ? 'Success' : 'Failure')] ||
|
||||
OpenLayers.Ajax.emptyFunction)(response);
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
|
||||
var contentType = response.getHeader('Content-type');
|
||||
}
|
||||
|
||||
try {
|
||||
(this.options['on' + state] ||
|
||||
OpenLayers.Ajax.emptyFunction)(response);
|
||||
OpenLayers.Ajax.Responders.dispatch('on' + state,
|
||||
this,
|
||||
response);
|
||||
} catch (e) {
|
||||
this.dispatchException(e);
|
||||
}
|
||||
|
||||
if (state == 'Complete') {
|
||||
// avoid memory leak in MSIE: clean up
|
||||
this.transport.onreadystatechange = OpenLayers.Ajax.emptyFunction;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getHeader
|
||||
*
|
||||
* Parameters:
|
||||
* name - {String} Header name
|
||||
*
|
||||
* Returns:
|
||||
* {?} - response header for the given name
|
||||
*/
|
||||
getHeader: function(name) {
|
||||
try {
|
||||
return this.transport.getResponseHeader(name);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: dispatchException
|
||||
* If the optional onException function is set, execute it
|
||||
* and then dispatch the call to any other listener registered
|
||||
* for onException.
|
||||
*
|
||||
* If no optional onException function is set, we suspect that
|
||||
* the user may have also not used
|
||||
* OpenLayers.Ajax.Responders.register to register a listener
|
||||
* for the onException call. To make sure that something
|
||||
* gets done with this exception, only dispatch the call if there
|
||||
* are listeners.
|
||||
*
|
||||
* If you explicitly want to swallow exceptions, set
|
||||
* request.options.onException to an empty function (function(){})
|
||||
* or register an empty function with <OpenLayers.Ajax.Responders>
|
||||
* for onException.
|
||||
*
|
||||
* Parameters:
|
||||
* exception - {?}
|
||||
*/
|
||||
dispatchException: function(exception) {
|
||||
var handler = this.options.onException;
|
||||
if(handler) {
|
||||
// call options.onException and alert any other listeners
|
||||
handler(this, exception);
|
||||
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
|
||||
} else {
|
||||
// check if there are any other listeners
|
||||
var listener = false;
|
||||
var responders = OpenLayers.Ajax.Responders.responders;
|
||||
for (var i = 0; i < responders.length; i++) {
|
||||
if(responders[i].onException) {
|
||||
listener = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(listener) {
|
||||
// call all listeners
|
||||
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
|
||||
} else {
|
||||
// let the exception through
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Property: Events
|
||||
* {Array(String)}
|
||||
*/
|
||||
OpenLayers.Ajax.Request.Events =
|
||||
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Ajax.Response
|
||||
*/
|
||||
OpenLayers.Ajax.Response = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Property: status
|
||||
*
|
||||
* {Integer}
|
||||
*/
|
||||
status: 0,
|
||||
|
||||
|
||||
/**
|
||||
* Property: statusText
|
||||
*
|
||||
* {String}
|
||||
*/
|
||||
statusText: '',
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Ajax.Response
|
||||
*
|
||||
* Parameters:
|
||||
* request - {Object}
|
||||
*/
|
||||
initialize: function(request) {
|
||||
this.request = request;
|
||||
var transport = this.transport = request.transport,
|
||||
readyState = this.readyState = transport.readyState;
|
||||
|
||||
if ((readyState > 2 &&
|
||||
!(!!(window.attachEvent && !window.opera))) ||
|
||||
readyState == 4) {
|
||||
this.status = this.getStatus();
|
||||
this.statusText = this.getStatusText();
|
||||
this.responseText = transport.responseText == null ?
|
||||
'' : String(transport.responseText);
|
||||
}
|
||||
|
||||
if(readyState == 4) {
|
||||
var xml = transport.responseXML;
|
||||
this.responseXML = xml === undefined ? null : xml;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getStatus
|
||||
*/
|
||||
getStatus: OpenLayers.Ajax.Request.prototype.getStatus,
|
||||
|
||||
/**
|
||||
* Method: getStatustext
|
||||
*
|
||||
* Returns:
|
||||
* {String} - statusText
|
||||
*/
|
||||
getStatusText: function() {
|
||||
try {
|
||||
return this.transport.statusText || '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getHeader
|
||||
*/
|
||||
getHeader: OpenLayers.Ajax.Request.prototype.getHeader,
|
||||
|
||||
/**
|
||||
* Method: getResponseHeader
|
||||
*
|
||||
* Returns:
|
||||
* {?} - response header for given name
|
||||
*/
|
||||
getResponseHeader: function(name) {
|
||||
return this.transport.getResponseHeader(name);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Function: getElementsByTagNameNS
|
||||
*
|
||||
* Parameters:
|
||||
* parentnode - {?}
|
||||
* nsuri - {?}
|
||||
* nsprefix - {?}
|
||||
* tagname - {?}
|
||||
*
|
||||
* Returns:
|
||||
* {?}
|
||||
*/
|
||||
OpenLayers.Ajax.getElementsByTagNameNS = function(parentnode, nsuri,
|
||||
nsprefix, tagname) {
|
||||
var elem = null;
|
||||
if (parentnode.getElementsByTagNameNS) {
|
||||
elem = parentnode.getElementsByTagNameNS(nsuri, tagname);
|
||||
} else {
|
||||
elem = parentnode.getElementsByTagName(nsprefix + ':' + tagname);
|
||||
}
|
||||
return elem;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function: serializeXMLToString
|
||||
* Wrapper function around XMLSerializer, which doesn't exist/work in
|
||||
* IE/Safari. We need to come up with a way to serialize in those browser:
|
||||
* for now, these browsers will just fail. #535, #536
|
||||
*
|
||||
* Parameters:
|
||||
* xmldom {XMLNode} xml dom to serialize
|
||||
*
|
||||
* Returns:
|
||||
* {?}
|
||||
*/
|
||||
OpenLayers.Ajax.serializeXMLToString = function(xmldom) {
|
||||
var serializer = new XMLSerializer();
|
||||
var data = serializer.serializeToString(xmldom);
|
||||
return data;
|
||||
};
|
||||
102
js/openlayers/src/openlayers/lib/OpenLayers/Animation.js
Normal file
@ -0,0 +1,102 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/SingleFile.js
|
||||
* @requires OpenLayers/Util/vendorPrefix.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Animation
|
||||
* A collection of utility functions for executing methods that repaint a
|
||||
* portion of the browser window. These methods take advantage of the
|
||||
* browser's scheduled repaints where requestAnimationFrame is available.
|
||||
*/
|
||||
OpenLayers.Animation = (function(window) {
|
||||
|
||||
/**
|
||||
* Property: isNative
|
||||
* {Boolean} true if a native requestAnimationFrame function is available
|
||||
*/
|
||||
var requestAnimationFrame = OpenLayers.Util.vendorPrefix.js(window, "requestAnimationFrame");
|
||||
var isNative = !!(requestAnimationFrame);
|
||||
|
||||
/**
|
||||
* Function: requestFrame
|
||||
* Schedule a function to be called at the next available animation frame.
|
||||
* Uses the native method where available. Where requestAnimationFrame is
|
||||
* not available, setTimeout will be called with a 16ms delay.
|
||||
*
|
||||
* Parameters:
|
||||
* callback - {Function} The function to be called at the next animation frame.
|
||||
* element - {DOMElement} Optional element that visually bounds the animation.
|
||||
*/
|
||||
var requestFrame = (function() {
|
||||
var request = window[requestAnimationFrame] ||
|
||||
function(callback, element) {
|
||||
window.setTimeout(callback, 16);
|
||||
};
|
||||
// bind to window to avoid illegal invocation of native function
|
||||
return function(callback, element) {
|
||||
request.apply(window, [callback, element]);
|
||||
};
|
||||
})();
|
||||
|
||||
// private variables for animation loops
|
||||
var counter = 0;
|
||||
var loops = {};
|
||||
|
||||
/**
|
||||
* Function: start
|
||||
* Executes a method with <requestFrame> in series for some
|
||||
* duration.
|
||||
*
|
||||
* Parameters:
|
||||
* callback - {Function} The function to be called at the next animation frame.
|
||||
* duration - {Number} Optional duration for the loop. If not provided, the
|
||||
* animation loop will execute indefinitely.
|
||||
* element - {DOMElement} Optional element that visually bounds the animation.
|
||||
*
|
||||
* Returns:
|
||||
* {Number} Identifier for the animation loop. Used to stop animations with
|
||||
* <stop>.
|
||||
*/
|
||||
function start(callback, duration, element) {
|
||||
duration = duration > 0 ? duration : Number.POSITIVE_INFINITY;
|
||||
var id = ++counter;
|
||||
var start = +new Date;
|
||||
loops[id] = function() {
|
||||
if (loops[id] && +new Date - start <= duration) {
|
||||
callback();
|
||||
if (loops[id]) {
|
||||
requestFrame(loops[id], element);
|
||||
}
|
||||
} else {
|
||||
delete loops[id];
|
||||
}
|
||||
};
|
||||
requestFrame(loops[id], element);
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function: stop
|
||||
* Terminates an animation loop started with <start>.
|
||||
*
|
||||
* Parameters:
|
||||
* id - {Number} Identifier returned from <start>.
|
||||
*/
|
||||
function stop(id) {
|
||||
delete loops[id];
|
||||
}
|
||||
|
||||
return {
|
||||
isNative: isNative,
|
||||
requestFrame: requestFrame,
|
||||
start: start,
|
||||
stop: stop
|
||||
};
|
||||
|
||||
})(window);
|
||||
@ -1,19 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
* @requires OpenLayers/BaseTypes/LonLat.js
|
||||
* @requires OpenLayers/BaseTypes/Size.js
|
||||
* @requires OpenLayers/BaseTypes/Pixel.js
|
||||
* @requires OpenLayers/BaseTypes/Bounds.js
|
||||
* @requires OpenLayers/BaseTypes/Element.js
|
||||
* @requires OpenLayers/Lang/en.js
|
||||
* @requires OpenLayers/Console.js
|
||||
* @requires OpenLayers/SingleFile.js
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Header: OpenLayers Base Types
|
||||
* OpenLayers custom string, number and function functions are described here.
|
||||
@ -31,7 +24,7 @@ OpenLayers.String = {
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string to test.
|
||||
* sub - {Sring} The substring to look for.
|
||||
* sub - {String} The substring to look for.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The first string starts with the second.
|
||||
@ -134,7 +127,9 @@ OpenLayers.String = {
|
||||
if (i == 0) {
|
||||
replacement = context;
|
||||
}
|
||||
|
||||
if (replacement === undefined) {
|
||||
break;
|
||||
}
|
||||
replacement = replacement[subs[i]];
|
||||
}
|
||||
|
||||
@ -159,20 +154,20 @@ OpenLayers.String = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Property: OpenLayers.String.tokenRegEx
|
||||
* Property: tokenRegEx
|
||||
* Used to find tokens in a string.
|
||||
* Examples: ${a}, ${a.b.c}, ${a-b}, ${5}
|
||||
*/
|
||||
tokenRegEx: /\$\{([\w.]+?)\}/g,
|
||||
|
||||
/**
|
||||
* Property: OpenLayers.String.numberRegEx
|
||||
* Property: numberRegEx
|
||||
* Used to test strings as numbers.
|
||||
*/
|
||||
numberRegEx: /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/,
|
||||
|
||||
/**
|
||||
* APIFunction: OpenLayers.String.isNumeric
|
||||
* APIFunction: isNumeric
|
||||
* Determine whether a string contains only a numeric value.
|
||||
*
|
||||
* Examples:
|
||||
@ -194,85 +189,24 @@ OpenLayers.String = {
|
||||
* APIFunction: numericIf
|
||||
* Converts a string that appears to be a numeric value into a number.
|
||||
*
|
||||
* Returns
|
||||
* Parameters:
|
||||
* value - {String}
|
||||
* trimWhitespace - {Boolean}
|
||||
*
|
||||
* Returns:
|
||||
* {Number|String} a Number if the passed value is a number, a String
|
||||
* otherwise.
|
||||
*/
|
||||
numericIf: function(value) {
|
||||
return OpenLayers.String.isNumeric(value) ? parseFloat(value) : value;
|
||||
numericIf: function(value, trimWhitespace) {
|
||||
var originalValue = value;
|
||||
if (trimWhitespace === true && value != null && value.replace) {
|
||||
value = value.replace(/^\s*|\s*$/g, "");
|
||||
}
|
||||
return OpenLayers.String.isNumeric(value) ? parseFloat(value) : originalValue;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
/**
|
||||
* APIMethod: String.startsWith
|
||||
* *Deprecated*. Whether or not a string starts with another string.
|
||||
*
|
||||
* Parameters:
|
||||
* sStart - {Sring} The string we're testing for.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Whether or not this string starts with the string passed in.
|
||||
*/
|
||||
String.prototype.startsWith = function(sStart) {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.String.startsWith'}));
|
||||
return OpenLayers.String.startsWith(this, sStart);
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.contains) {
|
||||
/**
|
||||
* APIMethod: String.contains
|
||||
* *Deprecated*. Whether or not a string contains another string.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} The string that we're testing for.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Whether or not this string contains with the string passed in.
|
||||
*/
|
||||
String.prototype.contains = function(str) {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.String.contains'}));
|
||||
return OpenLayers.String.contains(this, str);
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.trim) {
|
||||
/**
|
||||
* APIMethod: String.trim
|
||||
* *Deprecated*. Removes leading and trailing whitespace characters from a string.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A trimmed version of the string - all leading and
|
||||
* trailing spaces removed
|
||||
*/
|
||||
String.prototype.trim = function() {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.String.trim'}));
|
||||
return OpenLayers.String.trim(this);
|
||||
};
|
||||
}
|
||||
|
||||
if (!String.prototype.camelize) {
|
||||
/**
|
||||
* APIMethod: String.camelize
|
||||
* *Deprecated*. Camel-case a hyphenated string.
|
||||
* Ex. "chicken-head" becomes "chickenHead", and
|
||||
* "-chicken-head" becomes "ChickenHead".
|
||||
*
|
||||
* Returns:
|
||||
* {String} The string, camelized
|
||||
*/
|
||||
String.prototype.camelize = function() {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.String.camelize'}));
|
||||
return OpenLayers.String.camelize(this);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Number
|
||||
* Contains convenience functions for manipulating numbers.
|
||||
@ -363,28 +297,26 @@ OpenLayers.Number = {
|
||||
str = integer + dsep + rem;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
if (!Number.prototype.limitSigDigs) {
|
||||
/**
|
||||
* APIMethod: Number.limitSigDigs
|
||||
* *Deprecated*. Limit the number of significant digits on an integer. Does *not*
|
||||
* work with floats!
|
||||
*
|
||||
* Method: zeroPad
|
||||
* Create a zero padded string optionally with a radix for casting numbers.
|
||||
*
|
||||
* Parameters:
|
||||
* sig - {Integer}
|
||||
*
|
||||
* Returns:
|
||||
* {Integer} The number, rounded to the specified number of significant digits.
|
||||
* If null, 0, or negative value passed in, returns 0
|
||||
* num - {Number} The number to be zero padded.
|
||||
* len - {Number} The length of the string to be returned.
|
||||
* radix - {Number} An integer between 2 and 36 specifying the base to use
|
||||
* for representing numeric values.
|
||||
*/
|
||||
Number.prototype.limitSigDigs = function(sig) {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.Number.limitSigDigs'}));
|
||||
return OpenLayers.Number.limitSigDigs(this, sig);
|
||||
};
|
||||
}
|
||||
zeroPad: function(num, len, radix) {
|
||||
var str = num.toString(radix || 10);
|
||||
while (str.length < len) {
|
||||
str = "0" + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Function
|
||||
@ -464,50 +396,19 @@ OpenLayers.Function = {
|
||||
*/
|
||||
True : function() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: Void
|
||||
* A reusable function that returns ``undefined``.
|
||||
*
|
||||
* Returns:
|
||||
* {undefined}
|
||||
*/
|
||||
Void: function() {}
|
||||
|
||||
};
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
/**
|
||||
* APIMethod: Function.bind
|
||||
* *Deprecated*. Bind a function to an object.
|
||||
* Method to easily create closures with 'this' altered.
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} the this parameter
|
||||
*
|
||||
* Returns:
|
||||
* {Function} A closure with 'this' altered to the first
|
||||
* argument.
|
||||
*/
|
||||
Function.prototype.bind = function() {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.Function.bind'}));
|
||||
// new function takes the same arguments with this function up front
|
||||
Array.prototype.unshift.apply(arguments, [this]);
|
||||
return OpenLayers.Function.bind.apply(null, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
if (!Function.prototype.bindAsEventListener) {
|
||||
/**
|
||||
* APIMethod: Function.bindAsEventListener
|
||||
* *Deprecated*. Bind a function to an object, and configure it to receive the
|
||||
* event object as first parameter when called.
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} A reference to this.
|
||||
*
|
||||
* Returns:
|
||||
* {Function}
|
||||
*/
|
||||
Function.prototype.bindAsEventListener = function(object) {
|
||||
OpenLayers.Console.warn(OpenLayers.i18n("methodDeprecated",
|
||||
{'newMethod':'OpenLayers.Function.bindAsEventListener'}));
|
||||
return OpenLayers.Function.bindAsEventListener(this, object);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Array
|
||||
* Contains convenience functions for array manipulation.
|
||||
@ -560,123 +461,3 @@ OpenLayers.Array = {
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Date
|
||||
* Contains implementations of Date.parse and date.toISOString that match the
|
||||
* ECMAScript 5 specification for parsing RFC 3339 dates.
|
||||
* http://tools.ietf.org/html/rfc3339
|
||||
*/
|
||||
OpenLayers.Date = {
|
||||
|
||||
/**
|
||||
* APIMethod: toISOString
|
||||
* Generates a string representing a date. The format of the string follows
|
||||
* the profile of ISO 8601 for date and time on the Internet (see
|
||||
* http://tools.ietf.org/html/rfc3339). If the toISOString method is
|
||||
* available on the Date prototype, that is used. The toISOString
|
||||
* method for Date instances is defined in ECMA-262.
|
||||
*
|
||||
* Parameters:
|
||||
* date - {Date} A date object.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A string representing the date (e.g.
|
||||
* "2010-08-07T16:58:23.123Z"). If the date does not have a valid time
|
||||
* (i.e. isNaN(date.getTime())) this method returns the string "Invalid
|
||||
* Date". The ECMA standard says the toISOString method should throw
|
||||
* RangeError in this case, but Firefox returns a string instead. For
|
||||
* best results, use isNaN(date.getTime()) to determine date validity
|
||||
* before generating date strings.
|
||||
*/
|
||||
toISOString: (function() {
|
||||
if ("toISOString" in Date.prototype) {
|
||||
return function(date) {
|
||||
return date.toISOString();
|
||||
}
|
||||
} else {
|
||||
function pad(num, len) {
|
||||
var str = num + "";
|
||||
while (str.length < len) {
|
||||
str = "0" + str;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
return function(date) {
|
||||
var str;
|
||||
if (isNaN(date.getTime())) {
|
||||
// ECMA-262 says throw RangeError, Firefox returns
|
||||
// "Invalid Date"
|
||||
str = "Invalid Date";
|
||||
} else {
|
||||
str =
|
||||
date.getUTCFullYear() + "-" +
|
||||
pad(date.getUTCMonth() + 1, 2) + "-" +
|
||||
pad(date.getUTCDate(), 2) + "T" +
|
||||
pad(date.getUTCHours(), 2) + ":" +
|
||||
pad(date.getUTCMinutes(), 2) + ":" +
|
||||
pad(date.getUTCSeconds(), 2) + "." +
|
||||
pad(date.getUTCMilliseconds(), 3) + "Z";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
})(),
|
||||
|
||||
/**
|
||||
* APIMethod: parse
|
||||
* Generate a date object from a string. The format for the string follows
|
||||
* the profile of ISO 8601 for date and time on the Internet (see
|
||||
* http://tools.ietf.org/html/rfc3339). If the parse method on
|
||||
* the Date constructor returns a valid date for the given string,
|
||||
* that method is used.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} A string representing the date (e.g.
|
||||
* "2010", "2010-08", "2010-08-07", "2010-08-07T16:58:23.123Z",
|
||||
* "2010-08-07T11:58:23.123-06").
|
||||
*
|
||||
* Returns:
|
||||
* {Date} A date object. If the string could not be parsed, an invalid
|
||||
* date is returned (i.e. isNaN(date.getTime())).
|
||||
*/
|
||||
parse: function(str) {
|
||||
var date;
|
||||
// first check if the native parse method can parse it
|
||||
var elapsed = Date.parse(str);
|
||||
if (!isNaN(elapsed)) {
|
||||
date = new Date(elapsed);
|
||||
} else {
|
||||
var match = str.match(/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))?$/);
|
||||
var date;
|
||||
if (match && (match[1] || match[7])) { // must have at least year or time
|
||||
var year = parseInt(match[1], 10) || 0;
|
||||
var month = (parseInt(match[2], 10) - 1) || 0;
|
||||
var day = parseInt(match[3], 10) || 1;
|
||||
date = new Date(Date.UTC(year, month, day));
|
||||
// optional time
|
||||
var type = match[7];
|
||||
if (type) {
|
||||
var hours = parseInt(match[4], 10);
|
||||
var minutes = parseInt(match[5], 10);
|
||||
var secFrac = parseFloat(match[6]);
|
||||
var seconds = secFrac | 0;
|
||||
var milliseconds = Math.round(1000 * (secFrac - seconds));
|
||||
date.setUTCHours(hours, minutes, seconds, milliseconds);
|
||||
// check offset
|
||||
if (type !== "Z") {
|
||||
var hoursOffset = parseInt(type, 10);
|
||||
var minutesOffset = parseInt(match[8]) || 0;
|
||||
var offset = -1000 * (60 * (hoursOffset * 60) + minutesOffset * 60);
|
||||
date = new Date(date.getTime() + offset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
date = new Date("invalid");
|
||||
}
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
};
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Console.js
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -14,10 +14,12 @@
|
||||
* you should make sure you set them before using the bounds for anything.
|
||||
*
|
||||
* Possible use case:
|
||||
* > bounds = new OpenLayers.Bounds();
|
||||
* > bounds.extend(new OpenLayers.LonLat(4,5));
|
||||
* > bounds.extend(new OpenLayers.LonLat(5,6));
|
||||
* > bounds.toBBOX(); // returns 4,5,5,6
|
||||
* (code)
|
||||
* bounds = new OpenLayers.Bounds();
|
||||
* bounds.extend(new OpenLayers.LonLat(4,5));
|
||||
* bounds.extend(new OpenLayers.LonLat(5,6));
|
||||
* bounds.toBBOX(); // returns 4,5,5,6
|
||||
* (end)
|
||||
*/
|
||||
OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
@ -54,17 +56,27 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Bounds
|
||||
* Construct a new bounds object.
|
||||
* Construct a new bounds object. Coordinates can either be passed as four
|
||||
* arguments, or as a single argument.
|
||||
*
|
||||
* Parameters:
|
||||
* Parameters (four arguments):
|
||||
* left - {Number} The left bounds of the box. Note that for width
|
||||
* calculations, this is assumed to be less than the right value.
|
||||
* bottom - {Number} The bottom bounds of the box. Note that for height
|
||||
* calculations, this is assumed to be more than the top value.
|
||||
* calculations, this is assumed to be less than the top value.
|
||||
* right - {Number} The right bounds.
|
||||
* top - {Number} The top bounds.
|
||||
*
|
||||
* Parameters (single argument):
|
||||
* bounds - {Array(Number)} [left, bottom, right, top]
|
||||
*/
|
||||
initialize: function(left, bottom, right, top) {
|
||||
if (OpenLayers.Util.isArray(left)) {
|
||||
top = left[3];
|
||||
right = left[2];
|
||||
bottom = left[1];
|
||||
left = left[0];
|
||||
}
|
||||
if (left != null) {
|
||||
this.left = OpenLayers.Util.toFloat(left);
|
||||
}
|
||||
@ -116,18 +128,22 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: toString
|
||||
* Returns a string representation of the bounds object.
|
||||
*
|
||||
* Returns:
|
||||
* {String} String representation of bounds object.
|
||||
* (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
|
||||
*/
|
||||
toString:function() {
|
||||
return ( "left-bottom=(" + this.left + "," + this.bottom + ")"
|
||||
+ " right-top=(" + this.right + "," + this.top + ")" );
|
||||
return [this.left, this.bottom, this.right, this.top].join(",");
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: toArray
|
||||
* Returns an array representation of the bounds object.
|
||||
*
|
||||
* Returns an array of left, bottom, right, top properties, or -- when the
|
||||
* optional parameter is true -- an array of the bottom, left, top,
|
||||
* right properties.
|
||||
*
|
||||
* Parameters:
|
||||
* reverseAxisOrder - {Boolean} Should we reverse the axis order?
|
||||
@ -145,6 +161,7 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: toBBOX
|
||||
* Returns a boundingbox-string representation of the bounds object.
|
||||
*
|
||||
* Parameters:
|
||||
* decimal - {Integer} How many significant digits in the bbox coords?
|
||||
@ -153,7 +170,7 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
*
|
||||
* Returns:
|
||||
* {String} Simple String representation of bounds object.
|
||||
* (ex. <i>"5,42,10,45"</i>)
|
||||
* (e.g. "5,42,10,45")
|
||||
*/
|
||||
toBBOX:function(decimal, reverseAxisOrder) {
|
||||
if (decimal== null) {
|
||||
@ -192,9 +209,10 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: getWidth
|
||||
* Returns the width of the bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {Float} The width of the bounds
|
||||
* {Float} The width of the bounds (right minus left).
|
||||
*/
|
||||
getWidth:function() {
|
||||
return (this.right - this.left);
|
||||
@ -202,6 +220,7 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: getHeight
|
||||
* Returns the height of the bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {Float} The height of the bounds (top minus bottom).
|
||||
@ -212,9 +231,10 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: getSize
|
||||
* Returns an <OpenLayers.Size> object of the bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Size>} The size of the box.
|
||||
* {<OpenLayers.Size>} The size of the bounds.
|
||||
*/
|
||||
getSize:function() {
|
||||
return new OpenLayers.Size(this.getWidth(), this.getHeight());
|
||||
@ -222,6 +242,8 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: getCenterPixel
|
||||
* Returns the <OpenLayers.Pixel> object which represents the center of the
|
||||
* bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Pixel>} The center of the bounds in pixel space.
|
||||
@ -233,7 +255,9 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: getCenterLonLat
|
||||
*
|
||||
* Returns the <OpenLayers.LonLat> object which represents the center of the
|
||||
* bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.LonLat>} The center of the bounds in map space.
|
||||
*/
|
||||
@ -247,7 +271,7 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: scale
|
||||
* APIMethod: scale
|
||||
* Scales the bounds around a pixel or lonlat. Note that the new
|
||||
* bounds may return non-integer properties, even if a pixel
|
||||
* is passed.
|
||||
@ -258,10 +282,9 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
* Default is center.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bound>} A new bounds that is scaled by ratio
|
||||
* {<OpenLayers.Bounds>} A new bounds that is scaled by ratio
|
||||
* from origin.
|
||||
*/
|
||||
|
||||
scale: function(ratio, origin){
|
||||
if(origin == null){
|
||||
origin = this.getCenterLonLat();
|
||||
@ -288,20 +311,31 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: add
|
||||
*
|
||||
* Shifts the coordinates of the bound by the given horizontal and vertical
|
||||
* deltas.
|
||||
*
|
||||
* (start code)
|
||||
* var bounds = new OpenLayers.Bounds(0, 0, 10, 10);
|
||||
* bounds.toString();
|
||||
* // => "0,0,10,10"
|
||||
*
|
||||
* bounds.add(-1.5, 4).toString();
|
||||
* // => "-1.5,4,8.5,14"
|
||||
* (end)
|
||||
*
|
||||
* This method will throw a TypeError if it is passed null as an argument.
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Float}
|
||||
* y - {Float}
|
||||
*
|
||||
* x - {Float} horizontal delta
|
||||
* y - {Float} vertical delta
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bounds>} A new bounds whose coordinates are the same as
|
||||
* this, but shifted by the passed-in x and y values.
|
||||
*/
|
||||
add:function(x, y) {
|
||||
if ( (x == null) || (y == null) ) {
|
||||
var msg = OpenLayers.i18n("boundsAddError");
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
throw new TypeError('Bounds.add cannot receive null values');
|
||||
}
|
||||
return new OpenLayers.Bounds(this.left + x, this.bottom + y,
|
||||
this.right + x, this.top + y);
|
||||
@ -309,66 +343,116 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: extend
|
||||
* Extend the bounds to include the point, lonlat, or bounds specified.
|
||||
* Note, this function assumes that left < right and bottom < top.
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} Can be LonLat, Point, or Bounds
|
||||
* Extend the bounds to include the <OpenLayers.LonLat>,
|
||||
* <OpenLayers.Geometry.Point> or <OpenLayers.Bounds> specified.
|
||||
*
|
||||
* Please note that this function assumes that left < right and
|
||||
* bottom < top.
|
||||
*
|
||||
* Parameters:
|
||||
* object - {<OpenLayers.LonLat>, <OpenLayers.Geometry.Point> or
|
||||
* <OpenLayers.Bounds>} The object to be included in the new bounds
|
||||
* object.
|
||||
*/
|
||||
extend:function(object) {
|
||||
var bounds = null;
|
||||
if (object) {
|
||||
// clear cached center location
|
||||
switch(object.CLASS_NAME) {
|
||||
case "OpenLayers.LonLat":
|
||||
bounds = new OpenLayers.Bounds(object.lon, object.lat,
|
||||
object.lon, object.lat);
|
||||
case "OpenLayers.LonLat":
|
||||
this.extendXY(object.lon, object.lat);
|
||||
break;
|
||||
case "OpenLayers.Geometry.Point":
|
||||
bounds = new OpenLayers.Bounds(object.x, object.y,
|
||||
object.x, object.y);
|
||||
this.extendXY(object.x, object.y);
|
||||
break;
|
||||
|
||||
case "OpenLayers.Bounds":
|
||||
bounds = object;
|
||||
|
||||
case "OpenLayers.Bounds":
|
||||
// clear cached center location
|
||||
this.centerLonLat = null;
|
||||
|
||||
if ( (this.left == null) || (object.left < this.left)) {
|
||||
this.left = object.left;
|
||||
}
|
||||
if ( (this.bottom == null) || (object.bottom < this.bottom) ) {
|
||||
this.bottom = object.bottom;
|
||||
}
|
||||
if ( (this.right == null) || (object.right > this.right) ) {
|
||||
this.right = object.right;
|
||||
}
|
||||
if ( (this.top == null) || (object.top > this.top) ) {
|
||||
this.top = object.top;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (bounds) {
|
||||
this.centerLonLat = null;
|
||||
if ( (this.left == null) || (bounds.left < this.left)) {
|
||||
this.left = bounds.left;
|
||||
}
|
||||
if ( (this.bottom == null) || (bounds.bottom < this.bottom) ) {
|
||||
this.bottom = bounds.bottom;
|
||||
}
|
||||
if ( (this.right == null) || (bounds.right > this.right) ) {
|
||||
this.right = bounds.right;
|
||||
}
|
||||
if ( (this.top == null) || (bounds.top > this.top) ) {
|
||||
this.top = bounds.top;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: extendXY
|
||||
* Extend the bounds to include the XY coordinate specified.
|
||||
*
|
||||
* Parameters:
|
||||
* x - {number} The X part of the the coordinate.
|
||||
* y - {number} The Y part of the the coordinate.
|
||||
*/
|
||||
extendXY:function(x, y) {
|
||||
// clear cached center location
|
||||
this.centerLonLat = null;
|
||||
|
||||
if ((this.left == null) || (x < this.left)) {
|
||||
this.left = x;
|
||||
}
|
||||
if ((this.bottom == null) || (y < this.bottom)) {
|
||||
this.bottom = y;
|
||||
}
|
||||
if ((this.right == null) || (x > this.right)) {
|
||||
this.right = x;
|
||||
}
|
||||
if ((this.top == null) || (y > this.top)) {
|
||||
this.top = y;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: containsLonLat
|
||||
* Returns whether the bounds object contains the given <OpenLayers.LonLat>.
|
||||
*
|
||||
* Parameters:
|
||||
* ll - {<OpenLayers.LonLat>}
|
||||
* ll - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
|
||||
* object with a 'lon' and 'lat' properties.
|
||||
* options - {Object} Optional parameters
|
||||
*
|
||||
* Acceptable options:
|
||||
* inclusive - {Boolean} Whether or not to include the border.
|
||||
* Default is true.
|
||||
* worldBounds - {<OpenLayers.Bounds>} If a worldBounds is provided, the
|
||||
* ll will be considered as contained if it exceeds the world bounds,
|
||||
* but can be wrapped around the dateline so it is contained by this
|
||||
* bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The passed-in lonlat is within this bounds.
|
||||
*/
|
||||
containsLonLat:function(ll, inclusive) {
|
||||
return this.contains(ll.lon, ll.lat, inclusive);
|
||||
containsLonLat: function(ll, options) {
|
||||
if (typeof options === "boolean") {
|
||||
options = {inclusive: options};
|
||||
}
|
||||
options = options || {};
|
||||
var contains = this.contains(ll.lon, ll.lat, options.inclusive),
|
||||
worldBounds = options.worldBounds;
|
||||
if (worldBounds && !contains) {
|
||||
var worldWidth = worldBounds.getWidth();
|
||||
var worldCenterX = (worldBounds.left + worldBounds.right) / 2;
|
||||
var worldsAway = Math.round((ll.lon - worldCenterX) / worldWidth);
|
||||
contains = this.containsLonLat({
|
||||
lon: ll.lon - worldsAway * worldWidth,
|
||||
lat: ll.lat
|
||||
}, {inclusive: options.inclusive});
|
||||
}
|
||||
return contains;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: containsPixel
|
||||
* Returns whether the bounds object contains the given <OpenLayers.Pixel>.
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
@ -384,6 +468,7 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: contains
|
||||
* Returns whether the bounds object contains the given x and y.
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Float}
|
||||
@ -427,54 +512,85 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
*
|
||||
* Parameters:
|
||||
* bounds - {<OpenLayers.Bounds>} The target bounds.
|
||||
* options - {Object} Optional parameters.
|
||||
*
|
||||
* Acceptable options:
|
||||
* inclusive - {Boolean} Treat coincident borders as intersecting. Default
|
||||
* is true. If false, bounds that do not overlap but only touch at the
|
||||
* border will not be considered as intersecting.
|
||||
* worldBounds - {<OpenLayers.Bounds>} If a worldBounds is provided, two
|
||||
* bounds will be considered as intersecting if they intersect when
|
||||
* shifted to within the world bounds. This applies only to bounds that
|
||||
* cross or are completely outside the world bounds.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The passed-in bounds object intersects this bounds.
|
||||
*/
|
||||
intersectsBounds:function(bounds, inclusive) {
|
||||
if (inclusive == null) {
|
||||
inclusive = true;
|
||||
intersectsBounds:function(bounds, options) {
|
||||
if (typeof options === "boolean") {
|
||||
options = {inclusive: options};
|
||||
}
|
||||
options = options || {};
|
||||
if (options.worldBounds) {
|
||||
var self = this.wrapDateLine(options.worldBounds);
|
||||
bounds = bounds.wrapDateLine(options.worldBounds);
|
||||
} else {
|
||||
self = this;
|
||||
}
|
||||
if (options.inclusive == null) {
|
||||
options.inclusive = true;
|
||||
}
|
||||
var intersects = false;
|
||||
var mightTouch = (
|
||||
this.left == bounds.right ||
|
||||
this.right == bounds.left ||
|
||||
this.top == bounds.bottom ||
|
||||
this.bottom == bounds.top
|
||||
self.left == bounds.right ||
|
||||
self.right == bounds.left ||
|
||||
self.top == bounds.bottom ||
|
||||
self.bottom == bounds.top
|
||||
);
|
||||
|
||||
// if the two bounds only touch at an edge, and inclusive is false,
|
||||
// then the bounds don't *really* intersect.
|
||||
if (inclusive || !mightTouch) {
|
||||
if (options.inclusive || !mightTouch) {
|
||||
// otherwise, if one of the boundaries even partially contains another,
|
||||
// inclusive of the edges, then they do intersect.
|
||||
var inBottom = (
|
||||
((bounds.bottom >= this.bottom) && (bounds.bottom <= this.top)) ||
|
||||
((this.bottom >= bounds.bottom) && (this.bottom <= bounds.top))
|
||||
((bounds.bottom >= self.bottom) && (bounds.bottom <= self.top)) ||
|
||||
((self.bottom >= bounds.bottom) && (self.bottom <= bounds.top))
|
||||
);
|
||||
var inTop = (
|
||||
((bounds.top >= this.bottom) && (bounds.top <= this.top)) ||
|
||||
((this.top > bounds.bottom) && (this.top < bounds.top))
|
||||
((bounds.top >= self.bottom) && (bounds.top <= self.top)) ||
|
||||
((self.top > bounds.bottom) && (self.top < bounds.top))
|
||||
);
|
||||
var inLeft = (
|
||||
((bounds.left >= this.left) && (bounds.left <= this.right)) ||
|
||||
((this.left >= bounds.left) && (this.left <= bounds.right))
|
||||
((bounds.left >= self.left) && (bounds.left <= self.right)) ||
|
||||
((self.left >= bounds.left) && (self.left <= bounds.right))
|
||||
);
|
||||
var inRight = (
|
||||
((bounds.right >= this.left) && (bounds.right <= this.right)) ||
|
||||
((this.right >= bounds.left) && (this.right <= bounds.right))
|
||||
((bounds.right >= self.left) && (bounds.right <= self.right)) ||
|
||||
((self.right >= bounds.left) && (self.right <= bounds.right))
|
||||
);
|
||||
intersects = ((inBottom || inTop) && (inLeft || inRight));
|
||||
}
|
||||
// document me
|
||||
if (options.worldBounds && !intersects) {
|
||||
var world = options.worldBounds;
|
||||
var width = world.getWidth();
|
||||
var selfCrosses = !world.containsBounds(self);
|
||||
var boundsCrosses = !world.containsBounds(bounds);
|
||||
if (selfCrosses && !boundsCrosses) {
|
||||
bounds = bounds.add(-width, 0);
|
||||
intersects = self.intersectsBounds(bounds, {inclusive: options.inclusive});
|
||||
} else if (boundsCrosses && !selfCrosses) {
|
||||
self = self.add(-width, 0);
|
||||
intersects = bounds.intersectsBounds(self, {inclusive: options.inclusive});
|
||||
}
|
||||
}
|
||||
return intersects;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: containsBounds
|
||||
* Determine whether the target bounds is contained within this bounds.
|
||||
* Returns whether the bounds object contains the given <OpenLayers.Bounds>.
|
||||
*
|
||||
* bounds - {<OpenLayers.Bounds>} The target bounds.
|
||||
* partial - {Boolean} If any of the target corners is within this bounds
|
||||
@ -504,10 +620,12 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: determineQuadrant
|
||||
*
|
||||
* Returns the the quadrant ("br", "tr", "tl", "bl") in which the given
|
||||
* <OpenLayers.LonLat> lies.
|
||||
*
|
||||
* Parameters:
|
||||
* lonlat - {<OpenLayers.LonLat>}
|
||||
*
|
||||
*
|
||||
* Returns:
|
||||
* {String} The quadrant ("br" "tr" "tl" "bl") of the bounds in which the
|
||||
* coordinate lies.
|
||||
@ -554,10 +672,13 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: wrapDateLine
|
||||
* Wraps the bounds object around the dateline.
|
||||
*
|
||||
* Parameters:
|
||||
* maxExtent - {<OpenLayers.Bounds>}
|
||||
* options - {Object} Some possible options are:
|
||||
*
|
||||
* Allowed Options:
|
||||
* leftTolerance - {float} Allow for a margin of error
|
||||
* with the 'left' value of this
|
||||
* bound.
|
||||
@ -574,8 +695,9 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
* a different bounds value if this bounds is
|
||||
* *entirely* outside of the maxExtent. If this
|
||||
* bounds straddles the dateline (is part in/part
|
||||
* out of maxExtent), the returned bounds will be
|
||||
* merely a copy of this one.
|
||||
* out of maxExtent), the returned bounds will always
|
||||
* cross the left edge of the given maxExtent.
|
||||
*.
|
||||
*/
|
||||
wrapDateLine: function(maxExtent, options) {
|
||||
options = options || {};
|
||||
@ -586,18 +708,26 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
var newBounds = this.clone();
|
||||
|
||||
if (maxExtent) {
|
||||
var width = maxExtent.getWidth();
|
||||
|
||||
//shift right?
|
||||
while ( newBounds.left < maxExtent.left &&
|
||||
(newBounds.right - rightTolerance) <= maxExtent.left ) {
|
||||
newBounds = newBounds.add(maxExtent.getWidth(), 0);
|
||||
}
|
||||
//shift right?
|
||||
while (newBounds.left < maxExtent.left &&
|
||||
newBounds.right - rightTolerance <= maxExtent.left ) {
|
||||
newBounds = newBounds.add(width, 0);
|
||||
}
|
||||
|
||||
//shift left?
|
||||
while ( (newBounds.left + leftTolerance) >= maxExtent.right &&
|
||||
//shift left?
|
||||
while (newBounds.left + leftTolerance >= maxExtent.right &&
|
||||
newBounds.right > maxExtent.right ) {
|
||||
newBounds = newBounds.add(-maxExtent.getWidth(), 0);
|
||||
}
|
||||
newBounds = newBounds.add(-width, 0);
|
||||
}
|
||||
|
||||
// crosses right only? force left
|
||||
var newLeft = newBounds.left + leftTolerance;
|
||||
if (newLeft < maxExtent.right && newLeft > maxExtent.left &&
|
||||
newBounds.right - rightTolerance > maxExtent.right) {
|
||||
newBounds = newBounds.add(-width, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return newBounds;
|
||||
@ -609,45 +739,63 @@ OpenLayers.Bounds = OpenLayers.Class({
|
||||
/**
|
||||
* APIFunction: fromString
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds from a
|
||||
* parameter string
|
||||
*
|
||||
* parameter string.
|
||||
*
|
||||
* (begin code)
|
||||
* OpenLayers.Bounds.fromString("5,42,10,45");
|
||||
* // => equivalent to ...
|
||||
* new OpenLayers.Bounds(5, 42, 10, 45);
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String}Comma-separated bounds string. (ex. <i>"5,42,10,45"</i>)
|
||||
*
|
||||
* str - {String} Comma-separated bounds string. (e.g. "5,42,10,45")
|
||||
* reverseAxisOrder - {Boolean} Does the string use reverse axis order?
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bounds>} New bounds object built from the
|
||||
* passed-in String.
|
||||
*/
|
||||
OpenLayers.Bounds.fromString = function(str) {
|
||||
OpenLayers.Bounds.fromString = function(str, reverseAxisOrder) {
|
||||
var bounds = str.split(",");
|
||||
return OpenLayers.Bounds.fromArray(bounds);
|
||||
return OpenLayers.Bounds.fromArray(bounds, reverseAxisOrder);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: fromArray
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds
|
||||
* from an array
|
||||
*
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds from an array.
|
||||
*
|
||||
* (begin code)
|
||||
* OpenLayers.Bounds.fromArray( [5, 42, 10, 45] );
|
||||
* // => equivalent to ...
|
||||
* new OpenLayers.Bounds(5, 42, 10, 45);
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* bbox - {Array(Float)} Array of bounds values (ex. <i>[5,42,10,45]</i>)
|
||||
* bbox - {Array(Float)} Array of bounds values (e.g. [5,42,10,45])
|
||||
* reverseAxisOrder - {Boolean} Does the array use reverse axis order?
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bounds>} New bounds object built from the passed-in Array.
|
||||
*/
|
||||
OpenLayers.Bounds.fromArray = function(bbox) {
|
||||
return new OpenLayers.Bounds(parseFloat(bbox[0]),
|
||||
parseFloat(bbox[1]),
|
||||
parseFloat(bbox[2]),
|
||||
parseFloat(bbox[3]));
|
||||
OpenLayers.Bounds.fromArray = function(bbox, reverseAxisOrder) {
|
||||
return reverseAxisOrder === true ?
|
||||
new OpenLayers.Bounds(bbox[1], bbox[0], bbox[3], bbox[2]) :
|
||||
new OpenLayers.Bounds(bbox[0], bbox[1], bbox[2], bbox[3]);
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: fromSize
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds
|
||||
* from a size
|
||||
*
|
||||
* Alternative constructor that builds a new OpenLayers.Bounds from a size.
|
||||
*
|
||||
* (begin code)
|
||||
* OpenLayers.Bounds.fromSize( new OpenLayers.Size(10, 20) );
|
||||
* // => equivalent to ...
|
||||
* new OpenLayers.Bounds(0, 20, 10, 0);
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* size - {<OpenLayers.Size>}
|
||||
* size - {<OpenLayers.Size> or Object} <OpenLayers.Size> or an object with
|
||||
* both 'w' and 'h' properties.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Bounds>} New bounds object built from the passed-in size.
|
||||
@ -663,6 +811,14 @@ OpenLayers.Bounds.fromSize = function(size) {
|
||||
* Function: oppositeQuadrant
|
||||
* Get the opposite quadrant for a given quadrant string.
|
||||
*
|
||||
* (begin code)
|
||||
* OpenLayers.Bounds.oppositeQuadrant( "tl" );
|
||||
* // => "br"
|
||||
*
|
||||
* OpenLayers.Bounds.oppositeQuadrant( "tr" );
|
||||
* // => "bl"
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* quadrant - {String} two character quadrant shortstring
|
||||
*
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/SingleFile.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Class
|
||||
* Base class used to construct all other classes. Includes support for
|
||||
@ -13,104 +17,105 @@
|
||||
* will be removed.
|
||||
*
|
||||
* To create a new OpenLayers-style class, use the following syntax:
|
||||
* > var MyClass = OpenLayers.Class(prototype);
|
||||
* (code)
|
||||
* var MyClass = OpenLayers.Class(prototype);
|
||||
* (end)
|
||||
*
|
||||
* To create a new OpenLayers-style class with multiple inheritance, use the
|
||||
* following syntax:
|
||||
* > var MyClass = OpenLayers.Class(Class1, Class2, prototype);
|
||||
* Note that instanceof reflection will only reveil Class1 as superclass.
|
||||
* Class2 ff are mixins.
|
||||
* (code)
|
||||
* var MyClass = OpenLayers.Class(Class1, Class2, prototype);
|
||||
* (end)
|
||||
*
|
||||
* Note that instanceof reflection will only reveal Class1 as superclass.
|
||||
*
|
||||
*/
|
||||
OpenLayers.Class = function() {
|
||||
var Class = function() {
|
||||
/**
|
||||
* This following condition can be removed at 3.0 - this is only for
|
||||
* backwards compatibility while the Class.inherit method is still
|
||||
* in use. So at 3.0, the following three lines would be replaced with
|
||||
* simply:
|
||||
* this.initialize.apply(this, arguments);
|
||||
*/
|
||||
if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
|
||||
this.initialize.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
var extended = {};
|
||||
var parent, initialize, Type;
|
||||
for(var i=0, len=arguments.length; i<len; ++i) {
|
||||
Type = arguments[i];
|
||||
if(typeof Type == "function") {
|
||||
// make the class passed as the first argument the superclass
|
||||
if(i == 0 && len > 1) {
|
||||
initialize = Type.prototype.initialize;
|
||||
// replace the initialize method with an empty function,
|
||||
// because we do not want to create a real instance here
|
||||
Type.prototype.initialize = function() {};
|
||||
// the line below makes sure that the new class has a
|
||||
// superclass
|
||||
extended = new Type();
|
||||
// restore the original initialize method
|
||||
if(initialize === undefined) {
|
||||
delete Type.prototype.initialize;
|
||||
} else {
|
||||
Type.prototype.initialize = initialize;
|
||||
}
|
||||
}
|
||||
// get the prototype of the superclass
|
||||
parent = Type.prototype;
|
||||
} else {
|
||||
// in this case we're extending with the prototype
|
||||
parent = Type;
|
||||
}
|
||||
OpenLayers.Util.extend(extended, parent);
|
||||
var len = arguments.length;
|
||||
var P = arguments[0];
|
||||
var F = arguments[len-1];
|
||||
|
||||
var C = typeof F.initialize == "function" ?
|
||||
F.initialize :
|
||||
function(){ P.prototype.initialize.apply(this, arguments); };
|
||||
|
||||
if (len > 1) {
|
||||
var newArgs = [C, P].concat(
|
||||
Array.prototype.slice.call(arguments).slice(1, len-1), F);
|
||||
OpenLayers.inherit.apply(null, newArgs);
|
||||
} else {
|
||||
C.prototype = F;
|
||||
}
|
||||
Class.prototype = extended;
|
||||
return Class;
|
||||
return C;
|
||||
};
|
||||
|
||||
/**
|
||||
* Property: isPrototype
|
||||
* *Deprecated*. This is no longer needed and will be removed at 3.0.
|
||||
*/
|
||||
OpenLayers.Class.isPrototype = function () {};
|
||||
|
||||
/**
|
||||
* APIFunction: OpenLayers.create
|
||||
* *Deprecated*. Old method to create an OpenLayers style class. Use the
|
||||
* <OpenLayers.Class> constructor instead.
|
||||
*
|
||||
* Returns:
|
||||
* An OpenLayers class
|
||||
*/
|
||||
OpenLayers.Class.create = function() {
|
||||
return function() {
|
||||
if (arguments && arguments[0] != OpenLayers.Class.isPrototype) {
|
||||
this.initialize.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* APIFunction: inherit
|
||||
* *Deprecated*. Old method to inherit from one or more OpenLayers style
|
||||
* classes. Use the <OpenLayers.Class> constructor instead.
|
||||
* Function: OpenLayers.inherit
|
||||
*
|
||||
* Parameters:
|
||||
* class - One or more classes can be provided as arguments
|
||||
* C - {Object} the class that inherits
|
||||
* P - {Object} the superclass to inherit from
|
||||
*
|
||||
* In addition to the mandatory C and P parameters, an arbitrary number of
|
||||
* objects can be passed, which will extend C.
|
||||
*/
|
||||
OpenLayers.inherit = function(C, P) {
|
||||
var F = function() {};
|
||||
F.prototype = P.prototype;
|
||||
C.prototype = new F;
|
||||
var i, l, o;
|
||||
for(i=2, l=arguments.length; i<l; i++) {
|
||||
o = arguments[i];
|
||||
if(typeof o === "function") {
|
||||
o = o.prototype;
|
||||
}
|
||||
OpenLayers.Util.extend(C.prototype, o);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* APIFunction: extend
|
||||
* Copy all properties of a source object to a destination object. Modifies
|
||||
* the passed in destination object. Any properties on the source object
|
||||
* that are set to undefined will not be (re)set on the destination object.
|
||||
*
|
||||
* Parameters:
|
||||
* destination - {Object} The object that will be modified
|
||||
* source - {Object} The object with properties to be set on the destination
|
||||
*
|
||||
* Returns:
|
||||
* An object prototype
|
||||
* {Object} The destination object.
|
||||
*/
|
||||
OpenLayers.Class.inherit = function () {
|
||||
var superClass = arguments[0];
|
||||
var proto = new superClass(OpenLayers.Class.isPrototype);
|
||||
for (var i=1, len=arguments.length; i<len; i++) {
|
||||
if (typeof arguments[i] == "function") {
|
||||
var mixin = arguments[i];
|
||||
arguments[i] = new mixin(OpenLayers.Class.isPrototype);
|
||||
OpenLayers.Util = OpenLayers.Util || {};
|
||||
OpenLayers.Util.extend = function(destination, source) {
|
||||
destination = destination || {};
|
||||
if (source) {
|
||||
for (var property in source) {
|
||||
var value = source[property];
|
||||
if (value !== undefined) {
|
||||
destination[property] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* IE doesn't include the toString property when iterating over an object's
|
||||
* properties with the for(property in object) syntax. Explicitly check if
|
||||
* the source has its own toString property.
|
||||
*/
|
||||
|
||||
/*
|
||||
* FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
|
||||
* prototype object" when calling hawOwnProperty if the source object
|
||||
* is an instance of window.Event.
|
||||
*/
|
||||
|
||||
var sourceIsEvt = typeof window.Event == "function"
|
||||
&& source instanceof window.Event;
|
||||
|
||||
if (!sourceIsEvt
|
||||
&& source.hasOwnProperty && source.hasOwnProperty("toString")) {
|
||||
destination.toString = source.toString;
|
||||
}
|
||||
OpenLayers.Util.extend(proto, arguments[i]);
|
||||
}
|
||||
return proto;
|
||||
return destination;
|
||||
};
|
||||
|
||||
123
js/openlayers/src/openlayers/lib/OpenLayers/BaseTypes/Date.js
Normal file
@ -0,0 +1,123 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/SingleFile.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Date
|
||||
* Contains implementations of Date.parse and date.toISOString that match the
|
||||
* ECMAScript 5 specification for parsing RFC 3339 dates.
|
||||
* http://tools.ietf.org/html/rfc3339
|
||||
*/
|
||||
OpenLayers.Date = {
|
||||
|
||||
/**
|
||||
* APIProperty: dateRegEx
|
||||
* The regex to be used for validating dates. You can provide your own
|
||||
* regex for instance for adding support for years before BC. Default
|
||||
* value is: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/
|
||||
*/
|
||||
dateRegEx: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/,
|
||||
|
||||
/**
|
||||
* APIMethod: toISOString
|
||||
* Generates a string representing a date. The format of the string follows
|
||||
* the profile of ISO 8601 for date and time on the Internet (see
|
||||
* http://tools.ietf.org/html/rfc3339). If the toISOString method is
|
||||
* available on the Date prototype, that is used. The toISOString
|
||||
* method for Date instances is defined in ECMA-262.
|
||||
*
|
||||
* Parameters:
|
||||
* date - {Date} A date object.
|
||||
*
|
||||
* Returns:
|
||||
* {String} A string representing the date (e.g.
|
||||
* "2010-08-07T16:58:23.123Z"). If the date does not have a valid time
|
||||
* (i.e. isNaN(date.getTime())) this method returns the string "Invalid
|
||||
* Date". The ECMA standard says the toISOString method should throw
|
||||
* RangeError in this case, but Firefox returns a string instead. For
|
||||
* best results, use isNaN(date.getTime()) to determine date validity
|
||||
* before generating date strings.
|
||||
*/
|
||||
toISOString: (function() {
|
||||
if ("toISOString" in Date.prototype) {
|
||||
return function(date) {
|
||||
return date.toISOString();
|
||||
};
|
||||
} else {
|
||||
return function(date) {
|
||||
var str;
|
||||
if (isNaN(date.getTime())) {
|
||||
// ECMA-262 says throw RangeError, Firefox returns
|
||||
// "Invalid Date"
|
||||
str = "Invalid Date";
|
||||
} else {
|
||||
str =
|
||||
date.getUTCFullYear() + "-" +
|
||||
OpenLayers.Number.zeroPad(date.getUTCMonth() + 1, 2) + "-" +
|
||||
OpenLayers.Number.zeroPad(date.getUTCDate(), 2) + "T" +
|
||||
OpenLayers.Number.zeroPad(date.getUTCHours(), 2) + ":" +
|
||||
OpenLayers.Number.zeroPad(date.getUTCMinutes(), 2) + ":" +
|
||||
OpenLayers.Number.zeroPad(date.getUTCSeconds(), 2) + "." +
|
||||
OpenLayers.Number.zeroPad(date.getUTCMilliseconds(), 3) + "Z";
|
||||
}
|
||||
return str;
|
||||
};
|
||||
}
|
||||
|
||||
})(),
|
||||
|
||||
/**
|
||||
* APIMethod: parse
|
||||
* Generate a date object from a string. The format for the string follows
|
||||
* the profile of ISO 8601 for date and time on the Internet (see
|
||||
* http://tools.ietf.org/html/rfc3339). We don't call the native
|
||||
* Date.parse because of inconsistency between implmentations. In
|
||||
* Chrome, calling Date.parse with a string that doesn't contain any
|
||||
* indication of the timezone (e.g. "2011"), the date is interpreted
|
||||
* in local time. On Firefox, the assumption is UTC.
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} A string representing the date (e.g.
|
||||
* "2010", "2010-08", "2010-08-07", "2010-08-07T16:58:23.123Z",
|
||||
* "2010-08-07T11:58:23.123-06").
|
||||
*
|
||||
* Returns:
|
||||
* {Date} A date object. If the string could not be parsed, an invalid
|
||||
* date is returned (i.e. isNaN(date.getTime())).
|
||||
*/
|
||||
parse: function(str) {
|
||||
var date;
|
||||
var match = str.match(this.dateRegEx);
|
||||
if (match && (match[1] || match[7])) { // must have at least year or time
|
||||
var year = parseInt(match[1], 10) || 0;
|
||||
var month = (parseInt(match[2], 10) - 1) || 0;
|
||||
var day = parseInt(match[3], 10) || 1;
|
||||
date = new Date(Date.UTC(year, month, day));
|
||||
// optional time
|
||||
var type = match[7];
|
||||
if (type) {
|
||||
var hours = parseInt(match[4], 10);
|
||||
var minutes = parseInt(match[5], 10);
|
||||
var secFrac = parseFloat(match[6]);
|
||||
var seconds = secFrac | 0;
|
||||
var milliseconds = Math.round(1000 * (secFrac - seconds));
|
||||
date.setUTCHours(hours, minutes, seconds, milliseconds);
|
||||
// check offset
|
||||
if (type !== "Z") {
|
||||
var hoursOffset = parseInt(type, 10);
|
||||
var minutesOffset = parseInt(match[8], 10) || 0;
|
||||
var offset = -1000 * (60 * (hoursOffset * 60) + minutesOffset * 60);
|
||||
date = new Date(date.getTime() + offset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
date = new Date("invalid");
|
||||
}
|
||||
return date;
|
||||
}
|
||||
};
|
||||
@ -1,8 +1,13 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/BaseTypes.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Element
|
||||
*/
|
||||
@ -31,42 +36,9 @@ OpenLayers.Element = {
|
||||
toggle: function() {
|
||||
for (var i=0, len=arguments.length; i<len; i++) {
|
||||
var element = OpenLayers.Util.getElement(arguments[i]);
|
||||
var display = OpenLayers.Element.visible(element) ? 'hide'
|
||||
: 'show';
|
||||
OpenLayers.Element[display](element);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIFunction: hide
|
||||
* Hide element(s) passed in
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} Actually user can pass any number of elements
|
||||
*/
|
||||
hide: function() {
|
||||
for (var i=0, len=arguments.length; i<len; i++) {
|
||||
var element = OpenLayers.Util.getElement(arguments[i]);
|
||||
if (element) {
|
||||
element.style.display = 'none';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: show
|
||||
* Show element(s) passed in
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} Actually user can pass any number of elements
|
||||
*/
|
||||
show: function() {
|
||||
for (var i=0, len=arguments.length; i<len; i++) {
|
||||
var element = OpenLayers.Util.getElement(arguments[i]);
|
||||
if (element) {
|
||||
element.style.display = '';
|
||||
}
|
||||
var display = OpenLayers.Element.visible(element) ? 'none'
|
||||
: '';
|
||||
element.style.display = display;
|
||||
}
|
||||
},
|
||||
|
||||
@ -96,40 +68,6 @@ OpenLayers.Element = {
|
||||
return element.offsetHeight;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIFunction: getDimensions
|
||||
* *Deprecated*. Returns dimensions of the element passed in.
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
*
|
||||
* Returns:
|
||||
* {Object} Object with 'width' and 'height' properties which are the
|
||||
* dimensions of the element passed in.
|
||||
*/
|
||||
getDimensions: function(element) {
|
||||
element = OpenLayers.Util.getElement(element);
|
||||
if (OpenLayers.Element.getStyle(element, 'display') != 'none') {
|
||||
return {width: element.offsetWidth, height: element.offsetHeight};
|
||||
}
|
||||
|
||||
// All *Width and *Height properties give 0 on elements with display none,
|
||||
// so enable the element temporarily
|
||||
var els = element.style;
|
||||
var originalVisibility = els.visibility;
|
||||
var originalPosition = els.position;
|
||||
var originalDisplay = els.display;
|
||||
els.visibility = 'hidden';
|
||||
els.position = 'absolute';
|
||||
els.display = '';
|
||||
var originalWidth = element.clientWidth;
|
||||
var originalHeight = element.clientHeight;
|
||||
els.display = originalDisplay;
|
||||
els.position = originalPosition;
|
||||
els.visibility = originalVisibility;
|
||||
return {width: originalWidth, height: originalHeight};
|
||||
},
|
||||
|
||||
/**
|
||||
* Function: hasClass
|
||||
* Tests if an element has the given CSS class name.
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Console.js
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -27,17 +27,25 @@ OpenLayers.LonLat = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.LonLat
|
||||
* Create a new map location.
|
||||
* Create a new map location. Coordinates can be passed either as two
|
||||
* arguments, or as a single argument.
|
||||
*
|
||||
* Parameters:
|
||||
* Parameters (two arguments):
|
||||
* lon - {Number} The x-axis coordinate in map units. If your map is in
|
||||
* a geographic projection, this will be the Longitude. Otherwise,
|
||||
* it will be the x coordinate of the map location in your map units.
|
||||
* lat - {Number} The y-axis coordinate in map units. If your map is in
|
||||
* a geographic projection, this will be the Latitude. Otherwise,
|
||||
* it will be the y coordinate of the map location in your map units.
|
||||
*
|
||||
* Parameters (single argument):
|
||||
* location - {Array(Float)} [lon, lat]
|
||||
*/
|
||||
initialize: function(lon, lat) {
|
||||
if (OpenLayers.Util.isArray(lon)) {
|
||||
lat = lon[1];
|
||||
lon = lon[0];
|
||||
}
|
||||
this.lon = OpenLayers.Util.toFloat(lon);
|
||||
this.lat = OpenLayers.Util.toFloat(lat);
|
||||
},
|
||||
@ -48,7 +56,7 @@ OpenLayers.LonLat = OpenLayers.Class({
|
||||
*
|
||||
* Returns:
|
||||
* {String} String representation of OpenLayers.LonLat object.
|
||||
* (ex. <i>"lon=5,lat=42"</i>)
|
||||
* (e.g. <i>"lon=5,lat=42"</i>)
|
||||
*/
|
||||
toString:function() {
|
||||
return ("lon=" + this.lon + ",lat=" + this.lat);
|
||||
@ -59,7 +67,7 @@ OpenLayers.LonLat = OpenLayers.Class({
|
||||
*
|
||||
* Returns:
|
||||
* {String} Shortened String representation of OpenLayers.LonLat object.
|
||||
* (ex. <i>"5, 42"</i>)
|
||||
* (e.g. <i>"5, 42"</i>)
|
||||
*/
|
||||
toShortString:function() {
|
||||
return (this.lon + ", " + this.lat);
|
||||
@ -89,9 +97,7 @@ OpenLayers.LonLat = OpenLayers.Class({
|
||||
*/
|
||||
add:function(lon, lat) {
|
||||
if ( (lon == null) || (lat == null) ) {
|
||||
var msg = OpenLayers.i18n("lonlatAddError");
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
throw new TypeError('LonLat.add cannot receive null values');
|
||||
}
|
||||
return new OpenLayers.LonLat(this.lon + OpenLayers.Util.toFloat(lon),
|
||||
this.lat + OpenLayers.Util.toFloat(lat));
|
||||
@ -178,7 +184,7 @@ OpenLayers.LonLat = OpenLayers.Class({
|
||||
*
|
||||
* Parameters:
|
||||
* str - {String} Comma-separated Lon,Lat coordinate string.
|
||||
* (ex. <i>"5,40"</i>)
|
||||
* (e.g. <i>"5,40"</i>)
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.LonLat>} New <OpenLayers.LonLat> object built from the
|
||||
@ -188,3 +194,22 @@ OpenLayers.LonLat.fromString = function(str) {
|
||||
var pair = str.split(",");
|
||||
return new OpenLayers.LonLat(pair[0], pair[1]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function: fromArray
|
||||
* Alternative constructor that builds a new <OpenLayers.LonLat> from an
|
||||
* array of two numbers that represent lon- and lat-values.
|
||||
*
|
||||
* Parameters:
|
||||
* arr - {Array(Float)} Array of lon/lat values (e.g. [5,-42])
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.LonLat>} New <OpenLayers.LonLat> object built from the
|
||||
* passed-in array.
|
||||
*/
|
||||
OpenLayers.LonLat.fromArray = function(arr) {
|
||||
var gotArr = OpenLayers.Util.isArray(arr),
|
||||
lon = gotArr && arr[0],
|
||||
lat = gotArr && arr[1];
|
||||
return new OpenLayers.LonLat(lon, lat);
|
||||
};
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Console.js
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -68,7 +68,8 @@ OpenLayers.Pixel = OpenLayers.Class({
|
||||
* Determine whether one pixel is equivalent to another
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
* px - {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with
|
||||
* a 'x' and 'y' properties.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The point passed in as parameter is equal to this. Note that
|
||||
@ -83,6 +84,24 @@ OpenLayers.Pixel = OpenLayers.Class({
|
||||
return equals;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: distanceTo
|
||||
* Returns the distance to the pixel point passed in as a parameter.
|
||||
*
|
||||
* Parameters:
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
*
|
||||
* Returns:
|
||||
* {Float} The pixel point passed in as parameter to calculate the
|
||||
* distance to.
|
||||
*/
|
||||
distanceTo:function(px) {
|
||||
return Math.sqrt(
|
||||
Math.pow(this.x - px.x, 2) +
|
||||
Math.pow(this.y - px.y, 2)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: add
|
||||
*
|
||||
@ -96,9 +115,7 @@ OpenLayers.Pixel = OpenLayers.Class({
|
||||
*/
|
||||
add:function(x, y) {
|
||||
if ( (x == null) || (y == null) ) {
|
||||
var msg = OpenLayers.i18n("pixelAddError");
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
throw new TypeError('Pixel.add cannot receive null values');
|
||||
}
|
||||
return new OpenLayers.Pixel(this.x + x, this.y + y);
|
||||
},
|
||||
@ -107,7 +124,8 @@ OpenLayers.Pixel = OpenLayers.Class({
|
||||
* APIMethod: offset
|
||||
*
|
||||
* Parameters
|
||||
* px - {<OpenLayers.Pixel>}
|
||||
* px - {<OpenLayers.Pixel>|Object} An OpenLayers.Pixel or an object with
|
||||
* a 'x' and 'y' properties.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Pixel>} A new Pixel with this pixel's x&y augmented by the
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Size
|
||||
* Instances of this class represent a width/height pair
|
||||
@ -41,7 +45,7 @@ OpenLayers.Size = OpenLayers.Class({
|
||||
*
|
||||
* Returns:
|
||||
* {String} The string representation of OpenLayers.Size object.
|
||||
* (ex. <i>"w=55,h=66"</i>)
|
||||
* (e.g. <i>"w=55,h=66"</i>)
|
||||
*/
|
||||
toString:function() {
|
||||
return ("w=" + this.w + ",h=" + this.h);
|
||||
@ -65,12 +69,12 @@ OpenLayers.Size = OpenLayers.Class({
|
||||
* Determine where this size is equal to another
|
||||
*
|
||||
* Parameters:
|
||||
* sz - {<OpenLayers.Size>}
|
||||
* sz - {<OpenLayers.Size>|Object} An OpenLayers.Size or an object with
|
||||
* a 'w' and 'h' properties.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The passed in size has the same h and w properties as this one.
|
||||
* Note that if sz passed in is null, returns false.
|
||||
*
|
||||
*/
|
||||
equals:function(sz) {
|
||||
var equals = false;
|
||||
|
||||
@ -1,8 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Namespace: OpenLayers.Console
|
||||
* The OpenLayers.Console namespace is used for debugging and error logging.
|
||||
@ -97,7 +101,7 @@ OpenLayers.Console = {
|
||||
* Expects a single error message
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object}
|
||||
* error - {Object}
|
||||
*/
|
||||
userError: function(error) {
|
||||
alert(error);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Console.js
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -22,7 +22,6 @@
|
||||
* > var map = new OpenLayers.Map('map', { controls: [] });
|
||||
* >
|
||||
* > map.addControl(new OpenLayers.Control.PanZoomBar());
|
||||
* > map.addControl(new OpenLayers.Control.MouseToolbar());
|
||||
* > map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));
|
||||
* > map.addControl(new OpenLayers.Control.Permalink());
|
||||
* > map.addControl(new OpenLayers.Control.Permalink('permalink'));
|
||||
@ -70,13 +69,14 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
map: null,
|
||||
|
||||
/**
|
||||
* Property: div
|
||||
* {DOMElement}
|
||||
* APIProperty: div
|
||||
* {DOMElement} The element that contains the control, if not present the
|
||||
* control is placed inside the map.
|
||||
*/
|
||||
div: null,
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* APIProperty: type
|
||||
* {Number} Controls can have a 'type'. The type determines the type of
|
||||
* interactions which are possible with them when they are placed in an
|
||||
* <OpenLayers.Control.Panel>.
|
||||
@ -85,7 +85,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Property: allowSelection
|
||||
* {Boolean} By deafault, controls do not allow selection, because
|
||||
* {Boolean} By default, controls do not allow selection, because
|
||||
* it may interfere with map dragging. If this is true, OpenLayers
|
||||
* will not prevent selection of the control.
|
||||
* Default is false.
|
||||
@ -100,7 +100,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
displayClass: "",
|
||||
|
||||
/**
|
||||
* Property: title
|
||||
* APIProperty: title
|
||||
* {string} This property is used for showing a tooltip over the
|
||||
* Control.
|
||||
*/
|
||||
@ -114,11 +114,18 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
autoActivate: false,
|
||||
|
||||
/**
|
||||
* Property: active
|
||||
* {Boolean} The control is active.
|
||||
* APIProperty: active
|
||||
* {Boolean} The control is active (read-only). Use <activate> and
|
||||
* <deactivate> to change control state.
|
||||
*/
|
||||
active: null,
|
||||
|
||||
/**
|
||||
* Property: handlerOptions
|
||||
* {Object} Used to set non-default properties on the control's handler
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* Property: handler
|
||||
* {<OpenLayers.Handler>} null
|
||||
@ -135,16 +142,11 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
eventListeners: null,
|
||||
|
||||
/**
|
||||
* Property: events
|
||||
* {<OpenLayers.Events>} Events instance for triggering control specific
|
||||
* events.
|
||||
*/
|
||||
events: null,
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
* {Array(String)} Supported application event types. Register a listener
|
||||
* for a particular event with the following syntax:
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
@ -162,7 +164,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
* activate - Triggered when activated.
|
||||
* deactivate - Triggered when deactivated.
|
||||
*/
|
||||
EVENT_TYPES: ["activate", "deactivate"],
|
||||
events: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control
|
||||
@ -184,7 +186,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
|
||||
OpenLayers.Util.extend(this, options);
|
||||
|
||||
this.events = new OpenLayers.Events(this, null, this.EVENT_TYPES);
|
||||
this.events = new OpenLayers.Events(this);
|
||||
if(this.eventListeners instanceof Object) {
|
||||
this.events.on(this.eventListeners);
|
||||
}
|
||||
@ -227,6 +229,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
this.map.removeControl(this);
|
||||
this.map = null;
|
||||
}
|
||||
this.div = null;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -295,7 +298,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: activate
|
||||
* APIMethod: activate
|
||||
* Explicitly activates a control and it's associated
|
||||
* handler if one has been set. Controls can be
|
||||
* deactivated by calling the deactivate() method.
|
||||
@ -323,7 +326,7 @@ OpenLayers.Control = OpenLayers.Class({
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: deactivate
|
||||
* APIMethod: deactivate
|
||||
* Deactivates a control and it's associated handler if any. The exact
|
||||
* effect of this depends on the control itself.
|
||||
*
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.ArgParser
|
||||
* The ArgParser control adds location bar querystring parsing functionality
|
||||
* The ArgParser control adds location bar query string parsing functionality
|
||||
* to an OpenLayers Map.
|
||||
* When added to a Map control, on a page load/refresh, the Map will
|
||||
* automatically take the href string and parse it for lon, lat, zoom, and
|
||||
@ -22,20 +22,21 @@
|
||||
OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Parameter: center
|
||||
* Property: center
|
||||
* {<OpenLayers.LonLat>}
|
||||
*/
|
||||
center: null,
|
||||
|
||||
/**
|
||||
* Parameter: zoom
|
||||
* Property: zoom
|
||||
* {int}
|
||||
*/
|
||||
zoom: null,
|
||||
|
||||
/**
|
||||
* Parameter: layers
|
||||
* {Array(<OpenLayers.Layer>)}
|
||||
* Property: layers
|
||||
* {String} Each character represents the state of the corresponding layer
|
||||
* on the map.
|
||||
*/
|
||||
layers: null,
|
||||
|
||||
@ -43,7 +44,6 @@ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIProperty: displayProjection
|
||||
* {<OpenLayers.Projection>} Requires proj4js support.
|
||||
* Projection used when reading the coordinates from the URL. This will
|
||||
*
|
||||
* reproject the map coordinates from the URL into the map's
|
||||
* projection.
|
||||
*
|
||||
@ -60,10 +60,26 @@ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Parameters:
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getParameters
|
||||
*/
|
||||
getParameters: function(url) {
|
||||
url = url || window.location.href;
|
||||
var parameters = OpenLayers.Util.getParameters(url);
|
||||
|
||||
// If we have an anchor in the url use it to split the url
|
||||
var index = url.indexOf('#');
|
||||
if (index > 0) {
|
||||
// create an url to parse on the getParameters
|
||||
url = '?' + url.substring(index + 1, url.length);
|
||||
|
||||
OpenLayers.Util.extend(parameters,
|
||||
OpenLayers.Util.getParameters(url));
|
||||
}
|
||||
return parameters;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setMap
|
||||
* Set the map property for the control.
|
||||
@ -92,7 +108,7 @@ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
if (i == this.map.controls.length) {
|
||||
|
||||
var args = OpenLayers.Util.getParameters();
|
||||
var args = this.getParameters();
|
||||
// Be careful to set layer first, to not trigger unnecessary layer loads
|
||||
if (args.layers) {
|
||||
this.layers = args.layers;
|
||||
@ -106,7 +122,7 @@ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.center = new OpenLayers.LonLat(parseFloat(args.lon),
|
||||
parseFloat(args.lat));
|
||||
if (args.zoom) {
|
||||
this.zoom = parseInt(args.zoom);
|
||||
this.zoom = parseFloat(args.zoom);
|
||||
}
|
||||
|
||||
// when we add a new baselayer to see when we can set the center
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -19,20 +19,25 @@ OpenLayers.Control.Attribution =
|
||||
OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: seperator
|
||||
* {String} String used to seperate layers.
|
||||
* APIProperty: separator
|
||||
* {String} String used to separate layers.
|
||||
*/
|
||||
separator: ", ",
|
||||
|
||||
/**
|
||||
* APIProperty: template
|
||||
* {String} Template for the attribution. This has to include the substring
|
||||
* "${layers}", which will be replaced by the layer specific
|
||||
* attributions, separated by <separator>. The default is "${layers}".
|
||||
*/
|
||||
template: "${layers}",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.Attribution
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Options for control.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
@ -89,7 +94,9 @@ OpenLayers.Control.Attribution =
|
||||
}
|
||||
}
|
||||
}
|
||||
this.div.innerHTML = attributions.join(this.separator);
|
||||
this.div.innerHTML = OpenLayers.String.format(this.template, {
|
||||
layers: attributions.join(this.separator)
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
|
||||
156
js/openlayers/src/openlayers/lib/OpenLayers/Control/CacheRead.js
Normal file
@ -0,0 +1,156 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.CacheRead
|
||||
* A control for using image tiles cached with <OpenLayers.Control.CacheWrite>
|
||||
* from the browser's local storage.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.CacheRead = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: fetchEvent
|
||||
* {String} The layer event to listen to for replacing remote resource tile
|
||||
* URLs with cached data URIs. Supported values are "tileerror" (try
|
||||
* remote first, fall back to cached) and "tileloadstart" (try cache
|
||||
* first, fall back to remote). Default is "tileloadstart".
|
||||
*
|
||||
* Note that "tileerror" will not work for CORS enabled images (see
|
||||
* https://developer.mozilla.org/en/CORS_Enabled_Image), i.e. layers
|
||||
* configured with a <OpenLayers.Tile.Image.crossOriginKeyword> in
|
||||
* <OpenLayers.Layer.Grid.tileOptions>.
|
||||
*/
|
||||
fetchEvent: "tileloadstart",
|
||||
|
||||
/**
|
||||
* APIProperty: layers
|
||||
* {Array(<OpenLayers.Layer.Grid>)}. Optional. If provided, only these
|
||||
* layers will receive tiles from the cache.
|
||||
*/
|
||||
layers: null,
|
||||
|
||||
/**
|
||||
* APIProperty: autoActivate
|
||||
* {Boolean} Activate the control when it is added to a map. Default is
|
||||
* true.
|
||||
*/
|
||||
autoActivate: true,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.CacheRead
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Object with API properties for this control
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method: setMap
|
||||
* Set the map property for the control.
|
||||
*
|
||||
* Parameters:
|
||||
* map - {<OpenLayers.Map>}
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
var i, layers = this.layers || map.layers;
|
||||
for (i=layers.length-1; i>=0; --i) {
|
||||
this.addLayer({layer: layers[i]});
|
||||
}
|
||||
if (!this.layers) {
|
||||
map.events.on({
|
||||
addlayer: this.addLayer,
|
||||
removeLayer: this.removeLayer,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addLayer
|
||||
* Adds a layer to the control. Once added, tiles requested for this layer
|
||||
* will be cached.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object} Object with a layer property referencing an
|
||||
* <OpenLayers.Layer> instance
|
||||
*/
|
||||
addLayer: function(evt) {
|
||||
evt.layer.events.register(this.fetchEvent, this, this.fetch);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: removeLayer
|
||||
* Removes a layer from the control. Once removed, tiles requested for this
|
||||
* layer will no longer be cached.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object} Object with a layer property referencing an
|
||||
* <OpenLayers.Layer> instance
|
||||
*/
|
||||
removeLayer: function(evt) {
|
||||
evt.layer.events.unregister(this.fetchEvent, this, this.fetch);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: fetch
|
||||
* Listener to the <fetchEvent> event. Replaces a tile's url with a data
|
||||
* URI from the cache.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object} Event object with a tile property.
|
||||
*/
|
||||
fetch: function(evt) {
|
||||
if (this.active && window.localStorage &&
|
||||
evt.tile instanceof OpenLayers.Tile.Image) {
|
||||
var tile = evt.tile,
|
||||
url = tile.url;
|
||||
// deal with modified tile urls when both CacheWrite and CacheRead
|
||||
// are active
|
||||
if (!tile.layer.crossOriginKeyword && OpenLayers.ProxyHost &&
|
||||
url.indexOf(OpenLayers.ProxyHost) === 0) {
|
||||
url = OpenLayers.Control.CacheWrite.urlMap[url];
|
||||
}
|
||||
var dataURI = window.localStorage.getItem("olCache_" + url);
|
||||
if (dataURI) {
|
||||
tile.url = dataURI;
|
||||
if (evt.type === "tileerror") {
|
||||
tile.setImgSrc(dataURI);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
* The destroy method is used to perform any clean up before the control
|
||||
* is dereferenced. Typically this is where event listeners are removed
|
||||
* to prevent memory leaks.
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.layers || this.map) {
|
||||
var i, layers = this.layers || this.map.layers;
|
||||
for (i=layers.length-1; i>=0; --i) {
|
||||
this.removeLayer({layer: layers[i]});
|
||||
}
|
||||
}
|
||||
if (this.map) {
|
||||
this.map.events.un({
|
||||
addlayer: this.addLayer,
|
||||
removeLayer: this.removeLayer,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.CacheRead"
|
||||
});
|
||||
@ -0,0 +1,257 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Request.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.CacheWrite
|
||||
* A control for caching image tiles in the browser's local storage. The
|
||||
* <OpenLayers.Control.CacheRead> control is used to fetch and use the cached
|
||||
* tile images.
|
||||
*
|
||||
* Note: Before using this control on any layer that is not your own, make sure
|
||||
* that the terms of service of the tile provider allow local storage of tiles.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.CacheWrite = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* To register events in the constructor, configure <eventListeners>.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* cachefull - Triggered when the cache is full. Listeners receive an
|
||||
* object with a tile property as first argument. The tile references
|
||||
* the tile that couldn't be cached.
|
||||
*/
|
||||
|
||||
/**
|
||||
* APIProperty: eventListeners
|
||||
* {Object} Object with event listeners, keyed by event name. An optional
|
||||
* scope property defines the scope that listeners will be executed in.
|
||||
*/
|
||||
|
||||
/**
|
||||
* APIProperty: layers
|
||||
* {Array(<OpenLayers.Layer.Grid>)}. Optional. If provided, caching
|
||||
* will be enabled for these layers only, otherwise for all cacheable
|
||||
* layers.
|
||||
*/
|
||||
layers: null,
|
||||
|
||||
/**
|
||||
* APIProperty: imageFormat
|
||||
* {String} The image format used for caching. The default is "image/png".
|
||||
* Supported formats depend on the user agent. If an unsupported
|
||||
* <imageFormat> is provided, "image/png" will be used. For aerial
|
||||
* imagery, "image/jpeg" is recommended.
|
||||
*/
|
||||
imageFormat: "image/png",
|
||||
|
||||
/**
|
||||
* Property: quotaRegEx
|
||||
* {RegExp}
|
||||
*/
|
||||
quotaRegEx: (/quota/i),
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.CacheWrite
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Object with API properties for this control.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method: setMap
|
||||
* Set the map property for the control.
|
||||
*
|
||||
* Parameters:
|
||||
* map - {<OpenLayers.Map>}
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
var i, layers = this.layers || map.layers;
|
||||
for (i=layers.length-1; i>=0; --i) {
|
||||
this.addLayer({layer: layers[i]});
|
||||
}
|
||||
if (!this.layers) {
|
||||
map.events.on({
|
||||
addlayer: this.addLayer,
|
||||
removeLayer: this.removeLayer,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addLayer
|
||||
* Adds a layer to the control. Once added, tiles requested for this layer
|
||||
* will be cached.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object} Object with a layer property referencing an
|
||||
* <OpenLayers.Layer> instance
|
||||
*/
|
||||
addLayer: function(evt) {
|
||||
evt.layer.events.on({
|
||||
tileloadstart: this.makeSameOrigin,
|
||||
tileloaded: this.onTileLoaded,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: removeLayer
|
||||
* Removes a layer from the control. Once removed, tiles requested for this
|
||||
* layer will no longer be cached.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object} Object with a layer property referencing an
|
||||
* <OpenLayers.Layer> instance
|
||||
*/
|
||||
removeLayer: function(evt) {
|
||||
evt.layer.events.un({
|
||||
tileloadstart: this.makeSameOrigin,
|
||||
tileloaded: this.onTileLoaded,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: makeSameOrigin
|
||||
* If the tile does not have CORS image loading enabled and is from a
|
||||
* different origin, use OpenLayers.ProxyHost to make it a same origin url.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
makeSameOrigin: function(evt) {
|
||||
if (this.active) {
|
||||
var tile = evt.tile;
|
||||
if (tile instanceof OpenLayers.Tile.Image &&
|
||||
!tile.crossOriginKeyword &&
|
||||
tile.url.substr(0, 5) !== "data:") {
|
||||
var sameOriginUrl = OpenLayers.Request.makeSameOrigin(
|
||||
tile.url, OpenLayers.ProxyHost
|
||||
);
|
||||
OpenLayers.Control.CacheWrite.urlMap[sameOriginUrl] = tile.url;
|
||||
tile.url = sameOriginUrl;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onTileLoaded
|
||||
* Decides whether a tile can be cached and calls the cache method.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
onTileLoaded: function(evt) {
|
||||
if (this.active && !evt.aborted &&
|
||||
evt.tile instanceof OpenLayers.Tile.Image &&
|
||||
evt.tile.url.substr(0, 5) !== 'data:') {
|
||||
this.cache({tile: evt.tile});
|
||||
delete OpenLayers.Control.CacheWrite.urlMap[evt.tile.url];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: cache
|
||||
* Adds a tile to the cache. When the cache is full, the "cachefull" event
|
||||
* is triggered.
|
||||
*
|
||||
* Parameters:
|
||||
* obj - {Object} Object with a tile property, tile being the
|
||||
* <OpenLayers.Tile.Image> with the data to add to the cache
|
||||
*/
|
||||
cache: function(obj) {
|
||||
if (window.localStorage) {
|
||||
var tile = obj.tile;
|
||||
try {
|
||||
var canvasContext = tile.getCanvasContext();
|
||||
if (canvasContext) {
|
||||
var urlMap = OpenLayers.Control.CacheWrite.urlMap;
|
||||
var url = urlMap[tile.url] || tile.url;
|
||||
window.localStorage.setItem(
|
||||
"olCache_" + url,
|
||||
canvasContext.canvas.toDataURL(this.imageFormat)
|
||||
);
|
||||
}
|
||||
} catch(e) {
|
||||
// local storage full or CORS violation
|
||||
var reason = e.name || e.message;
|
||||
if (reason && this.quotaRegEx.test(reason)) {
|
||||
this.events.triggerEvent("cachefull", {tile: tile});
|
||||
} else {
|
||||
OpenLayers.Console.error(e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
* The destroy method is used to perform any clean up before the control
|
||||
* is dereferenced. Typically this is where event listeners are removed
|
||||
* to prevent memory leaks.
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.layers || this.map) {
|
||||
var i, layers = this.layers || this.map.layers;
|
||||
for (i=layers.length-1; i>=0; --i) {
|
||||
this.removeLayer({layer: layers[i]});
|
||||
}
|
||||
}
|
||||
if (this.map) {
|
||||
this.map.events.un({
|
||||
addlayer: this.addLayer,
|
||||
removeLayer: this.removeLayer,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.CacheWrite"
|
||||
});
|
||||
|
||||
/**
|
||||
* APIFunction: OpenLayers.Control.CacheWrite.clearCache
|
||||
* Clears all tiles cached with <OpenLayers.Control.CacheWrite> from the cache.
|
||||
*/
|
||||
OpenLayers.Control.CacheWrite.clearCache = function() {
|
||||
if (!window.localStorage) { return; }
|
||||
var i, key;
|
||||
for (i=window.localStorage.length-1; i>=0; --i) {
|
||||
key = window.localStorage.key(i);
|
||||
if (key.substr(0, 8) === "olCache_") {
|
||||
window.localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Property: OpenLayers.Control.CacheWrite.urlMap
|
||||
* {Object} Mapping of same origin urls to cache url keys. Entries will be
|
||||
* deleted as soon as a tile was cached.
|
||||
*/
|
||||
OpenLayers.Control.CacheWrite.urlMap = {};
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -65,6 +65,28 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
onComplete: function(feature, pixel) {},
|
||||
|
||||
/**
|
||||
* APIProperty: onEnter
|
||||
* {Function} Define this function if you want to know when the mouse
|
||||
* goes over a feature and thereby makes this feature a candidate
|
||||
* for dragging.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>} The feature that is ready
|
||||
* to be dragged.
|
||||
*/
|
||||
onEnter: function(feature) {},
|
||||
|
||||
/**
|
||||
* APIProperty: onLeave
|
||||
* {Function} Define this function if you want to know when the mouse
|
||||
* goes out of the feature that was dragged.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>} The feature that was dragged.
|
||||
*/
|
||||
onLeave: function(feature) {},
|
||||
|
||||
/**
|
||||
* APIProperty: documentDrag
|
||||
* {Boolean} If set to true, mouse dragging will continue even if the
|
||||
@ -129,6 +151,10 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
),
|
||||
feature: new OpenLayers.Handler.Feature(
|
||||
this, this.layer, OpenLayers.Util.extend({
|
||||
// 'click' and 'clickout' callback are for the mobile
|
||||
// support: no 'over' or 'out' in touch based browsers.
|
||||
click: this.clickFeature,
|
||||
clickout: this.clickoutFeature,
|
||||
over: this.overFeature,
|
||||
out: this.outFeature
|
||||
}, this.featureCallbacks),
|
||||
@ -136,7 +162,36 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
)
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: clickFeature
|
||||
* Called when the feature handler detects a click-in on a feature.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>}
|
||||
*/
|
||||
clickFeature: function(feature) {
|
||||
if (this.handlers.feature.touch && !this.over && this.overFeature(feature)) {
|
||||
this.handlers.drag.dragstart(this.handlers.feature.evt);
|
||||
// to let the events propagate to the feature handler (click callback)
|
||||
this.handlers.drag.stopDown = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: clickoutFeature
|
||||
* Called when the feature handler detects a click-out on a feature.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>}
|
||||
*/
|
||||
clickoutFeature: function(feature) {
|
||||
if (this.handlers.feature.touch && this.over) {
|
||||
this.outFeature(feature);
|
||||
this.handlers.drag.stopDown = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* Take care of things that are not handled in superclass
|
||||
@ -185,13 +240,19 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>} The selected feature.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Successfully activated the drag handler.
|
||||
*/
|
||||
overFeature: function(feature) {
|
||||
var activated = false;
|
||||
if(!this.handlers.drag.dragging) {
|
||||
this.feature = feature;
|
||||
this.handlers.drag.activate();
|
||||
activated = true;
|
||||
this.over = true;
|
||||
OpenLayers.Element.addClass(this.map.viewPortDiv, this.displayClass + "Over");
|
||||
this.onEnter(feature);
|
||||
} else {
|
||||
if(this.feature.id == feature.id) {
|
||||
this.over = true;
|
||||
@ -199,6 +260,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.over = false;
|
||||
}
|
||||
}
|
||||
return activated;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -269,6 +331,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Element.removeClass(
|
||||
this.map.viewPortDiv, this.displayClass + "Over"
|
||||
);
|
||||
this.onLeave(feature);
|
||||
this.feature = null;
|
||||
} else {
|
||||
if(this.feature.id == feature.id) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -32,10 +32,12 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
|
||||
/**
|
||||
* Property: interval
|
||||
* {Integer} The number of milliseconds that should ellapse before
|
||||
* panning the map again. Set this to increase dragging performance.
|
||||
* Defaults to 25 milliseconds.
|
||||
* panning the map again. Defaults to 0 milliseconds, which means that
|
||||
* no separate cycle is used for panning. In most cases you won't want
|
||||
* to change this value. For slow machines/devices larger values can be
|
||||
* tried out.
|
||||
*/
|
||||
interval: 25,
|
||||
interval: 0,
|
||||
|
||||
/**
|
||||
* APIProperty: documentDrag
|
||||
@ -43,16 +45,50 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
|
||||
* mouse cursor leaves the map viewport. Default is false.
|
||||
*/
|
||||
documentDrag: false,
|
||||
|
||||
|
||||
/**
|
||||
* Property: kinetic
|
||||
* {<OpenLayers.Kinetic>} The OpenLayers.Kinetic object.
|
||||
*/
|
||||
kinetic: null,
|
||||
|
||||
/**
|
||||
* APIProperty: enableKinetic
|
||||
* {Boolean} Set this option to enable "kinetic dragging". Can be
|
||||
* set to true or to an object. If set to an object this
|
||||
* object will be passed to the {<OpenLayers.Kinetic>}
|
||||
* constructor. Defaults to true.
|
||||
* To get kinetic dragging, ensure that OpenLayers/Kinetic.js is
|
||||
* included in your build config.
|
||||
*/
|
||||
enableKinetic: true,
|
||||
|
||||
/**
|
||||
* APIProperty: kineticInterval
|
||||
* {Integer} Interval in milliseconds between 2 steps in the "kinetic
|
||||
* scrolling". Applies only if enableKinetic is set. Defaults
|
||||
* to 10 milliseconds.
|
||||
*/
|
||||
kineticInterval: 10,
|
||||
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
* Creates a Drag handler, using <panMap> and
|
||||
* <panMapDone> as callbacks.
|
||||
*/
|
||||
draw: function() {
|
||||
if (this.enableKinetic && OpenLayers.Kinetic) {
|
||||
var config = {interval: this.kineticInterval};
|
||||
if(typeof this.enableKinetic === "object") {
|
||||
config = OpenLayers.Util.extend(config, this.enableKinetic);
|
||||
}
|
||||
this.kinetic = new OpenLayers.Kinetic(config);
|
||||
}
|
||||
this.handler = new OpenLayers.Handler.Drag(this, {
|
||||
"move": this.panMap,
|
||||
"done": this.panMapDone
|
||||
"done": this.panMapDone,
|
||||
"down": this.panMapStart
|
||||
}, {
|
||||
interval: this.interval,
|
||||
documentDrag: this.documentDrag
|
||||
@ -60,6 +96,15 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: panMapStart
|
||||
*/
|
||||
panMapStart: function() {
|
||||
if(this.kinetic) {
|
||||
this.kinetic.begin();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: panMap
|
||||
*
|
||||
@ -67,11 +112,14 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
|
||||
* xy - {<OpenLayers.Pixel>} Pixel of the mouse position
|
||||
*/
|
||||
panMap: function(xy) {
|
||||
if(this.kinetic) {
|
||||
this.kinetic.update(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}
|
||||
{dragging: true, animate: false}
|
||||
);
|
||||
},
|
||||
|
||||
@ -85,7 +133,21 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
panMapDone: function(xy) {
|
||||
if(this.panned) {
|
||||
this.panMap(xy);
|
||||
var res = null;
|
||||
if (this.kinetic) {
|
||||
res = this.kinetic.end(xy);
|
||||
}
|
||||
this.map.pan(
|
||||
this.handler.last.x - xy.x,
|
||||
this.handler.last.y - xy.y,
|
||||
{dragging: !!res, animate: false}
|
||||
);
|
||||
if (res) {
|
||||
var self = this;
|
||||
this.kinetic.move(res, function(x, y, end) {
|
||||
self.map.pan(x, y, {dragging: !end, animate: false});
|
||||
});
|
||||
}
|
||||
this.panned = false;
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -31,13 +31,19 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
callbacks: null,
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Supported event types:
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* featureadded - Triggered when a feature is added
|
||||
*/
|
||||
EVENT_TYPES: ["featureadded"],
|
||||
|
||||
/**
|
||||
* APIProperty: multi
|
||||
@ -56,7 +62,6 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIProperty: handlerOptions
|
||||
* {Object} Used to set non-default properties on the control's handler
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.DrawFeature
|
||||
@ -67,13 +72,6 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(layer, handler, options) {
|
||||
|
||||
// concatenate events specific to vector with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.DrawFeature.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.callbacks = OpenLayers.Util.extend(
|
||||
{
|
||||
@ -93,6 +91,11 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
);
|
||||
this.layer = layer;
|
||||
this.handlerOptions = this.handlerOptions || {};
|
||||
this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(
|
||||
this.handlerOptions.layerOptions, {
|
||||
renderers: layer.renderers, rendererOptions: layer.rendererOptions
|
||||
}
|
||||
);
|
||||
if (!("multi" in this.handlerOptions)) {
|
||||
this.handlerOptions.multi = this.multi;
|
||||
}
|
||||
@ -121,6 +124,106 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.events.triggerEvent("featureadded",{feature : feature});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: insertXY
|
||||
* Insert a point in the current sketch given x & y coordinates.
|
||||
*
|
||||
* Parameters:
|
||||
* x - {Number} The x-coordinate of the point.
|
||||
* y - {Number} The y-coordinate of the point.
|
||||
*/
|
||||
insertXY: function(x, y) {
|
||||
if (this.handler && this.handler.line) {
|
||||
this.handler.insertXY(x, y);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: insertDeltaXY
|
||||
* Insert a point given offsets from the previously inserted point.
|
||||
*
|
||||
* Parameters:
|
||||
* dx - {Number} The x-coordinate offset of the point.
|
||||
* dy - {Number} The y-coordinate offset of the point.
|
||||
*/
|
||||
insertDeltaXY: function(dx, dy) {
|
||||
if (this.handler && this.handler.line) {
|
||||
this.handler.insertDeltaXY(dx, dy);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: insertDirectionLength
|
||||
* Insert a point in the current sketch given a direction and a length.
|
||||
*
|
||||
* Parameters:
|
||||
* direction - {Number} Degrees clockwise from the positive x-axis.
|
||||
* length - {Number} Distance from the previously drawn point.
|
||||
*/
|
||||
insertDirectionLength: function(direction, length) {
|
||||
if (this.handler && this.handler.line) {
|
||||
this.handler.insertDirectionLength(direction, length);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: insertDeflectionLength
|
||||
* Insert a point in the current sketch given a deflection and a length.
|
||||
* The deflection should be degrees clockwise from the previously
|
||||
* digitized segment.
|
||||
*
|
||||
* Parameters:
|
||||
* deflection - {Number} Degrees clockwise from the previous segment.
|
||||
* length - {Number} Distance from the previously drawn point.
|
||||
*/
|
||||
insertDeflectionLength: function(deflection, length) {
|
||||
if (this.handler && this.handler.line) {
|
||||
this.handler.insertDeflectionLength(deflection, length);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: undo
|
||||
* Remove the most recently added point in the current sketch geometry.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} An edit was undone.
|
||||
*/
|
||||
undo: function() {
|
||||
return this.handler.undo && this.handler.undo();
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: redo
|
||||
* Reinsert the most recently removed point resulting from an <undo> call.
|
||||
* The undo stack is deleted whenever a point is added by other means.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} An edit was redone.
|
||||
*/
|
||||
redo: function() {
|
||||
return this.handler.redo && this.handler.redo();
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: finishSketch
|
||||
* Finishes the sketch without including the currently drawn point.
|
||||
* This method can be called to terminate drawing programmatically
|
||||
* instead of waiting for the user to end the sketch.
|
||||
*/
|
||||
finishSketch: function() {
|
||||
this.handler.finishGeometry();
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: cancel
|
||||
* Cancel the current sketch. This removes the current sketch and keeps
|
||||
* the drawing control active.
|
||||
*/
|
||||
cancel: function() {
|
||||
this.handler.cancel();
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.DrawFeature"
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -24,6 +24,13 @@
|
||||
OpenLayers.Control.EditingToolbar = OpenLayers.Class(
|
||||
OpenLayers.Control.Panel, {
|
||||
|
||||
/**
|
||||
* APIProperty: citeCompliant
|
||||
* {Boolean} If set to true, coordinates of features drawn in a map extent
|
||||
* crossing the date line won't exceed the world bounds. Default is false.
|
||||
*/
|
||||
citeCompliant: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.EditingToolbar
|
||||
* Create an editing toolbar for a given layer.
|
||||
@ -39,9 +46,18 @@ OpenLayers.Control.EditingToolbar = OpenLayers.Class(
|
||||
[ 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'})
|
||||
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {
|
||||
displayClass: 'olControlDrawFeaturePoint',
|
||||
handlerOptions: {citeCompliant: this.citeCompliant}
|
||||
}),
|
||||
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {
|
||||
displayClass: 'olControlDrawFeaturePath',
|
||||
handlerOptions: {citeCompliant: this.citeCompliant}
|
||||
}),
|
||||
new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {
|
||||
displayClass: 'olControlDrawFeaturePolygon',
|
||||
handlerOptions: {citeCompliant: this.citeCompliant}
|
||||
})
|
||||
];
|
||||
this.addControls(controls);
|
||||
},
|
||||
@ -55,7 +71,9 @@ OpenLayers.Control.EditingToolbar = OpenLayers.Class(
|
||||
*/
|
||||
draw: function() {
|
||||
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
|
||||
this.activateControl(this.controls[0]);
|
||||
if (this.defaultControl === null) {
|
||||
this.defaultControl = this.controls[0];
|
||||
}
|
||||
return div;
|
||||
},
|
||||
|
||||
|
||||
192
js/openlayers/src/openlayers/lib/OpenLayers/Control/Geolocate.js
Normal file
@ -0,0 +1,192 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Geometry/Point.js
|
||||
* @requires OpenLayers/Projection.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.Geolocate
|
||||
* The Geolocate control wraps w3c geolocation API into control that can be
|
||||
* bound to a map, and generate events on location update
|
||||
*
|
||||
* To use this control requires to load the proj4js library if the projection
|
||||
* of the map is not EPSG:4326 or EPSG:900913.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* locationupdated - Triggered when browser return a new position. Listeners will
|
||||
* receive an object with a 'position' property which is the browser.geolocation.position
|
||||
* native object, as well as a 'point' property which is the location transformed in the
|
||||
* current map projection.
|
||||
* locationfailed - Triggered when geolocation has failed
|
||||
* locationuncapable - Triggered when control is activated on a browser
|
||||
* which doesn't support geolocation
|
||||
*/
|
||||
|
||||
/**
|
||||
* Property: geolocation
|
||||
* {Object} The geolocation engine, as a property to be possibly mocked.
|
||||
* This is set lazily to avoid a memory leak in IE9.
|
||||
*/
|
||||
geolocation: null,
|
||||
|
||||
/**
|
||||
* Property: available
|
||||
* {Boolean} The navigator.geolocation object is available.
|
||||
*/
|
||||
available: ('geolocation' in navigator),
|
||||
|
||||
/**
|
||||
* APIProperty: bind
|
||||
* {Boolean} If true, map center will be set on location update.
|
||||
*/
|
||||
bind: true,
|
||||
|
||||
/**
|
||||
* APIProperty: watch
|
||||
* {Boolean} If true, position will be update regularly.
|
||||
*/
|
||||
watch: false,
|
||||
|
||||
/**
|
||||
* APIProperty: geolocationOptions
|
||||
* {Object} Options to pass to the navigator's geolocation API. See
|
||||
* <http://dev.w3.org/geo/api/spec-source.html>. No specific
|
||||
* option is passed to the geolocation API by default.
|
||||
*/
|
||||
geolocationOptions: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.Geolocate
|
||||
* Create a new control to deal with browser geolocation API
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
this.deactivate();
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: activate
|
||||
* Activates the control.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The control was effectively activated.
|
||||
*/
|
||||
activate: function () {
|
||||
if (this.available && !this.geolocation) {
|
||||
// set lazily to avoid IE9 memory leak
|
||||
this.geolocation = navigator.geolocation;
|
||||
}
|
||||
if (!this.geolocation) {
|
||||
this.events.triggerEvent("locationuncapable");
|
||||
return false;
|
||||
}
|
||||
if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {
|
||||
if (this.watch) {
|
||||
this.watchId = this.geolocation.watchPosition(
|
||||
OpenLayers.Function.bind(this.geolocate, this),
|
||||
OpenLayers.Function.bind(this.failure, this),
|
||||
this.geolocationOptions
|
||||
);
|
||||
} else {
|
||||
this.getCurrentLocation();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: deactivate
|
||||
* Deactivates the control.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The control was effectively deactivated.
|
||||
*/
|
||||
deactivate: function () {
|
||||
if (this.active && this.watchId !== null) {
|
||||
this.geolocation.clearWatch(this.watchId);
|
||||
}
|
||||
return OpenLayers.Control.prototype.deactivate.apply(
|
||||
this, arguments
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: geolocate
|
||||
* Activates the control.
|
||||
*
|
||||
*/
|
||||
geolocate: function (position) {
|
||||
var center = new OpenLayers.LonLat(
|
||||
position.coords.longitude,
|
||||
position.coords.latitude
|
||||
).transform(
|
||||
new OpenLayers.Projection("EPSG:4326"),
|
||||
this.map.getProjectionObject()
|
||||
);
|
||||
if (this.bind) {
|
||||
this.map.setCenter(center);
|
||||
}
|
||||
this.events.triggerEvent("locationupdated", {
|
||||
position: position,
|
||||
point: new OpenLayers.Geometry.Point(
|
||||
center.lon, center.lat
|
||||
)
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getCurrentLocation
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Returns true if a event will be fired (successfull
|
||||
* registration)
|
||||
*/
|
||||
getCurrentLocation: function() {
|
||||
if (!this.active || this.watch) {
|
||||
return false;
|
||||
}
|
||||
this.geolocation.getCurrentPosition(
|
||||
OpenLayers.Function.bind(this.geolocate, this),
|
||||
OpenLayers.Function.bind(this.failure, this),
|
||||
this.geolocationOptions
|
||||
);
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: failure
|
||||
* method called on browser's geolocation failure
|
||||
*
|
||||
*/
|
||||
failure: function (error) {
|
||||
this.events.triggerEvent("locationfailed", {error: error});
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.Geolocate"
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -144,7 +144,6 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Object} Additional options for the handlers used by this control. This
|
||||
* is a hash with the keys "click", "box" and "hover".
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* Property: handlers
|
||||
@ -169,10 +168,17 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
filterType: OpenLayers.Filter.Spatial.BBOX,
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Supported event types:
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforefeatureselected - Triggered when <click> is true before a
|
||||
* feature is selected. The event object has a feature property with
|
||||
* the feature about to select
|
||||
@ -197,9 +203,6 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* outfeature - Triggered when <hover> is true and the mouse moves
|
||||
* moved away from a hover-selected feature
|
||||
*/
|
||||
EVENT_TYPES: ["featureselected", "featuresselected", "featureunselected",
|
||||
"clickout", "beforefeatureselected", "beforefeaturesselected",
|
||||
"hoverfeature", "outfeature"],
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.GetFeature
|
||||
@ -207,15 +210,10 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} A configuration object which at least has to contain
|
||||
* a <protocol> property
|
||||
* a <protocol> property (if not, it has to be set before a request is
|
||||
* made)
|
||||
*/
|
||||
initialize: function(options) {
|
||||
// concatenate events specific to vector with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.GetFeature.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
|
||||
options.handlerOptions = options.handlerOptions || {};
|
||||
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
@ -242,7 +240,8 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.handlers.hover = new OpenLayers.Handler.Hover(
|
||||
this, {'move': this.cancelHover, 'pause': this.selectHover},
|
||||
OpenLayers.Util.extend(this.handlerOptions.hover, {
|
||||
'delay': 250
|
||||
'delay': 250,
|
||||
'pixelTolerance': 2
|
||||
})
|
||||
);
|
||||
}
|
||||
@ -303,17 +302,20 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Callback from the handlers.box set up when <box> selection is on
|
||||
*
|
||||
* Parameters:
|
||||
* position - {<OpenLayers.Bounds>}
|
||||
* position - {<OpenLayers.Bounds>|Object} An OpenLayers.Bounds or
|
||||
* an object with a 'left', 'bottom', 'right' and 'top' properties.
|
||||
*/
|
||||
selectBox: function(position) {
|
||||
var bounds;
|
||||
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 minXY = this.map.getLonLatFromPixel({
|
||||
x: position.left,
|
||||
y: position.bottom
|
||||
});
|
||||
var maxXY = this.map.getLonLatFromPixel({
|
||||
x: position.right,
|
||||
y: position.top
|
||||
});
|
||||
bounds = new OpenLayers.Bounds(
|
||||
minXY.lon, minXY.lat, maxXY.lon, maxXY.lat
|
||||
);
|
||||
@ -330,11 +332,11 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Method selectHover
|
||||
* Method: selectHover
|
||||
* Callback from the handlers.hover set up when <hover> selection is on
|
||||
*
|
||||
* Parameters:
|
||||
* evt {Object} - event object with an xy property
|
||||
* evt - {Object} event object with an xy property
|
||||
*/
|
||||
selectHover: function(evt) {
|
||||
var bounds = this.pixelToBounds(evt.xy);
|
||||
@ -456,7 +458,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Sets the multiple and toggle modifiers according to the current event
|
||||
*
|
||||
* Parameters:
|
||||
* evt {<OpenLayers.Event>}
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
setModifiers: function(evt) {
|
||||
this.modifiers = {
|
||||
@ -477,7 +479,7 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
if(!this.modifiers.multiple && !this.modifiers.toggle) {
|
||||
this.unselectAll();
|
||||
}
|
||||
if(!(features instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(features))) {
|
||||
features = [features];
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Lang.js
|
||||
* @requires OpenLayers/Rule.js
|
||||
* @requires OpenLayers/StyleMap.js
|
||||
* @requires OpenLayers/Layer/Vector.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -97,7 +101,7 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Property: gratLayer
|
||||
* {OpenLayers.Layer.Vector} vector layer used to draw the graticule on
|
||||
* {<OpenLayers.Layer.Vector>} vector layer used to draw the graticule on
|
||||
*/
|
||||
gratLayer: null,
|
||||
|
||||
@ -112,7 +116,7 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
options.layerName = options.layerName || OpenLayers.i18n("graticule");
|
||||
options.layerName = options.layerName || OpenLayers.i18n("Graticule");
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
|
||||
this.labelSymbolizer.stroke = false;
|
||||
@ -233,8 +237,8 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
for (var i=0; i<this.intervals.length; ++i) {
|
||||
llInterval = this.intervals[i]; //could do this for both x and y??
|
||||
var delta = llInterval/2;
|
||||
var p1 = mapCenterLL.offset(new OpenLayers.Pixel(-delta, -delta)); //test coords in EPSG:4326 space
|
||||
var p2 = mapCenterLL.offset(new OpenLayers.Pixel( delta, delta));
|
||||
var p1 = mapCenterLL.offset({x: -delta, y: -delta}); //test coords in EPSG:4326 space
|
||||
var p2 = mapCenterLL.offset({x: delta, y: delta});
|
||||
OpenLayers.Projection.transform(p1, llProj, mapProj); // convert them back to map projection
|
||||
OpenLayers.Projection.transform(p2, llProj, mapProj);
|
||||
var distSq = (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y);
|
||||
@ -260,13 +264,13 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
var newPoint = mapCenterLL.clone();
|
||||
var mapXY;
|
||||
do {
|
||||
newPoint = newPoint.offset(new OpenLayers.Pixel(0,llInterval));
|
||||
newPoint = newPoint.offset({x: 0, y: llInterval});
|
||||
mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);
|
||||
centerLonPoints.unshift(newPoint);
|
||||
} while (mapBounds.containsPixel(mapXY) && ++iter<1000);
|
||||
newPoint = mapCenterLL.clone();
|
||||
do {
|
||||
newPoint = newPoint.offset(new OpenLayers.Pixel(0,-llInterval));
|
||||
newPoint = newPoint.offset({x: 0, y: -llInterval});
|
||||
mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);
|
||||
centerLonPoints.push(newPoint);
|
||||
} while (mapBounds.containsPixel(mapXY) && ++iter<1000);
|
||||
@ -276,13 +280,13 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
|
||||
var centerLatPoints = [mapCenterLL.clone()];
|
||||
newPoint = mapCenterLL.clone();
|
||||
do {
|
||||
newPoint = newPoint.offset(new OpenLayers.Pixel(-llInterval, 0));
|
||||
newPoint = newPoint.offset({x: -llInterval, y: 0});
|
||||
mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);
|
||||
centerLatPoints.unshift(newPoint);
|
||||
} while (mapBounds.containsPixel(mapXY) && ++iter<1000);
|
||||
newPoint = mapCenterLL.clone();
|
||||
do {
|
||||
newPoint = newPoint.offset(new OpenLayers.Pixel(llInterval, 0));
|
||||
newPoint = newPoint.offset({x: llInterval, y: 0});
|
||||
mapXY = OpenLayers.Projection.transform(newPoint.clone(), llProj, mapProj);
|
||||
centerLatPoints.push(newPoint);
|
||||
} while (mapBounds.containsPixel(mapXY) && ++iter<1000);
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Handler/Keyboard.js
|
||||
* @requires OpenLayers/Events.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -34,32 +35,29 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
slideFactor: 75,
|
||||
|
||||
/**
|
||||
* APIProperty: observeElement
|
||||
* {DOMelement|String} The DOM element to handle keys for. You
|
||||
* can use the map div here, to have the navigation keys
|
||||
* work when the map div has the focus. If undefined the
|
||||
* document is used.
|
||||
*/
|
||||
observeElement: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.KeyboardDefaults
|
||||
*/
|
||||
initialize: function() {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.handler) {
|
||||
this.handler.destroy();
|
||||
}
|
||||
this.handler = null;
|
||||
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
* Create handler.
|
||||
*/
|
||||
draw: function() {
|
||||
this.handler = new OpenLayers.Handler.Keyboard( this, {
|
||||
"keydown": this.defaultKeyPress });
|
||||
var observeElement = this.observeElement || document;
|
||||
this.handler = new OpenLayers.Handler.Keyboard( this,
|
||||
{"keydown": this.defaultKeyPress},
|
||||
{observeElement: observeElement}
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -74,10 +72,20 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
|
||||
* http://unixpapa.com/js/key.html
|
||||
*
|
||||
* Parameters:
|
||||
* code - {Integer}
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultKeyPress: function (evt) {
|
||||
switch(evt.keyCode) {
|
||||
var size, handled = true;
|
||||
|
||||
var target = OpenLayers.Event.element(evt);
|
||||
if (target &&
|
||||
(target.tagName == 'INPUT' ||
|
||||
target.tagName == 'TEXTAREA' ||
|
||||
target.tagName == 'SELECT')) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (evt.keyCode) {
|
||||
case OpenLayers.Event.KEY_LEFT:
|
||||
this.map.pan(-this.slideFactor, 0);
|
||||
break;
|
||||
@ -92,19 +100,19 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
|
||||
break;
|
||||
|
||||
case 33: // Page Up. Same in all browsers.
|
||||
var size = this.map.getSize();
|
||||
size = this.map.getSize();
|
||||
this.map.pan(0, -0.75*size.h);
|
||||
break;
|
||||
case 34: // Page Down. Same in all browsers.
|
||||
var size = this.map.getSize();
|
||||
size = this.map.getSize();
|
||||
this.map.pan(0, 0.75*size.h);
|
||||
break;
|
||||
case 35: // End. Same in all browsers.
|
||||
var size = this.map.getSize();
|
||||
size = this.map.getSize();
|
||||
this.map.pan(0.75*size.w, 0);
|
||||
break;
|
||||
case 36: // Home. Same in all browsers.
|
||||
var size = this.map.getSize();
|
||||
size = this.map.getSize();
|
||||
this.map.pan(-0.75*size.w, 0);
|
||||
break;
|
||||
|
||||
@ -120,7 +128,14 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
|
||||
case 95: // -/_ (some ASCII)
|
||||
this.map.zoomOut();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
handled = false;
|
||||
}
|
||||
if (handled) {
|
||||
// prevent browser default not to move the page
|
||||
// when moving the page with the keyboard
|
||||
OpenLayers.Event.stop(evt);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"
|
||||
|
||||
@ -1,42 +1,30 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Lang.js
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/Events/buttonclick.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.LayerSwitcher
|
||||
* The LayerSwitcher control displays a table of contents for the map. This
|
||||
* The LayerSwitcher control displays a table of contents for the map. This
|
||||
* allows the user interface to switch between BaseLasyers and to show or hide
|
||||
* Overlays. By default the switcher is shown minimized on the right edge of
|
||||
* Overlays. By default the switcher is shown minimized on the right edge of
|
||||
* the map, the user may expand it by clicking on the handle.
|
||||
*
|
||||
* To create the LayerSwitcher outside of the map, pass the Id of a html div
|
||||
* To create the LayerSwitcher outside of the map, pass the Id of a html div
|
||||
* as the first argument to the constructor.
|
||||
*
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.LayerSwitcher =
|
||||
OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.LayerSwitcher = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: roundedCorner
|
||||
* {Boolean} If true the Rico library is used for rounding the corners
|
||||
* of the layer switcher div, defaults to true.
|
||||
*/
|
||||
roundedCorner: true,
|
||||
|
||||
/**
|
||||
* APIProperty: roundedCornerColor
|
||||
* {String} The color of the rounded corners, only applies if roundedCorner
|
||||
* is true, defaults to "darkblue".
|
||||
*/
|
||||
roundedCornerColor: "darkblue",
|
||||
|
||||
/**
|
||||
* Property: layerStates
|
||||
* {Array(Object)} Basically a copy of the "state" of the map's layers
|
||||
@ -44,69 +32,68 @@ OpenLayers.Control.LayerSwitcher =
|
||||
* unnecessarily redrawing the control.
|
||||
*/
|
||||
layerStates: null,
|
||||
|
||||
|
||||
// DOM Elements
|
||||
|
||||
|
||||
/**
|
||||
* Property: layersDiv
|
||||
* {DOMElement}
|
||||
* {DOMElement}
|
||||
*/
|
||||
layersDiv: null,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Property: baseLayersDiv
|
||||
* {DOMElement}
|
||||
*/
|
||||
baseLayersDiv: null,
|
||||
|
||||
/**
|
||||
/**
|
||||
* Property: baseLayers
|
||||
* {Array(<OpenLayers.Layer>)}
|
||||
* {Array(Object)}
|
||||
*/
|
||||
baseLayers: null,
|
||||
|
||||
|
||||
/**
|
||||
|
||||
|
||||
/**
|
||||
* Property: dataLbl
|
||||
* {DOMElement}
|
||||
* {DOMElement}
|
||||
*/
|
||||
dataLbl: null,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Property: dataLayersDiv
|
||||
* {DOMElement}
|
||||
* {DOMElement}
|
||||
*/
|
||||
dataLayersDiv: null,
|
||||
|
||||
/**
|
||||
/**
|
||||
* Property: dataLayers
|
||||
* {Array(<OpenLayers.Layer>)}
|
||||
* {Array(Object)}
|
||||
*/
|
||||
dataLayers: null,
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Property: minimizeDiv
|
||||
* {DOMElement}
|
||||
* {DOMElement}
|
||||
*/
|
||||
minimizeDiv: null,
|
||||
|
||||
/**
|
||||
/**
|
||||
* Property: maximizeDiv
|
||||
* {DOMElement}
|
||||
* {DOMElement}
|
||||
*/
|
||||
maximizeDiv: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: ascending
|
||||
* {Boolean}
|
||||
* {Boolean}
|
||||
*/
|
||||
ascending: true,
|
||||
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.LayerSwitcher
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object}
|
||||
*/
|
||||
@ -116,55 +103,58 @@ OpenLayers.Control.LayerSwitcher =
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
OpenLayers.Event.stopObservingElement(this.div);
|
||||
|
||||
OpenLayers.Event.stopObservingElement(this.minimizeDiv);
|
||||
OpenLayers.Event.stopObservingElement(this.maximizeDiv);
|
||||
|
||||
//clear out layers info and unregister their events
|
||||
//clear out layers info and unregister their events
|
||||
this.clearLayersArray("base");
|
||||
this.clearLayersArray("data");
|
||||
|
||||
|
||||
this.map.events.un({
|
||||
"addlayer": this.redraw,
|
||||
"changelayer": this.redraw,
|
||||
"removelayer": this.redraw,
|
||||
"changebaselayer": this.redraw,
|
||||
buttonclick: this.onButtonClick,
|
||||
addlayer: this.redraw,
|
||||
changelayer: this.redraw,
|
||||
removelayer: this.redraw,
|
||||
changebaselayer: this.redraw,
|
||||
scope: this
|
||||
});
|
||||
|
||||
this.events.unregister("buttonclick", this, this.onButtonClick);
|
||||
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Method: setMap
|
||||
*
|
||||
* Properties:
|
||||
* map - {<OpenLayers.Map>}
|
||||
* map - {<OpenLayers.Map>}
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
|
||||
this.map.events.on({
|
||||
"addlayer": this.redraw,
|
||||
"changelayer": this.redraw,
|
||||
"removelayer": this.redraw,
|
||||
"changebaselayer": this.redraw,
|
||||
addlayer: this.redraw,
|
||||
changelayer: this.redraw,
|
||||
removelayer: this.redraw,
|
||||
changebaselayer: this.redraw,
|
||||
scope: this
|
||||
});
|
||||
if (this.outsideViewport) {
|
||||
this.events.attachToElement(this.div);
|
||||
this.events.register("buttonclick", this, this.onButtonClick);
|
||||
} else {
|
||||
this.map.events.register("buttonclick", this, this.onButtonClick);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} A reference to the DIV DOMElement containing the
|
||||
* {DOMElement} A reference to the DIV DOMElement containing the
|
||||
* switcher tabs.
|
||||
*/
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this);
|
||||
|
||||
@ -177,28 +167,48 @@ OpenLayers.Control.LayerSwitcher =
|
||||
}
|
||||
|
||||
// populate div with current info
|
||||
this.redraw();
|
||||
this.redraw();
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Method: onButtonClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
onButtonClick: function(evt) {
|
||||
var button = evt.buttonElement;
|
||||
if (button === this.minimizeDiv) {
|
||||
this.minimizeControl();
|
||||
} else if (button === this.maximizeDiv) {
|
||||
this.maximizeControl();
|
||||
} else if (button._layerSwitcher === this.id) {
|
||||
if (button["for"]) {
|
||||
button = document.getElementById(button["for"]);
|
||||
}
|
||||
if (!button.disabled) {
|
||||
if (button.type == "radio") {
|
||||
button.checked = true;
|
||||
this.map.setBaseLayer(this.map.getLayer(button._layer));
|
||||
} else {
|
||||
button.checked = !button.checked;
|
||||
this.updateMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: clearLayersArray
|
||||
* User specifies either "base" or "data". we then clear all the
|
||||
* corresponding listeners, the div, and reinitialize a new array.
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* layersType - {String}
|
||||
* layersType - {String}
|
||||
*/
|
||||
clearLayersArray: function(layersType) {
|
||||
var layers = this[layersType + "Layers"];
|
||||
if (layers) {
|
||||
for(var i=0, len=layers.length; i<len ; i++) {
|
||||
var layer = layers[i];
|
||||
OpenLayers.Event.stopObservingElement(layer.inputElem);
|
||||
OpenLayers.Event.stopObservingElement(layer.labelSpan);
|
||||
}
|
||||
}
|
||||
this[layersType + "LayersDiv"].innerHTML = "";
|
||||
this[layersType + "Layers"] = [];
|
||||
},
|
||||
@ -207,54 +217,53 @@ OpenLayers.Control.LayerSwitcher =
|
||||
/**
|
||||
* Method: checkRedraw
|
||||
* Checks if the layer state has changed since the last redraw() call.
|
||||
*
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The layer state changed since the last redraw() call.
|
||||
* {Boolean} The layer state changed since the last redraw() call.
|
||||
*/
|
||||
checkRedraw: function() {
|
||||
var redraw = false;
|
||||
if ( !this.layerStates.length ||
|
||||
(this.map.layers.length != this.layerStates.length) ) {
|
||||
redraw = true;
|
||||
} else {
|
||||
for (var i=0, len=this.layerStates.length; i<len; i++) {
|
||||
var layerState = this.layerStates[i];
|
||||
var layer = this.map.layers[i];
|
||||
if ( (layerState.name != layer.name) ||
|
||||
(layerState.inRange != layer.inRange) ||
|
||||
(layerState.id != layer.id) ||
|
||||
(layerState.visibility != layer.visibility) ) {
|
||||
redraw = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
for (var i = 0, len = this.layerStates.length; i < len; i++) {
|
||||
var layerState = this.layerStates[i];
|
||||
var layer = this.map.layers[i];
|
||||
if ( (layerState.name != layer.name) ||
|
||||
(layerState.inRange != layer.inRange) ||
|
||||
(layerState.id != layer.id) ||
|
||||
(layerState.visibility != layer.visibility) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return redraw;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Method: redraw
|
||||
* Goes through and takes the current state of the Map and rebuilds the
|
||||
* control to display that state. Groups base layers into a
|
||||
* control to display that state. Groups base layers into a
|
||||
* radio-button group and lists each data layer with a checkbox.
|
||||
*
|
||||
* Returns:
|
||||
* Returns:
|
||||
* {DOMElement} A reference to the DIV DOMElement containing the control
|
||||
*/
|
||||
*/
|
||||
redraw: function() {
|
||||
//if the state hasn't changed since last redraw, no need
|
||||
//if the state hasn't changed since last redraw, no need
|
||||
// to do anything. Just return the existing div.
|
||||
if (!this.checkRedraw()) {
|
||||
return this.div;
|
||||
}
|
||||
if (!this.checkRedraw()) {
|
||||
return this.div;
|
||||
}
|
||||
|
||||
//clear out previous layers
|
||||
//clear out previous layers
|
||||
this.clearLayersArray("base");
|
||||
this.clearLayersArray("data");
|
||||
|
||||
|
||||
var containsOverlays = false;
|
||||
var containsBaseLayers = false;
|
||||
|
||||
|
||||
// Save state -- for checking layer if the map state changed.
|
||||
// We save this before redrawing, because in the process of redrawing
|
||||
// we will trigger more visibility changes, and we want to not redraw
|
||||
@ -264,12 +273,12 @@ OpenLayers.Control.LayerSwitcher =
|
||||
for (var i=0; i <len; i++) {
|
||||
var layer = this.map.layers[i];
|
||||
this.layerStates[i] = {
|
||||
'name': layer.name,
|
||||
'name': layer.name,
|
||||
'visibility': layer.visibility,
|
||||
'inRange': layer.inRange,
|
||||
'id': layer.id
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
var layers = this.map.layers.slice();
|
||||
if (!this.ascending) { layers.reverse(); }
|
||||
@ -283,52 +292,53 @@ OpenLayers.Control.LayerSwitcher =
|
||||
containsBaseLayers = true;
|
||||
} else {
|
||||
containsOverlays = true;
|
||||
}
|
||||
}
|
||||
|
||||
// only check a baselayer if it is *the* baselayer, check data
|
||||
// layers if they are visible
|
||||
var checked = (baseLayer) ? (layer == this.map.baseLayer)
|
||||
: layer.getVisibility();
|
||||
|
||||
|
||||
// create input element
|
||||
var inputElem = document.createElement("input");
|
||||
inputElem.id = this.id + "_input_" + layer.name;
|
||||
var inputElem = document.createElement("input"),
|
||||
// The input shall have an id attribute so we can use
|
||||
// labels to interact with them.
|
||||
inputId = OpenLayers.Util.createUniqueID(
|
||||
this.id + "_input_"
|
||||
);
|
||||
|
||||
inputElem.id = inputId;
|
||||
inputElem.name = (baseLayer) ? this.id + "_baseLayers" : layer.name;
|
||||
inputElem.type = (baseLayer) ? "radio" : "checkbox";
|
||||
inputElem.value = layer.name;
|
||||
inputElem.checked = checked;
|
||||
inputElem.defaultChecked = checked;
|
||||
inputElem.className = "olButton";
|
||||
inputElem._layer = layer.id;
|
||||
inputElem._layerSwitcher = this.id;
|
||||
|
||||
if (!baseLayer && !layer.inRange) {
|
||||
inputElem.disabled = true;
|
||||
}
|
||||
var context = {
|
||||
'inputElem': inputElem,
|
||||
'layer': layer,
|
||||
'layerSwitcher': this
|
||||
};
|
||||
OpenLayers.Event.observe(inputElem, "mouseup",
|
||||
OpenLayers.Function.bindAsEventListener(this.onInputClick,
|
||||
context)
|
||||
);
|
||||
|
||||
|
||||
// create span
|
||||
var labelSpan = document.createElement("span");
|
||||
OpenLayers.Element.addClass(labelSpan, "labelSpan")
|
||||
var labelSpan = document.createElement("label");
|
||||
// this isn't the DOM attribute 'for', but an arbitrary name we
|
||||
// use to find the appropriate input element in <onButtonClick>
|
||||
labelSpan["for"] = inputElem.id;
|
||||
OpenLayers.Element.addClass(labelSpan, "labelSpan olButton");
|
||||
labelSpan._layer = layer.id;
|
||||
labelSpan._layerSwitcher = this.id;
|
||||
if (!baseLayer && !layer.inRange) {
|
||||
labelSpan.style.color = "gray";
|
||||
}
|
||||
labelSpan.innerHTML = layer.name;
|
||||
labelSpan.style.verticalAlign = (baseLayer) ? "bottom"
|
||||
labelSpan.style.verticalAlign = (baseLayer) ? "bottom"
|
||||
: "baseline";
|
||||
OpenLayers.Event.observe(labelSpan, "click",
|
||||
OpenLayers.Function.bindAsEventListener(this.onInputClick,
|
||||
context)
|
||||
);
|
||||
// create line break
|
||||
var br = document.createElement("br");
|
||||
|
||||
|
||||
|
||||
|
||||
var groupArray = (baseLayer) ? this.baseLayers
|
||||
: this.dataLayers;
|
||||
groupArray.push({
|
||||
@ -336,8 +346,8 @@ OpenLayers.Control.LayerSwitcher =
|
||||
'inputElem': inputElem,
|
||||
'labelSpan': labelSpan
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var groupDiv = (baseLayer) ? this.baseLayersDiv
|
||||
: this.dataLayersDiv;
|
||||
groupDiv.appendChild(inputElem);
|
||||
@ -347,64 +357,24 @@ OpenLayers.Control.LayerSwitcher =
|
||||
}
|
||||
|
||||
// if no overlays, dont display the overlay label
|
||||
this.dataLbl.style.display = (containsOverlays) ? "" : "none";
|
||||
|
||||
this.dataLbl.style.display = (containsOverlays) ? "" : "none";
|
||||
|
||||
// if no baselayers, dont display the baselayer label
|
||||
this.baseLbl.style.display = (containsBaseLayers) ? "" : "none";
|
||||
this.baseLbl.style.display = (containsBaseLayers) ? "" : "none";
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method:
|
||||
* A label has been clicked, check or uncheck its corresponding input
|
||||
*
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*
|
||||
* Context:
|
||||
* - {DOMElement} inputElem
|
||||
* - {<OpenLayers.Control.LayerSwitcher>} layerSwitcher
|
||||
* - {<OpenLayers.Layer>} layer
|
||||
*/
|
||||
|
||||
onInputClick: function(e) {
|
||||
|
||||
if (!this.inputElem.disabled) {
|
||||
if (this.inputElem.type == "radio") {
|
||||
this.inputElem.checked = true;
|
||||
this.layer.map.setBaseLayer(this.layer);
|
||||
} else {
|
||||
this.inputElem.checked = !this.inputElem.checked;
|
||||
this.layerSwitcher.updateMap();
|
||||
}
|
||||
}
|
||||
OpenLayers.Event.stop(e);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onLayerClick
|
||||
* Need to update the map accordingly whenever user clicks in either of
|
||||
* the layers.
|
||||
*
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*/
|
||||
onLayerClick: function(e) {
|
||||
this.updateMap();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: updateMap
|
||||
* Cycles through the loaded data and base layer input arrays and makes
|
||||
* the necessary calls to the Map object such that that the map's
|
||||
* visual state corresponds to what the user has selected in
|
||||
* the necessary calls to the Map object such that that the map's
|
||||
* visual state corresponds to what the user has selected in
|
||||
* the control.
|
||||
*/
|
||||
updateMap: function() {
|
||||
|
||||
// set the newly selected base layer
|
||||
// set the newly selected base layer
|
||||
for(var i=0, len=this.baseLayers.length; i<len; i++) {
|
||||
var layerEntry = this.baseLayers[i];
|
||||
if (layerEntry.inputElem.checked) {
|
||||
@ -414,18 +384,18 @@ OpenLayers.Control.LayerSwitcher =
|
||||
|
||||
// set the correct visibilities for the overlays
|
||||
for(var i=0, len=this.dataLayers.length; i<len; i++) {
|
||||
var layerEntry = this.dataLayers[i];
|
||||
var layerEntry = this.dataLayers[i];
|
||||
layerEntry.layer.setVisibility(layerEntry.inputElem.checked);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Method: maximizeControl
|
||||
* Set up the labels and divs for the control
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
* e - {Event}
|
||||
*/
|
||||
maximizeControl: function(e) {
|
||||
|
||||
@ -437,17 +407,17 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.showControls(false);
|
||||
|
||||
if (e != null) {
|
||||
OpenLayers.Event.stop(e);
|
||||
OpenLayers.Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Method: minimizeControl
|
||||
* Hide all the contents of the control, shrink the size,
|
||||
* Hide all the contents of the control, shrink the size,
|
||||
* add the maximize icon
|
||||
*
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
* e - {Event}
|
||||
*/
|
||||
minimizeControl: function(e) {
|
||||
|
||||
@ -461,7 +431,7 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.showControls(true);
|
||||
|
||||
if (e != null) {
|
||||
OpenLayers.Event.stop(e);
|
||||
OpenLayers.Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
@ -469,7 +439,7 @@ OpenLayers.Control.LayerSwitcher =
|
||||
* Method: showControls
|
||||
* Hide/Show all LayerSwitcher controls depending on whether we are
|
||||
* minimized or not
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* minimize - {Boolean}
|
||||
*/
|
||||
@ -480,39 +450,29 @@ OpenLayers.Control.LayerSwitcher =
|
||||
|
||||
this.layersDiv.style.display = minimize ? "none" : "";
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Method: loadContents
|
||||
* Set up the labels and divs for the control
|
||||
*/
|
||||
loadContents: function() {
|
||||
|
||||
//configure main div
|
||||
|
||||
OpenLayers.Event.observe(this.div, "mouseup",
|
||||
OpenLayers.Function.bindAsEventListener(this.mouseUp, this));
|
||||
OpenLayers.Event.observe(this.div, "click",
|
||||
this.ignoreEvent);
|
||||
OpenLayers.Event.observe(this.div, "mousedown",
|
||||
OpenLayers.Function.bindAsEventListener(this.mouseDown, this));
|
||||
OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent);
|
||||
|
||||
// layers list div
|
||||
// layers list div
|
||||
this.layersDiv = document.createElement("div");
|
||||
this.layersDiv.id = this.id + "_layersDiv";
|
||||
OpenLayers.Element.addClass(this.layersDiv, "layersDiv");
|
||||
|
||||
this.baseLbl = document.createElement("div");
|
||||
this.baseLbl.innerHTML = OpenLayers.i18n("baseLayer");
|
||||
this.baseLbl.innerHTML = OpenLayers.i18n("Base Layer");
|
||||
OpenLayers.Element.addClass(this.baseLbl, "baseLbl");
|
||||
|
||||
|
||||
this.baseLayersDiv = document.createElement("div");
|
||||
OpenLayers.Element.addClass(this.baseLayersDiv, "baseLayersDiv");
|
||||
|
||||
this.dataLbl = document.createElement("div");
|
||||
this.dataLbl.innerHTML = OpenLayers.i18n("overlays");
|
||||
this.dataLbl.innerHTML = OpenLayers.i18n("Overlays");
|
||||
OpenLayers.Element.addClass(this.dataLbl, "dataLbl");
|
||||
|
||||
|
||||
this.dataLayersDiv = document.createElement("div");
|
||||
OpenLayers.Element.addClass(this.dataLayersDiv, "dataLayersDiv");
|
||||
|
||||
@ -526,95 +486,36 @@ OpenLayers.Control.LayerSwitcher =
|
||||
this.layersDiv.appendChild(this.dataLayersDiv);
|
||||
this.layersDiv.appendChild(this.baseLbl);
|
||||
this.layersDiv.appendChild(this.baseLayersDiv);
|
||||
}
|
||||
|
||||
this.div.appendChild(this.layersDiv);
|
||||
|
||||
if(this.roundedCorner) {
|
||||
OpenLayers.Rico.Corner.round(this.div, {
|
||||
corners: "tl bl",
|
||||
bgColor: "transparent",
|
||||
color: this.roundedCornerColor,
|
||||
blend: false
|
||||
});
|
||||
OpenLayers.Rico.Corner.changeOpacity(this.layersDiv, 0.75);
|
||||
}
|
||||
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
var sz = new OpenLayers.Size(18,18);
|
||||
this.div.appendChild(this.layersDiv);
|
||||
|
||||
// maximize button div
|
||||
var img = imgLocation + 'layer-switcher-maximize.png';
|
||||
var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');
|
||||
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
"OpenLayers_Control_MaximizeDiv",
|
||||
null,
|
||||
sz,
|
||||
img,
|
||||
"OpenLayers_Control_MaximizeDiv",
|
||||
null,
|
||||
null,
|
||||
img,
|
||||
"absolute");
|
||||
OpenLayers.Element.addClass(this.maximizeDiv, "maximizeDiv");
|
||||
OpenLayers.Element.addClass(this.maximizeDiv, "maximizeDiv olButton");
|
||||
this.maximizeDiv.style.display = "none";
|
||||
OpenLayers.Event.observe(this.maximizeDiv, "click",
|
||||
OpenLayers.Function.bindAsEventListener(this.maximizeControl, this)
|
||||
);
|
||||
|
||||
|
||||
this.div.appendChild(this.maximizeDiv);
|
||||
|
||||
// minimize button div
|
||||
var img = imgLocation + 'layer-switcher-minimize.png';
|
||||
var sz = new OpenLayers.Size(18,18);
|
||||
var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');
|
||||
this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
"OpenLayers_Control_MinimizeDiv",
|
||||
null,
|
||||
sz,
|
||||
img,
|
||||
"OpenLayers_Control_MinimizeDiv",
|
||||
null,
|
||||
null,
|
||||
img,
|
||||
"absolute");
|
||||
OpenLayers.Element.addClass(this.minimizeDiv, "minimizeDiv");
|
||||
OpenLayers.Element.addClass(this.minimizeDiv, "minimizeDiv olButton");
|
||||
this.minimizeDiv.style.display = "none";
|
||||
OpenLayers.Event.observe(this.minimizeDiv, "click",
|
||||
OpenLayers.Function.bindAsEventListener(this.minimizeControl, this)
|
||||
);
|
||||
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: ignoreEvent
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
ignoreEvent: function(evt) {
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: mouseDown
|
||||
* Register a local 'mouseDown' flag so that we'll know whether or not
|
||||
* to ignore a mouseUp event
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
mouseDown: function(evt) {
|
||||
this.isMouseDown = true;
|
||||
this.ignoreEvent(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: mouseUp
|
||||
* If the 'isMouseDown' flag has been set, that means that the drag was
|
||||
* started from within the LayerSwitcher control, and thus we can
|
||||
* ignore the mouseup. Otherwise, let the Event continue.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
mouseUp: function(evt) {
|
||||
if (this.isMouseDown) {
|
||||
this.isMouseDown = false;
|
||||
this.ignoreEvent(evt);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -18,53 +18,51 @@
|
||||
OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
* {Array(String)} Supported application event types. Register a listener
|
||||
* for a particular event with the following syntax:
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Listeners will be called with a reference to an event object. The
|
||||
* properties of this event depends on exactly what happened.
|
||||
*
|
||||
* Supported control event types (in addition to those from <OpenLayers.Control>):
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* measure - Triggered when a measurement sketch is complete. Listeners
|
||||
* will receive an event with measure, units, order, and geometry
|
||||
* properties.
|
||||
* measurepartial - Triggered when a new point is added to the
|
||||
* measurement sketch. Listeners receive an event with measure,
|
||||
* measurement sketch or if the <immediate> property is true and the
|
||||
* measurement sketch is modified. Listeners receive an event with measure,
|
||||
* units, order, and geometry.
|
||||
*/
|
||||
EVENT_TYPES: ['measure', 'measurepartial'],
|
||||
|
||||
/**
|
||||
* APIProperty: handlerOptions
|
||||
* {Object} Used to set non-default properties on the control's handler
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: callbacks
|
||||
* {Object} The functions that are sent to the handler for callback
|
||||
*/
|
||||
callbacks: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: displaySystem
|
||||
* APIProperty: displaySystem
|
||||
* {String} Display system for output measurements. Supported values
|
||||
* are 'english', 'metric', and 'geographic'. Default is 'metric'.
|
||||
*/
|
||||
displaySystem: 'metric',
|
||||
|
||||
|
||||
/**
|
||||
* Property: geodesic
|
||||
* APIProperty: geodesic
|
||||
* {Boolean} Calculate geodesic metrics instead of planar metrics. This
|
||||
* requires that geometries can be transformed into Geographic/WGS84
|
||||
* (if that is not already the map projection). Default is false.
|
||||
*/
|
||||
geodesic: false,
|
||||
|
||||
|
||||
/**
|
||||
* Property: displaySystemUnits
|
||||
* {Object} Units for various measurement systems. Values are arrays
|
||||
@ -93,7 +91,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Number} Timeout id of trigger for measurepartial.
|
||||
*/
|
||||
delayedTrigger: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: persist
|
||||
* {Boolean} Keep the temporary measurement sketch drawn after the
|
||||
@ -103,42 +101,70 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
persist: false,
|
||||
|
||||
/**
|
||||
* APIProperty: immediate
|
||||
* {Boolean} Activates the immediate measurement so that the "measurepartial"
|
||||
* event is also fired once the measurement sketch is modified.
|
||||
* Default is false.
|
||||
*/
|
||||
immediate : false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.Measure
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* handler - {<OpenLayers.Handler>}
|
||||
* options - {Object}
|
||||
* handler - {<OpenLayers.Handler>}
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(handler, options) {
|
||||
// concatenate events specific to measure with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.Measure.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.callbacks = OpenLayers.Util.extend(
|
||||
{done: this.measureComplete, point: this.measurePartial},
|
||||
this.callbacks
|
||||
);
|
||||
var callbacks = {done: this.measureComplete,
|
||||
point: this.measurePartial};
|
||||
if (this.immediate){
|
||||
callbacks.modify = this.measureImmediate;
|
||||
}
|
||||
this.callbacks = OpenLayers.Util.extend(callbacks, this.callbacks);
|
||||
|
||||
// let the handler options override, so old code that passes 'persist'
|
||||
// let the handler options override, so old code that passes 'persist'
|
||||
// directly to the handler does not need an update
|
||||
this.handlerOptions = OpenLayers.Util.extend(
|
||||
{persist: this.persist}, this.handlerOptions
|
||||
);
|
||||
this.handler = new handler(this, this.callbacks, this.handlerOptions);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: deactivate
|
||||
*/
|
||||
deactivate: function() {
|
||||
this.cancelDelay();
|
||||
return OpenLayers.Control.prototype.deactivate.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: cancel
|
||||
* Stop the control from measuring. If <persist> is true, the temporary
|
||||
* sketch will be erased.
|
||||
*/
|
||||
cancel: function() {
|
||||
this.cancelDelay();
|
||||
this.handler.cancel();
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: setImmediate
|
||||
* Sets the <immediate> property. Changes the activity of immediate
|
||||
* measurement.
|
||||
*/
|
||||
setImmediate: function(immediate) {
|
||||
this.immediate = immediate;
|
||||
if (this.immediate){
|
||||
this.callbacks.modify = this.measureImmediate;
|
||||
} else {
|
||||
delete this.callbacks.modify;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: updateHandler
|
||||
*
|
||||
@ -165,12 +191,10 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
* geometry - {<OpenLayers.Geometry>}
|
||||
*/
|
||||
measureComplete: function(geometry) {
|
||||
if(this.delayedTrigger) {
|
||||
window.clearTimeout(this.delayedTrigger);
|
||||
}
|
||||
this.cancelDelay();
|
||||
this.measure(geometry, "measure");
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: measurePartial
|
||||
* Called each time a new point is added to the measurement sketch.
|
||||
@ -180,10 +204,17 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
* geometry - {<OpenLayers.Geometry>} The sketch geometry.
|
||||
*/
|
||||
measurePartial: function(point, geometry) {
|
||||
if (geometry.getLength() > 0) {
|
||||
geometry = geometry.clone();
|
||||
this.cancelDelay();
|
||||
geometry = geometry.clone();
|
||||
// when we're wating for a dblclick, we have to trigger measurepartial
|
||||
// after some delay to deal with reflow issues in IE
|
||||
if (this.handler.freehandMode(this.handler.evt)) {
|
||||
// no dblclick in freehand mode
|
||||
this.measure(geometry, "measurepartial");
|
||||
} else {
|
||||
this.delayedTrigger = window.setTimeout(
|
||||
OpenLayers.Function.bind(function() {
|
||||
this.delayedTrigger = null;
|
||||
this.measure(geometry, "measurepartial");
|
||||
}, this),
|
||||
this.partialDelay
|
||||
@ -191,6 +222,33 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: measureImmediate
|
||||
* Called each time the measurement sketch is modified.
|
||||
*
|
||||
* Parameters:
|
||||
* point - {<OpenLayers.Geometry.Point>} The point at the mouse position.
|
||||
* feature - {<OpenLayers.Feature.Vector>} The sketch feature.
|
||||
* drawing - {Boolean} Indicates whether we're currently drawing.
|
||||
*/
|
||||
measureImmediate : function(point, feature, drawing) {
|
||||
if (drawing && !this.handler.freehandMode(this.handler.evt)) {
|
||||
this.cancelDelay();
|
||||
this.measure(feature.geometry, "measurepartial");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: cancelDelay
|
||||
* Cancels the delay measurement that measurePartial began.
|
||||
*/
|
||||
cancelDelay: function() {
|
||||
if (this.delayedTrigger !== null) {
|
||||
window.clearTimeout(this.delayedTrigger);
|
||||
this.delayedTrigger = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: measure
|
||||
*
|
||||
@ -214,7 +272,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
geometry: geometry
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: getBestArea
|
||||
* Based on the <displaySystem> returns the area of a geometry.
|
||||
@ -238,7 +296,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
return [area, unit];
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: getArea
|
||||
*
|
||||
@ -265,7 +323,7 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
return area;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: getBestLength
|
||||
* Based on the <displaySystem> returns the length of a geometry.
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control/DragFeature.js
|
||||
* @requires OpenLayers/Control/SelectFeature.js
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Handler/Drag.js
|
||||
* @requires OpenLayers/Handler/Keyboard.js
|
||||
*/
|
||||
|
||||
@ -22,6 +22,13 @@
|
||||
*/
|
||||
OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: documentDrag
|
||||
* {Boolean} If set to true, dragging vertices will continue even if the
|
||||
* mouse cursor leaves the map viewport. Default is false.
|
||||
*/
|
||||
documentDrag: false,
|
||||
|
||||
/**
|
||||
* APIProperty: geometryTypes
|
||||
* {Array(String)} To restrict modification to a limited set of geometry
|
||||
@ -43,7 +50,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Default is true.
|
||||
*/
|
||||
toggle: true,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: standalone
|
||||
* {Boolean} Set to true to create a control without SelectFeature
|
||||
@ -60,20 +67,26 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {<OpenLayers.Layer.Vector>}
|
||||
*/
|
||||
layer: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: feature
|
||||
* {<OpenLayers.Feature.Vector>} Feature currently available for modification.
|
||||
*/
|
||||
feature: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: vertex
|
||||
* {<OpenLayers.Feature.Vector>} Vertex currently being modified.
|
||||
*/
|
||||
vertex: null,
|
||||
|
||||
/**
|
||||
* Property: vertices
|
||||
* {Array(<OpenLayers.Feature.Vector>)} Verticies currently available
|
||||
* for dragging.
|
||||
*/
|
||||
vertices: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: virtualVertices
|
||||
* {Array(<OpenLayers.Feature.Vector>)} Virtual vertices in the middle
|
||||
@ -81,24 +94,12 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
virtualVertices: null,
|
||||
|
||||
/**
|
||||
* Property: selectControl
|
||||
* {<OpenLayers.Control.SelectFeature>}
|
||||
*/
|
||||
selectControl: null,
|
||||
|
||||
/**
|
||||
* Property: dragControl
|
||||
* {<OpenLayers.Control.DragFeature>}
|
||||
*/
|
||||
dragControl: null,
|
||||
|
||||
/**
|
||||
* Property: handlers
|
||||
* {Object}
|
||||
*/
|
||||
handlers: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: deleteCodes
|
||||
* {Array(Integer)} Keycodes for deleting verticies. Set to null to disable
|
||||
@ -114,6 +115,15 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
virtualStyle: null,
|
||||
|
||||
/**
|
||||
* APIProperty: vertexRenderIntent
|
||||
* {String} The renderIntent to use for vertices. If no <virtualStyle> is
|
||||
* provided, this renderIntent will also be used for virtual vertices, with
|
||||
* a fillOpacity and strokeOpacity of 0.3. Default is null, which means
|
||||
* that the layer's default style will be used for vertices.
|
||||
*/
|
||||
vertexRenderIntent: null,
|
||||
|
||||
/**
|
||||
* APIProperty: mode
|
||||
* {Integer} Bitfields specifying the modification mode. Defaults to
|
||||
@ -128,6 +138,13 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
mode: null,
|
||||
|
||||
/**
|
||||
* APIProperty: createVertices
|
||||
* {Boolean} Create new vertices by dragging the virtual vertices
|
||||
* in the middle of each edge. Default is true.
|
||||
*/
|
||||
createVertices: true,
|
||||
|
||||
/**
|
||||
* Property: modified
|
||||
* {Boolean} The currently selected feature has been modified.
|
||||
@ -193,77 +210,66 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* control.
|
||||
*/
|
||||
initialize: function(layer, options) {
|
||||
options = options || {};
|
||||
this.layer = layer;
|
||||
this.vertices = [];
|
||||
this.virtualVertices = [];
|
||||
this.virtualStyle = OpenLayers.Util.extend({},
|
||||
this.layer.style || this.layer.styleMap.createSymbolizer());
|
||||
this.layer.style ||
|
||||
this.layer.styleMap.createSymbolizer(null, options.vertexRenderIntent)
|
||||
);
|
||||
this.virtualStyle.fillOpacity = 0.3;
|
||||
this.virtualStyle.strokeOpacity = 0.3;
|
||||
this.deleteCodes = [46, 68];
|
||||
this.mode = OpenLayers.Control.ModifyFeature.RESHAPE;
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
if(!(this.deleteCodes instanceof Array)) {
|
||||
if(!(OpenLayers.Util.isArray(this.deleteCodes))) {
|
||||
this.deleteCodes = [this.deleteCodes];
|
||||
}
|
||||
var control = this;
|
||||
|
||||
// configure the select control
|
||||
var selectOptions = {
|
||||
geometryTypes: this.geometryTypes,
|
||||
clickout: this.clickout,
|
||||
toggle: this.toggle,
|
||||
onBeforeSelect: this.beforeSelectFeature,
|
||||
onSelect: this.selectFeature,
|
||||
onUnselect: this.unselectFeature,
|
||||
scope: this
|
||||
};
|
||||
if(this.standalone === false) {
|
||||
this.selectControl = new OpenLayers.Control.SelectFeature(
|
||||
layer, selectOptions
|
||||
);
|
||||
}
|
||||
|
||||
// configure the drag control
|
||||
var dragOptions = {
|
||||
geometryTypes: ["OpenLayers.Geometry.Point"],
|
||||
snappingOptions: this.snappingOptions,
|
||||
onStart: function(feature, pixel) {
|
||||
control.dragStart.apply(control, [feature, pixel]);
|
||||
|
||||
// configure the drag handler
|
||||
var dragCallbacks = {
|
||||
down: function(pixel) {
|
||||
this.vertex = null;
|
||||
var feature = this.layer.getFeatureFromEvent(
|
||||
this.handlers.drag.evt);
|
||||
if (feature) {
|
||||
this.dragStart(feature);
|
||||
} else if (this.clickout) {
|
||||
this._unselect = this.feature;
|
||||
}
|
||||
},
|
||||
onDrag: function(feature, pixel) {
|
||||
control.dragVertex.apply(control, [feature, pixel]);
|
||||
move: function(pixel) {
|
||||
delete this._unselect;
|
||||
if (this.vertex) {
|
||||
this.dragVertex(this.vertex, pixel);
|
||||
}
|
||||
},
|
||||
onComplete: function(feature) {
|
||||
control.dragComplete.apply(control, [feature]);
|
||||
up: function() {
|
||||
this.handlers.drag.stopDown = false;
|
||||
if (this._unselect) {
|
||||
this.unselectFeature(this._unselect);
|
||||
delete this._unselect;
|
||||
}
|
||||
},
|
||||
featureCallbacks: {
|
||||
over: function(feature) {
|
||||
/**
|
||||
* In normal mode, the feature handler is set up to allow
|
||||
* dragging of all points. In standalone mode, we only
|
||||
* want to allow dragging of sketch vertices and virtual
|
||||
* vertices - or, in the case of a modifiable point, the
|
||||
* point itself.
|
||||
*/
|
||||
if(control.standalone !== true || feature._sketch ||
|
||||
control.feature === feature) {
|
||||
control.dragControl.overFeature.apply(
|
||||
control.dragControl, [feature]);
|
||||
}
|
||||
done: function(pixel) {
|
||||
if (this.vertex) {
|
||||
this.dragComplete(this.vertex);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.dragControl = new OpenLayers.Control.DragFeature(
|
||||
layer, dragOptions
|
||||
);
|
||||
var dragOptions = {
|
||||
documentDrag: this.documentDrag,
|
||||
stopDown: false
|
||||
};
|
||||
|
||||
// configure the keyboard handler
|
||||
var keyboardOptions = {
|
||||
keydown: this.handleKeypress
|
||||
};
|
||||
this.handlers = {
|
||||
keyboard: new OpenLayers.Handler.Keyboard(this, keyboardOptions)
|
||||
keyboard: new OpenLayers.Handler.Keyboard(this, keyboardOptions),
|
||||
drag: new OpenLayers.Handler.Drag(this, dragCallbacks, dragOptions)
|
||||
};
|
||||
},
|
||||
|
||||
@ -272,9 +278,14 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Take care of things that are not handled in superclass.
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.map) {
|
||||
this.map.events.un({
|
||||
"removelayer": this.handleMapEvents,
|
||||
"changelayer": this.handleMapEvents,
|
||||
scope: this
|
||||
});
|
||||
}
|
||||
this.layer = null;
|
||||
this.standalone || this.selectControl.destroy();
|
||||
this.dragControl.destroy();
|
||||
OpenLayers.Control.prototype.destroy.apply(this, []);
|
||||
},
|
||||
|
||||
@ -286,8 +297,14 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Boolean} Successfully activated the control.
|
||||
*/
|
||||
activate: function() {
|
||||
return ((this.standalone || this.selectControl.activate()) &&
|
||||
this.handlers.keyboard.activate() &&
|
||||
this.moveLayerToTop();
|
||||
this.map.events.on({
|
||||
"removelayer": this.handleMapEvents,
|
||||
"changelayer": this.handleMapEvents,
|
||||
scope: this
|
||||
});
|
||||
return (this.handlers.keyboard.activate() &&
|
||||
this.handlers.drag.activate() &&
|
||||
OpenLayers.Control.prototype.activate.apply(this, arguments));
|
||||
},
|
||||
|
||||
@ -302,29 +319,26 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var deactivated = false;
|
||||
// the return from the controls is unimportant in this case
|
||||
if(OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {
|
||||
this.moveLayerBack();
|
||||
this.map.events.un({
|
||||
"removelayer": this.handleMapEvents,
|
||||
"changelayer": this.handleMapEvents,
|
||||
scope: this
|
||||
});
|
||||
this.layer.removeFeatures(this.vertices, {silent: true});
|
||||
this.layer.removeFeatures(this.virtualVertices, {silent: true});
|
||||
this.vertices = [];
|
||||
this.dragControl.deactivate();
|
||||
var feature = this.feature;
|
||||
var valid = feature && feature.geometry && feature.layer;
|
||||
if(this.standalone === false) {
|
||||
if(valid) {
|
||||
this.selectControl.unselect.apply(this.selectControl,
|
||||
[feature]);
|
||||
}
|
||||
this.selectControl.deactivate();
|
||||
} else {
|
||||
if(valid) {
|
||||
this.unselectFeature(feature);
|
||||
}
|
||||
}
|
||||
this.handlers.drag.deactivate();
|
||||
this.handlers.keyboard.deactivate();
|
||||
var feature = this.feature;
|
||||
if (feature && feature.geometry && feature.layer) {
|
||||
this.unselectFeature(feature);
|
||||
}
|
||||
deactivated = true;
|
||||
}
|
||||
return deactivated;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: beforeSelectFeature
|
||||
* Called before a feature is selected.
|
||||
@ -339,22 +353,41 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: selectFeature
|
||||
* Called when the select feature control selects a feature.
|
||||
* APIMethod: selectFeature
|
||||
* Select a feature for modification in standalone mode. In non-standalone
|
||||
* mode, this method is called when a feature is selected by clicking.
|
||||
* Register a listener to the beforefeaturemodified event and return false
|
||||
* to prevent feature modification.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>} the selected feature.
|
||||
*/
|
||||
selectFeature: function(feature) {
|
||||
this.feature = feature;
|
||||
this.modified = false;
|
||||
this.resetVertices();
|
||||
this.dragControl.activate();
|
||||
this.onModificationStart(this.feature);
|
||||
if (this.feature === feature ||
|
||||
(this.geometryTypes && OpenLayers.Util.indexOf(this.geometryTypes,
|
||||
feature.geometry.CLASS_NAME) == -1)) {
|
||||
return;
|
||||
}
|
||||
if (this.beforeSelectFeature(feature) !== false) {
|
||||
if (this.feature) {
|
||||
this.unselectFeature(this.feature);
|
||||
}
|
||||
this.feature = feature;
|
||||
this.layer.selectedFeatures.push(feature);
|
||||
this.layer.drawFeature(feature, 'select');
|
||||
this.modified = false;
|
||||
this.resetVertices();
|
||||
this.onModificationStart(this.feature);
|
||||
}
|
||||
// keep track of geometry modifications
|
||||
var modified = feature.modified;
|
||||
if (feature.geometry && !(modified && modified.geometry)) {
|
||||
this._originalGeometry = feature.geometry.clone();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: unselectFeature
|
||||
* APIMethod: unselectFeature
|
||||
* Called when the select feature control unselects a feature.
|
||||
*
|
||||
* Parameters:
|
||||
@ -373,8 +406,9 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.layer.destroyFeatures([this.radiusHandle], {silent: true});
|
||||
delete this.radiusHandle;
|
||||
}
|
||||
this.layer.drawFeature(this.feature, 'default');
|
||||
this.feature = null;
|
||||
this.dragControl.deactivate();
|
||||
OpenLayers.Util.removeItem(this.layer.selectedFeatures, feature);
|
||||
this.onModificationEnd(feature);
|
||||
this.layer.events.triggerEvent("afterfeaturemodified", {
|
||||
feature: feature,
|
||||
@ -382,64 +416,48 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
});
|
||||
this.modified = false;
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method: dragStart
|
||||
* Called by the drag feature control with before a feature is dragged.
|
||||
* This method is used to differentiate between points and vertices
|
||||
* of higher order geometries. This respects the <geometryTypes>
|
||||
* property and forces a select of points when the drag control is
|
||||
* already active (and stops events from propagating to the select
|
||||
* control).
|
||||
* Called by the drag handler before a feature is dragged. This method is
|
||||
* used to differentiate between points and vertices
|
||||
* of higher order geometries.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector>} The point or vertex about to be
|
||||
* dragged.
|
||||
* pixel - {<OpenLayers.Pixel>} Pixel location of the mouse event.
|
||||
*/
|
||||
dragStart: function(feature, pixel) {
|
||||
// only change behavior if the feature is not in the vertices array
|
||||
if(feature != this.feature && !feature.geometry.parent &&
|
||||
feature != this.dragHandle && feature != this.radiusHandle) {
|
||||
if(this.standalone === false && this.feature) {
|
||||
// unselect the currently selected feature
|
||||
this.selectControl.clickFeature.apply(this.selectControl,
|
||||
[this.feature]);
|
||||
}
|
||||
// check any constraints on the geometry type
|
||||
if(this.geometryTypes == null ||
|
||||
OpenLayers.Util.indexOf(this.geometryTypes,
|
||||
feature.geometry.CLASS_NAME) != -1) {
|
||||
// select the point
|
||||
this.standalone || this.selectControl.clickFeature.apply(
|
||||
this.selectControl, [feature]);
|
||||
/**
|
||||
* TBD: These lines improve workflow by letting the user
|
||||
* immediately start dragging after the mouse down.
|
||||
* However, it is very ugly to be messing with controls
|
||||
* and their handlers in this way. I'd like a better
|
||||
* solution if the workflow change is necessary.
|
||||
*/
|
||||
// prepare the point for dragging
|
||||
this.dragControl.overFeature.apply(this.dragControl,
|
||||
[feature]);
|
||||
this.dragControl.lastPixel = pixel;
|
||||
this.dragControl.handlers.drag.started = true;
|
||||
this.dragControl.handlers.drag.start = pixel;
|
||||
this.dragControl.handlers.drag.last = pixel;
|
||||
dragStart: function(feature) {
|
||||
var isPoint = feature.geometry.CLASS_NAME ==
|
||||
'OpenLayers.Geometry.Point';
|
||||
if (!this.standalone &&
|
||||
((!feature._sketch && isPoint) || !feature._sketch)) {
|
||||
if (this.toggle && this.feature === feature) {
|
||||
// mark feature for unselection
|
||||
this._unselect = feature;
|
||||
}
|
||||
this.selectFeature(feature);
|
||||
}
|
||||
if (feature._sketch || isPoint) {
|
||||
// feature is a drag or virtual handle or point
|
||||
this.vertex = feature;
|
||||
this.handlers.drag.stopDown = true;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: dragVertex
|
||||
* Called by the drag feature control with each drag move of a vertex.
|
||||
* Called by the drag handler with each drag move of a vertex.
|
||||
*
|
||||
* Parameters:
|
||||
* vertex - {<OpenLayers.Feature.Vector>} The vertex being dragged.
|
||||
* pixel - {<OpenLayers.Pixel>} Pixel location of the mouse event.
|
||||
*/
|
||||
dragVertex: function(vertex, pixel) {
|
||||
var pos = this.map.getLonLatFromViewPortPx(pixel);
|
||||
var geom = vertex.geometry;
|
||||
geom.move(pos.lon - geom.x, pos.lat - geom.y);
|
||||
this.modified = true;
|
||||
/**
|
||||
* Five cases:
|
||||
@ -451,9 +469,6 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
if(this.feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
|
||||
// dragging a simple point
|
||||
if(this.feature != vertex) {
|
||||
this.feature = vertex;
|
||||
}
|
||||
this.layer.events.triggerEvent("vertexmodified", {
|
||||
vertex: vertex.geometry,
|
||||
feature: this.feature,
|
||||
@ -490,7 +505,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.virtualVertices = [];
|
||||
}
|
||||
this.layer.drawFeature(this.feature, this.standalone ? undefined :
|
||||
this.selectControl.renderIntent);
|
||||
'select');
|
||||
}
|
||||
// keep the vertex on top so it gets the mouseout after dragging
|
||||
// this should be removed in favor of an option to draw under or
|
||||
@ -500,7 +515,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Method: dragComplete
|
||||
* Called by the drag feature control when the feature dragging is complete.
|
||||
* Called by the drag handler when the feature dragging is complete.
|
||||
*
|
||||
* Parameters:
|
||||
* vertex - {<OpenLayers.Feature.Vector>} The vertex being dragged.
|
||||
@ -522,6 +537,13 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
if(this.feature.state != OpenLayers.State.INSERT &&
|
||||
this.feature.state != OpenLayers.State.DELETE) {
|
||||
this.feature.state = OpenLayers.State.UPDATE;
|
||||
if (this.modified && this._originalGeometry) {
|
||||
var feature = this.feature;
|
||||
feature.modified = OpenLayers.Util.extend(feature.modified, {
|
||||
geometry: this._originalGeometry
|
||||
});
|
||||
delete this._originalGeometry;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -529,16 +551,6 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: resetVertices
|
||||
*/
|
||||
resetVertices: function() {
|
||||
// if coming from a drag complete we're about to destroy the vertex
|
||||
// that was just dragged. For that reason, the drag feature control
|
||||
// will never detect a mouse-out on that vertex, meaning that the drag
|
||||
// handler won't be deactivated. This can cause errors because the drag
|
||||
// feature control still has a feature to drag but that feature is
|
||||
// destroyed. To prevent this, we call outFeature on the drag feature
|
||||
// control if the control actually has a feature to drag.
|
||||
if(this.dragControl.feature) {
|
||||
this.dragControl.outFeature(this.dragControl.feature);
|
||||
}
|
||||
if(this.vertices.length > 0) {
|
||||
this.layer.removeFeatures(this.vertices, {silent: true});
|
||||
this.vertices = [];
|
||||
@ -581,7 +593,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* the mouse is over a vertex.
|
||||
*
|
||||
* Parameters:
|
||||
* {Integer} Key code corresponding to the keypress event.
|
||||
* evt - {Event} Keypress event.
|
||||
*/
|
||||
handleKeypress: function(evt) {
|
||||
var code = evt.keyCode;
|
||||
@ -589,16 +601,20 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
// check for delete key
|
||||
if(this.feature &&
|
||||
OpenLayers.Util.indexOf(this.deleteCodes, code) != -1) {
|
||||
var vertex = this.dragControl.feature;
|
||||
if(vertex &&
|
||||
OpenLayers.Util.indexOf(this.vertices, vertex) != -1 &&
|
||||
!this.dragControl.handlers.drag.dragging &&
|
||||
vertex.geometry.parent) {
|
||||
var vertex = this.layer.getFeatureFromEvent(this.handlers.drag.evt);
|
||||
if (vertex &&
|
||||
OpenLayers.Util.indexOf(this.vertices, vertex) != -1 &&
|
||||
!this.handlers.drag.dragging && vertex.geometry.parent) {
|
||||
// remove the vertex
|
||||
vertex.geometry.parent.removeComponent(vertex.geometry);
|
||||
this.layer.events.triggerEvent("vertexremoved", {
|
||||
vertex: vertex.geometry,
|
||||
feature: this.feature,
|
||||
pixel: evt.xy
|
||||
});
|
||||
this.layer.drawFeature(this.feature, this.standalone ?
|
||||
undefined :
|
||||
this.selectControl.renderIntent);
|
||||
undefined : 'select');
|
||||
this.modified = true;
|
||||
this.resetVertices();
|
||||
this.setFeatureState();
|
||||
this.onModification(this.feature);
|
||||
@ -622,6 +638,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
if(geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
|
||||
vertex = new OpenLayers.Feature.Vector(geometry);
|
||||
vertex._sketch = true;
|
||||
vertex.renderIntent = control.vertexRenderIntent;
|
||||
control.vertices.push(vertex);
|
||||
} else {
|
||||
var numVert = geometry.components.length;
|
||||
@ -633,6 +650,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
if(component.CLASS_NAME == "OpenLayers.Geometry.Point") {
|
||||
vertex = new OpenLayers.Feature.Vector(component);
|
||||
vertex._sketch = true;
|
||||
vertex.renderIntent = control.vertexRenderIntent;
|
||||
control.vertices.push(vertex);
|
||||
} else {
|
||||
collectComponentVertices(component);
|
||||
@ -640,7 +658,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
|
||||
// add virtual vertices in the middle of each edge
|
||||
if(geometry.CLASS_NAME != "OpenLayers.Geometry.MultiPoint") {
|
||||
if (control.createVertices && geometry.CLASS_NAME != "OpenLayers.Geometry.MultiPoint") {
|
||||
for(i=0, len=geometry.components.length; i<len-1; ++i) {
|
||||
var prevVertex = geometry.components[i];
|
||||
var nextVertex = geometry.components[i + 1];
|
||||
@ -684,6 +702,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
};
|
||||
origin._sketch = true;
|
||||
this.dragHandle = origin;
|
||||
this.dragHandle.renderIntent = this.vertexRenderIntent;
|
||||
this.layer.addFeatures([this.dragHandle], {silent: true});
|
||||
},
|
||||
|
||||
@ -736,6 +755,7 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
};
|
||||
radius._sketch = true;
|
||||
this.radiusHandle = radius;
|
||||
this.radiusHandle.renderIntent = this.vertexRenderIntent;
|
||||
this.layer.addFeatures([this.radiusHandle], {silent: true});
|
||||
},
|
||||
|
||||
@ -747,11 +767,49 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* map - {<OpenLayers.Map>} The control's map.
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.standalone || this.selectControl.setMap(map);
|
||||
this.dragControl.setMap(map);
|
||||
this.handlers.drag.setMap(map);
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: handleMapEvents
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object}
|
||||
*/
|
||||
handleMapEvents: function(evt) {
|
||||
if (evt.type == "removelayer" || evt.property == "order") {
|
||||
this.moveLayerToTop();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveLayerToTop
|
||||
* Moves the layer for this handler to the top, so mouse events can reach
|
||||
* it.
|
||||
*/
|
||||
moveLayerToTop: function() {
|
||||
var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,
|
||||
this.layer.getZIndex()) + 1;
|
||||
this.layer.setZIndex(index);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: moveLayerBack
|
||||
* Moves the layer back to the position determined by the map's layers
|
||||
* array.
|
||||
*/
|
||||
moveLayerBack: function() {
|
||||
var index = this.layer.getZIndex() - 1;
|
||||
if (index >= this.map.Z_INDEX_BASE['Feature']) {
|
||||
this.layer.setZIndex(index);
|
||||
} else {
|
||||
this.map.setLayerZIndex(this.layer,
|
||||
this.map.getLayerIndex(this.layer));
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.ModifyFeature"
|
||||
});
|
||||
|
||||
|
||||
@ -1,368 +0,0 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.MouseDefaults
|
||||
* This class is DEPRECATED in 2.4 and will be removed by 3.0.
|
||||
* If you need this functionality, use <OpenLayers.Control.Navigation>
|
||||
* instead!!!
|
||||
*
|
||||
* This class is DEPRECATED in 2.4 and will be removed by 3.0.
|
||||
* If you need this functionality, use Control.Navigation instead!!!
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.MouseDefaults = OpenLayers.Class(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!!! */
|
||||
|
||||
/**
|
||||
* Property: performedDrag
|
||||
* {Boolean}
|
||||
*/
|
||||
performedDrag: false,
|
||||
|
||||
/**
|
||||
* Property: wheelObserver
|
||||
* {Function}
|
||||
*/
|
||||
wheelObserver: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.MouseDefaults
|
||||
*/
|
||||
initialize: function() {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
if (this.handler) {
|
||||
this.handler.destroy();
|
||||
}
|
||||
this.handler = null;
|
||||
|
||||
this.map.events.un({
|
||||
"click": this.defaultClick,
|
||||
"dblclick": this.defaultDblClick,
|
||||
"mousedown": this.defaultMouseDown,
|
||||
"mouseup": this.defaultMouseUp,
|
||||
"mousemove": this.defaultMouseMove,
|
||||
"mouseout": this.defaultMouseOut,
|
||||
scope: this
|
||||
});
|
||||
|
||||
//unregister mousewheel events specifically on the window and document
|
||||
OpenLayers.Event.stopObserving(window, "DOMMouseScroll",
|
||||
this.wheelObserver);
|
||||
OpenLayers.Event.stopObserving(window, "mousewheel",
|
||||
this.wheelObserver);
|
||||
OpenLayers.Event.stopObserving(document, "mousewheel",
|
||||
this.wheelObserver);
|
||||
this.wheelObserver = null;
|
||||
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
*/
|
||||
draw: function() {
|
||||
this.map.events.on({
|
||||
"click": this.defaultClick,
|
||||
"dblclick": this.defaultDblClick,
|
||||
"mousedown": this.defaultMouseDown,
|
||||
"mouseup": this.defaultMouseUp,
|
||||
"mousemove": this.defaultMouseMove,
|
||||
"mouseout": this.defaultMouseOut,
|
||||
scope: this
|
||||
});
|
||||
|
||||
this.registerWheelEvents();
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: registerWheelEvents
|
||||
*/
|
||||
registerWheelEvents: function() {
|
||||
|
||||
this.wheelObserver = OpenLayers.Function.bindAsEventListener(
|
||||
this.onWheelEvent, this
|
||||
);
|
||||
|
||||
//register mousewheel events specifically on the window and document
|
||||
OpenLayers.Event.observe(window, "DOMMouseScroll", this.wheelObserver);
|
||||
OpenLayers.Event.observe(window, "mousewheel", this.wheelObserver);
|
||||
OpenLayers.Event.observe(document, "mousewheel", this.wheelObserver);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean}
|
||||
*/
|
||||
defaultClick: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
var notAfterDrag = !this.performedDrag;
|
||||
this.performedDrag = false;
|
||||
return notAfterDrag;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultDblClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultDblClick: function (evt) {
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
OpenLayers.Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseDown
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseDown: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.performedDrag = false;
|
||||
if (evt.shiftKey) {
|
||||
this.map.div.style.cursor = "crosshair";
|
||||
this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
|
||||
this.mouseDragStart,
|
||||
null,
|
||||
null,
|
||||
"absolute",
|
||||
"2px solid red");
|
||||
this.zoomBox.style.backgroundColor = "white";
|
||||
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
|
||||
this.zoomBox.style.opacity = "0.50";
|
||||
this.zoomBox.style.fontSize = "1px";
|
||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
}
|
||||
document.onselectstart = OpenLayers.Function.False;
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseMove
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseMove: function (evt) {
|
||||
// record the mouse position, used in onWheelEvent
|
||||
this.mousePosition = evt.xy.clone();
|
||||
|
||||
if (this.mouseDragStart != null) {
|
||||
if (this.zoomBox) {
|
||||
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
|
||||
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
|
||||
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
|
||||
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
|
||||
if (evt.xy.x < this.mouseDragStart.x) {
|
||||
this.zoomBox.style.left = evt.xy.x+"px";
|
||||
}
|
||||
if (evt.xy.y < this.mouseDragStart.y) {
|
||||
this.zoomBox.style.top = evt.xy.y+"px";
|
||||
}
|
||||
} else {
|
||||
var deltaX = this.mouseDragStart.x - evt.xy.x;
|
||||
var deltaY = this.mouseDragStart.y - evt.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.mouseDragStart = evt.xy.clone();
|
||||
this.map.div.style.cursor = "move";
|
||||
}
|
||||
this.performedDrag = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseUp
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
defaultMouseUp: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
if (this.zoomBox) {
|
||||
this.zoomBoxEnd(evt);
|
||||
} else {
|
||||
if (this.performedDrag) {
|
||||
this.map.setCenter(this.map.center);
|
||||
}
|
||||
}
|
||||
document.onselectstart=null;
|
||||
this.mouseDragStart = null;
|
||||
this.map.div.style.cursor = "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseOut
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseOut: function (evt) {
|
||||
if (this.mouseDragStart != null &&
|
||||
OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
||||
if (this.zoomBox) {
|
||||
this.removeZoomBox();
|
||||
}
|
||||
this.mouseDragStart = null;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: defaultWheelUp
|
||||
* User spun scroll wheel up
|
||||
*
|
||||
*/
|
||||
defaultWheelUp: function(evt) {
|
||||
if (this.map.getZoom() <= this.map.getNumZoomLevels()) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
|
||||
this.map.getZoom() + 1);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultWheelDown
|
||||
* User spun scroll wheel down
|
||||
*/
|
||||
defaultWheelDown: function(evt) {
|
||||
if (this.map.getZoom() > 0) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(evt.xy),
|
||||
this.map.getZoom() - 1);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: zoomBoxEnd
|
||||
* Zoombox function.
|
||||
*/
|
||||
zoomBoxEnd: function(evt) {
|
||||
if (this.mouseDragStart != null) {
|
||||
if (Math.abs(this.mouseDragStart.x - evt.xy.x) > 5 ||
|
||||
Math.abs(this.mouseDragStart.y - evt.xy.y) > 5) {
|
||||
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
var top = Math.max(start.lat, end.lat);
|
||||
var bottom = Math.min(start.lat, end.lat);
|
||||
var left = Math.min(start.lon, end.lon);
|
||||
var right = Math.max(start.lon, end.lon);
|
||||
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
|
||||
this.map.zoomToExtent(bounds);
|
||||
} else {
|
||||
var end = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(new OpenLayers.LonLat(
|
||||
(end.lon),
|
||||
(end.lat)
|
||||
), this.map.getZoom() + 1);
|
||||
}
|
||||
this.removeZoomBox();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: removeZoomBox
|
||||
* Remove the zoombox from the screen and nullify our reference to it.
|
||||
*/
|
||||
removeZoomBox: function() {
|
||||
this.map.viewPortDiv.removeChild(this.zoomBox);
|
||||
this.zoomBox = null;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Method: onWheelEvent
|
||||
* Catch the wheel event and handle it xbrowserly
|
||||
*
|
||||
* Parameters:
|
||||
* e - {Event}
|
||||
*/
|
||||
onWheelEvent: function(e){
|
||||
|
||||
// first determine whether or not the wheeling was inside the map
|
||||
var inMap = false;
|
||||
var elem = OpenLayers.Event.element(e);
|
||||
while(elem != null) {
|
||||
if (this.map && elem == this.map.div) {
|
||||
inMap = true;
|
||||
break;
|
||||
}
|
||||
elem = elem.parentNode;
|
||||
}
|
||||
|
||||
if (inMap) {
|
||||
|
||||
var delta = 0;
|
||||
if (!e) {
|
||||
e = window.event;
|
||||
}
|
||||
if (e.wheelDelta) {
|
||||
delta = e.wheelDelta/120;
|
||||
if (window.opera && window.opera.version() < 9.2) {
|
||||
delta = -delta;
|
||||
}
|
||||
} else if (e.detail) {
|
||||
delta = -e.detail / 3;
|
||||
}
|
||||
if (delta) {
|
||||
// add the mouse position to the event because mozilla has a bug
|
||||
// with clientX and clientY (see https://bugzilla.mozilla.org/show_bug.cgi?id=352179)
|
||||
// getLonLatFromViewPortPx(e) returns wrong values
|
||||
e.xy = this.mousePosition;
|
||||
|
||||
if (delta < 0) {
|
||||
this.defaultWheelDown(e);
|
||||
} else {
|
||||
this.defaultWheelUp(e);
|
||||
}
|
||||
}
|
||||
|
||||
//only wheel the map, not the window
|
||||
OpenLayers.Event.stop(e);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.MouseDefaults"
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -13,11 +13,23 @@
|
||||
* The MousePosition control displays geographic coordinates of the mouse
|
||||
* pointer, as it is moved about the map.
|
||||
*
|
||||
* You can use the <prefix>- or <suffix>-properties to provide more information
|
||||
* about the displayed coordinates to the user:
|
||||
*
|
||||
* (code)
|
||||
* var mousePositionCtrl = new OpenLayers.Control.MousePosition({
|
||||
* prefix: '<a target="_blank" ' +
|
||||
* 'href="http://spatialreference.org/ref/epsg/4326/">' +
|
||||
* 'EPSG:4326</a> coordinates: '
|
||||
* }
|
||||
* );
|
||||
* (end code)
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: autoActivate
|
||||
* {Boolean} Activate the control when it is added to a map. Default is
|
||||
@ -25,50 +37,55 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
autoActivate: true,
|
||||
|
||||
/**
|
||||
/**
|
||||
* Property: element
|
||||
* {DOMElement}
|
||||
* {DOMElement}
|
||||
*/
|
||||
element: null,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* APIProperty: prefix
|
||||
* {String}
|
||||
* {String} A string to be prepended to the current pointers coordinates
|
||||
* when it is rendered. Defaults to the empty string ''.
|
||||
*/
|
||||
prefix: '',
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* APIProperty: separator
|
||||
* {String}
|
||||
* {String} A string to be used to seperate the two coordinates from each
|
||||
* other. Defaults to the string ', ', which will result in a
|
||||
* rendered coordinate of e.g. '42.12, 21.22'.
|
||||
*/
|
||||
separator: ', ',
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* APIProperty: suffix
|
||||
* {String}
|
||||
* {String} A string to be appended to the current pointers coordinates
|
||||
* when it is rendered. Defaults to the empty string ''.
|
||||
*/
|
||||
suffix: '',
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* APIProperty: numDigits
|
||||
* {Integer}
|
||||
* {Integer} The number of digits each coordinate shall have when being
|
||||
* rendered, Defaults to 5.
|
||||
*/
|
||||
numDigits: 5,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* APIProperty: granularity
|
||||
* {Integer}
|
||||
* {Integer}
|
||||
*/
|
||||
granularity: 10,
|
||||
|
||||
/**
|
||||
* APIProperty: emptyString
|
||||
* APIProperty: emptyString
|
||||
* {String} Set this to some value to set when the mouse is outside the
|
||||
* map.
|
||||
*/
|
||||
emptyString: null,
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* Property: lastXy
|
||||
* {<OpenLayers.Pixel>}
|
||||
*/
|
||||
@ -76,20 +93,17 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: displayProjection
|
||||
* {<OpenLayers.Projection>} The projection in which the
|
||||
* mouse position is displayed
|
||||
* {<OpenLayers.Projection>} The projection in which the mouse position is
|
||||
* displayed.
|
||||
*/
|
||||
displayProjection: null,
|
||||
|
||||
displayProjection: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.MousePosition
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Options for control.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
@ -112,7 +126,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: deactivate
|
||||
*/
|
||||
@ -130,7 +144,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
/**
|
||||
* Method: draw
|
||||
* {DOMElement}
|
||||
*/
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
|
||||
@ -139,12 +153,12 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.div.top = "";
|
||||
this.element = this.div;
|
||||
}
|
||||
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: redraw
|
||||
* Method: redraw
|
||||
*/
|
||||
redraw: function(evt) {
|
||||
|
||||
@ -163,18 +177,18 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
|
||||
lonLat = this.map.getLonLatFromPixel(evt.xy);
|
||||
if (!lonLat) {
|
||||
if (!lonLat) {
|
||||
// map has not yet been properly initialized
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.displayProjection) {
|
||||
lonLat.transform(this.map.getProjectionObject(),
|
||||
lonLat.transform(this.map.getProjectionObject(),
|
||||
this.displayProjection );
|
||||
}
|
||||
}
|
||||
this.lastXy = evt.xy;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
var newHtml = this.formatOutput(lonLat);
|
||||
|
||||
if (newHtml != this.element.innerHTML) {
|
||||
@ -203,7 +217,7 @@ OpenLayers.Control.MousePosition = OpenLayers.Class(OpenLayers.Control, {
|
||||
var newHtml =
|
||||
this.prefix +
|
||||
lonLat.lon.toFixed(digits) +
|
||||
this.separator +
|
||||
this.separator +
|
||||
lonLat.lat.toFixed(digits) +
|
||||
this.suffix;
|
||||
return newHtml;
|
||||
|
||||
@ -1,406 +0,0 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/MouseDefaults.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.MouseToolbar
|
||||
* This class is DEPRECATED in 2.4 and will be removed by 3.0.
|
||||
* If you need this functionality, use <OpenLayers.Control.NavToolbar>
|
||||
* instead!!!
|
||||
*/
|
||||
OpenLayers.Control.MouseToolbar = OpenLayers.Class(
|
||||
OpenLayers.Control.MouseDefaults, {
|
||||
|
||||
/**
|
||||
* Property: mode
|
||||
*/
|
||||
mode: null,
|
||||
/**
|
||||
* Property: buttons
|
||||
*/
|
||||
buttons: null,
|
||||
|
||||
/**
|
||||
* APIProperty: direction
|
||||
* {String} 'vertical' or 'horizontal'
|
||||
*/
|
||||
direction: "vertical",
|
||||
|
||||
/**
|
||||
* Property: buttonClicked
|
||||
* {String}
|
||||
*/
|
||||
buttonClicked: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.MouseToolbar
|
||||
*
|
||||
* Parameters:
|
||||
* position - {<OpenLayers.Pixel>}
|
||||
* direction - {String}
|
||||
*/
|
||||
initialize: function(position, direction) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,
|
||||
OpenLayers.Control.MouseToolbar.Y);
|
||||
if (position) {
|
||||
this.position = position;
|
||||
}
|
||||
if (direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
this.measureDivs = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
for( var btnId in this.buttons) {
|
||||
var btn = this.buttons[btnId];
|
||||
btn.map = null;
|
||||
btn.events.destroy();
|
||||
}
|
||||
OpenLayers.Control.MouseDefaults.prototype.destroy.apply(this,
|
||||
arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
OpenLayers.Control.MouseDefaults.prototype.draw.apply(this, arguments);
|
||||
this.buttons = {};
|
||||
var sz = new OpenLayers.Size(28,28);
|
||||
var centered = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,0);
|
||||
this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area");
|
||||
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
|
||||
this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
|
||||
centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
|
||||
this.switchModeTo("pan");
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: _addButton
|
||||
*/
|
||||
_addButton:function(id, img, activeImg, xy, sz, title) {
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation() + img;
|
||||
var activeImgLocation = OpenLayers.Util.getImagesLocation() + activeImg;
|
||||
// var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz);
|
||||
var btn = OpenLayers.Util.createAlphaImageDiv(
|
||||
"OpenLayers_Control_MouseToolbar_" + id,
|
||||
xy, sz, imgLocation, "absolute");
|
||||
|
||||
//we want to add the outer div
|
||||
this.div.appendChild(btn);
|
||||
btn.imgLocation = imgLocation;
|
||||
btn.activeImgLocation = activeImgLocation;
|
||||
|
||||
btn.events = new OpenLayers.Events(this, btn, null, true);
|
||||
btn.events.on({
|
||||
"mousedown": this.buttonDown,
|
||||
"mouseup": this.buttonUp,
|
||||
"dblclick": OpenLayers.Event.stop,
|
||||
scope: this
|
||||
});
|
||||
btn.action = id;
|
||||
btn.title = title;
|
||||
btn.alt = title;
|
||||
btn.map = this.map;
|
||||
|
||||
//we want to remember/reference the outer div
|
||||
this.buttons[id] = btn;
|
||||
return btn;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: buttonDown
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
buttonDown: function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
this.buttonClicked = evt.element.action;
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: buttonUp
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
buttonUp: function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
if (this.buttonClicked != null) {
|
||||
if (this.buttonClicked == evt.element.action) {
|
||||
this.switchModeTo(evt.element.action);
|
||||
}
|
||||
OpenLayers.Event.stop(evt);
|
||||
this.buttonClicked = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultDblClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultDblClick: function (evt) {
|
||||
this.switchModeTo("pan");
|
||||
this.performedDrag = false;
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
OpenLayers.Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseDown
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseDown: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
this.performedDrag = false;
|
||||
this.startViaKeyboard = false;
|
||||
if (evt.shiftKey && this.mode !="zoombox") {
|
||||
this.switchModeTo("zoombox");
|
||||
this.startViaKeyboard = true;
|
||||
} else if (evt.altKey && this.mode !="measure") {
|
||||
this.switchModeTo("measure");
|
||||
} else if (!this.mode) {
|
||||
this.switchModeTo("pan");
|
||||
}
|
||||
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
this.map.div.style.cursor = "crosshair";
|
||||
this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
|
||||
this.mouseDragStart,
|
||||
null,
|
||||
null,
|
||||
"absolute",
|
||||
"2px solid red");
|
||||
this.zoomBox.style.backgroundColor = "white";
|
||||
this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
|
||||
this.zoomBox.style.opacity = "0.50";
|
||||
this.zoomBox.style.fontSize = "1px";
|
||||
this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.viewPortDiv.appendChild(this.zoomBox);
|
||||
this.performedDrag = true;
|
||||
break;
|
||||
case "measure":
|
||||
var distance = "";
|
||||
if (this.measureStart) {
|
||||
var measureEnd = this.map.getLonLatFromViewPortPx(this.mouseDragStart);
|
||||
distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd);
|
||||
distance = Math.round(distance * 100) / 100;
|
||||
distance = distance + "km";
|
||||
this.measureStartBox = this.measureBox;
|
||||
}
|
||||
this.measureStart = this.map.getLonLatFromViewPortPx(this.mouseDragStart);;
|
||||
this.measureBox = OpenLayers.Util.createDiv(null,
|
||||
this.mouseDragStart.add(
|
||||
-2-parseInt(this.map.layerContainerDiv.style.left),
|
||||
-2-parseInt(this.map.layerContainerDiv.style.top)),
|
||||
null,
|
||||
null,
|
||||
"absolute");
|
||||
this.measureBox.style.width="4px";
|
||||
this.measureBox.style.height="4px";
|
||||
this.measureBox.style.fontSize = "1px";
|
||||
this.measureBox.style.backgroundColor="red";
|
||||
this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.layerContainerDiv.appendChild(this.measureBox);
|
||||
if (distance) {
|
||||
this.measureBoxDistance = OpenLayers.Util.createDiv(null,
|
||||
this.mouseDragStart.add(
|
||||
-2-parseInt(this.map.layerContainerDiv.style.left),
|
||||
2-parseInt(this.map.layerContainerDiv.style.top)),
|
||||
null,
|
||||
null,
|
||||
"absolute");
|
||||
|
||||
this.measureBoxDistance.innerHTML = distance;
|
||||
this.measureBoxDistance.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.layerContainerDiv.appendChild(this.measureBoxDistance);
|
||||
this.measureDivs.push(this.measureBoxDistance);
|
||||
}
|
||||
this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
|
||||
this.map.layerContainerDiv.appendChild(this.measureBox);
|
||||
this.measureDivs.push(this.measureBox);
|
||||
break;
|
||||
default:
|
||||
this.map.div.style.cursor = "move";
|
||||
break;
|
||||
}
|
||||
document.onselectstart = OpenLayers.Function.False;
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: switchModeTo
|
||||
*
|
||||
* Parameters:
|
||||
* mode - {String}
|
||||
*/
|
||||
switchModeTo: function(mode) {
|
||||
if (mode != this.mode) {
|
||||
|
||||
|
||||
if (this.mode && this.buttons[this.mode]) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
|
||||
}
|
||||
if (this.mode == "measure" && mode != "measure") {
|
||||
for(var i=0, len=this.measureDivs.length; i<len; i++) {
|
||||
if (this.measureDivs[i]) {
|
||||
this.map.layerContainerDiv.removeChild(this.measureDivs[i]);
|
||||
}
|
||||
}
|
||||
this.measureDivs = [];
|
||||
this.measureStart = null;
|
||||
}
|
||||
this.mode = mode;
|
||||
if (this.buttons[mode]) {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
|
||||
}
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
this.map.div.style.cursor = "crosshair";
|
||||
break;
|
||||
default:
|
||||
this.map.div.style.cursor = "";
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: leaveMode
|
||||
*/
|
||||
leaveMode: function() {
|
||||
this.switchModeTo("pan");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseMove
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseMove: function (evt) {
|
||||
if (this.mouseDragStart != null) {
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
|
||||
var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
|
||||
this.zoomBox.style.width = Math.max(1, deltaX) + "px";
|
||||
this.zoomBox.style.height = Math.max(1, deltaY) + "px";
|
||||
if (evt.xy.x < this.mouseDragStart.x) {
|
||||
this.zoomBox.style.left = evt.xy.x+"px";
|
||||
}
|
||||
if (evt.xy.y < this.mouseDragStart.y) {
|
||||
this.zoomBox.style.top = evt.xy.y+"px";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
var deltaX = this.mouseDragStart.x - evt.xy.x;
|
||||
var deltaY = this.mouseDragStart.y - evt.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.mouseDragStart = evt.xy.clone();
|
||||
}
|
||||
this.performedDrag = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseUp
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseUp: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
switch (this.mode) {
|
||||
case "zoombox":
|
||||
this.zoomBoxEnd(evt);
|
||||
if (this.startViaKeyboard) {
|
||||
this.leaveMode();
|
||||
}
|
||||
break;
|
||||
case "pan":
|
||||
if (this.performedDrag) {
|
||||
this.map.setCenter(this.map.center);
|
||||
}
|
||||
}
|
||||
document.onselectstart = null;
|
||||
this.mouseDragStart = null;
|
||||
this.map.div.style.cursor = "default";
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultMouseOut
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultMouseOut: function (evt) {
|
||||
if (this.mouseDragStart != null
|
||||
&& OpenLayers.Util.mouseLeft(evt, this.map.div)) {
|
||||
if (this.zoomBox) {
|
||||
this.removeZoomBox();
|
||||
if (this.startViaKeyboard) {
|
||||
this.leaveMode();
|
||||
}
|
||||
}
|
||||
this.mouseDragStart = null;
|
||||
this.map.div.style.cursor = "default";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultClick: function (evt) {
|
||||
if (this.performedDrag) {
|
||||
this.performedDrag = false;
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.MouseToolbar"
|
||||
});
|
||||
|
||||
OpenLayers.Control.MouseToolbar.X = 6;
|
||||
OpenLayers.Control.MouseToolbar.Y = 300;
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -47,7 +47,9 @@ OpenLayers.Control.NavToolbar = OpenLayers.Class(OpenLayers.Control.Panel, {
|
||||
*/
|
||||
draw: function() {
|
||||
var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);
|
||||
this.activateControl(this.controls[0]);
|
||||
if (this.defaultControl === null) {
|
||||
this.defaultControl = this.controls[0];
|
||||
}
|
||||
return div;
|
||||
},
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -32,11 +32,23 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
dragPan: null,
|
||||
|
||||
/**
|
||||
* APIProprety: dragPanOptions
|
||||
* APIProperty: dragPanOptions
|
||||
* {Object} Options passed to the DragPan control.
|
||||
*/
|
||||
dragPanOptions: null,
|
||||
|
||||
/**
|
||||
* Property: pinchZoom
|
||||
* {<OpenLayers.Control.PinchZoom>}
|
||||
*/
|
||||
pinchZoom: null,
|
||||
|
||||
/**
|
||||
* APIProperty: pinchZoomOptions
|
||||
* {Object} Options passed to the PinchZoom control.
|
||||
*/
|
||||
pinchZoomOptions: null,
|
||||
|
||||
/**
|
||||
* APIProperty: documentDrag
|
||||
* {Boolean} Allow panning of the map by dragging outside map viewport.
|
||||
@ -65,7 +77,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
/**
|
||||
* Property: mouseWheelOptions
|
||||
* {Object} Options passed to the MouseWheel control (only useful if
|
||||
* <zoomWheelEnabled> is set to true)
|
||||
* <zoomWheelEnabled> is set to true). Default is no options for maps
|
||||
* with fractionalZoom set to true, otherwise
|
||||
* {cumulative: false, interval: 50, maxDelta: 6}
|
||||
*/
|
||||
mouseWheelOptions: null,
|
||||
|
||||
@ -82,7 +96,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* You should probably set handleRightClicks to true if you use this
|
||||
* with MOD_CTRL, to disable the context menu for machines which use
|
||||
* CTRL-Click as a right click.
|
||||
* Default: <OpenLayers.Handler.MOD_SHIFT
|
||||
* Default: <OpenLayers.Handler.MOD_SHIFT>
|
||||
*/
|
||||
zoomBoxKeyMask: OpenLayers.Handler.MOD_SHIFT,
|
||||
|
||||
@ -124,6 +138,12 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.zoomBox.destroy();
|
||||
}
|
||||
this.zoomBox = null;
|
||||
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.destroy();
|
||||
}
|
||||
this.pinchZoom = null;
|
||||
|
||||
OpenLayers.Control.prototype.destroy.apply(this,arguments);
|
||||
},
|
||||
|
||||
@ -139,6 +159,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (this.zoomBoxEnabled) {
|
||||
this.zoomBox.activate();
|
||||
}
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.activate();
|
||||
}
|
||||
return OpenLayers.Control.prototype.activate.apply(this,arguments);
|
||||
},
|
||||
|
||||
@ -146,6 +169,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: deactivate
|
||||
*/
|
||||
deactivate: function() {
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.deactivate();
|
||||
}
|
||||
this.zoomBox.deactivate();
|
||||
this.dragPan.deactivate();
|
||||
this.handlers.click.deactivate();
|
||||
@ -163,6 +189,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
|
||||
var clickCallbacks = {
|
||||
'click': this.defaultClick,
|
||||
'dblclick': this.defaultDblClick,
|
||||
'dblrightclick': this.defaultDblRightClick
|
||||
};
|
||||
@ -183,10 +210,32 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
{map: this.map, keyMask: this.zoomBoxKeyMask});
|
||||
this.dragPan.draw();
|
||||
this.zoomBox.draw();
|
||||
var wheelOptions = this.map.fractionalZoom ? {} : {
|
||||
cumulative: false,
|
||||
interval: 50,
|
||||
maxDelta: 6
|
||||
};
|
||||
this.handlers.wheel = new OpenLayers.Handler.MouseWheel(
|
||||
this, {"up" : this.wheelUp,
|
||||
"down": this.wheelDown},
|
||||
this.mouseWheelOptions );
|
||||
this, {up : this.wheelUp, down: this.wheelDown},
|
||||
OpenLayers.Util.extend(wheelOptions, this.mouseWheelOptions)
|
||||
);
|
||||
if (OpenLayers.Control.PinchZoom) {
|
||||
this.pinchZoom = new OpenLayers.Control.PinchZoom(
|
||||
OpenLayers.Util.extend(
|
||||
{map: this.map}, this.pinchZoomOptions));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultClick: function (evt) {
|
||||
if (evt.lastTouches && evt.lastTouches.length == 2) {
|
||||
this.map.zoomOut();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -196,8 +245,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultDblClick: function (evt) {
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom + 1);
|
||||
this.map.zoomTo(this.map.zoom + 1, evt.xy);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -207,8 +255,7 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultDblRightClick: function (evt) {
|
||||
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
|
||||
this.map.setCenter(newCenter, this.map.zoom - 1);
|
||||
this.map.zoomTo(this.map.zoom - 1, evt.xy);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -219,22 +266,17 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* deltaZ - {Integer}
|
||||
*/
|
||||
wheelChange: function(evt, deltaZ) {
|
||||
var currentZoom = this.map.getZoom();
|
||||
var newZoom = this.map.getZoom() + Math.round(deltaZ);
|
||||
if (!this.map.fractionalZoom) {
|
||||
deltaZ = Math.round(deltaZ);
|
||||
}
|
||||
var currentZoom = this.map.getZoom(),
|
||||
newZoom = currentZoom + deltaZ;
|
||||
newZoom = Math.max(newZoom, 0);
|
||||
newZoom = Math.min(newZoom, this.map.getNumZoomLevels());
|
||||
if (newZoom === currentZoom) {
|
||||
return;
|
||||
}
|
||||
var size = this.map.getSize();
|
||||
var deltaX = size.w/2 - evt.xy.x;
|
||||
var deltaY = evt.xy.y - size.h/2;
|
||||
var newRes = this.map.baseLayer.getResolutionForZoom(newZoom);
|
||||
var zoomPoint = this.map.getLonLatFromPixel(evt.xy);
|
||||
var newCenter = new OpenLayers.LonLat(
|
||||
zoomPoint.lon + deltaX * newRes,
|
||||
zoomPoint.lat + deltaY * newRes );
|
||||
this.map.setCenter( newCenter, newZoom );
|
||||
this.map.zoomTo(newZoom, evt.xy);
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/BaseTypes.js
|
||||
* @requires OpenLayers/Events.js
|
||||
* @requires OpenLayers/Events/buttonclick.js
|
||||
* @requires OpenLayers/Map.js
|
||||
* @requires OpenLayers/Handler/Click.js
|
||||
* @requires OpenLayers/Handler/Drag.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -17,7 +20,7 @@
|
||||
* the lower right corner of the main map. Create a new overview map with the
|
||||
* <OpenLayers.Control.OverviewMap> constructor.
|
||||
*
|
||||
* Inerits from:
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
@ -41,7 +44,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
* class name olControlOverviewMapElement) may have padding or other style
|
||||
* attributes added via CSS.
|
||||
*/
|
||||
size: new OpenLayers.Size(180, 90),
|
||||
size: {w: 180, h: 90},
|
||||
|
||||
/**
|
||||
* APIProperty: layers
|
||||
@ -127,12 +130,26 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
maximized: false,
|
||||
|
||||
/**
|
||||
* APIProperty: maximizeTitle
|
||||
* {String} This property is used for showing a tooltip over the
|
||||
* maximize div. Defaults to "" (no title).
|
||||
*/
|
||||
maximizeTitle: "",
|
||||
|
||||
/**
|
||||
* APIProperty: minimizeTitle
|
||||
* {String} This property is used for showing a tooltip over the
|
||||
* minimize div. Defaults to "" (no title).
|
||||
*/
|
||||
minimizeTitle: "",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.OverviewMap
|
||||
* Create a new overview map
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} Properties of this object will be set on the overview
|
||||
* options - {Object} Properties of this object will be set on the overview
|
||||
* map object. Note, to set options on the map object contained in this
|
||||
* control, set <mapOptions> as one of the options properties.
|
||||
*/
|
||||
@ -157,7 +174,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.handlers.drag.destroy();
|
||||
}
|
||||
|
||||
this.mapDiv.removeChild(this.extentRectangle);
|
||||
this.ovmap && this.ovmap.viewPortDiv.removeChild(this.extentRectangle);
|
||||
this.extentRectangle = null;
|
||||
|
||||
if (this.rectEvents) {
|
||||
@ -177,20 +194,19 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.element = null;
|
||||
|
||||
if (this.maximizeDiv) {
|
||||
OpenLayers.Event.stopObservingElement(this.maximizeDiv);
|
||||
this.div.removeChild(this.maximizeDiv);
|
||||
this.maximizeDiv = null;
|
||||
}
|
||||
|
||||
if (this.minimizeDiv) {
|
||||
OpenLayers.Event.stopObservingElement(this.minimizeDiv);
|
||||
this.div.removeChild(this.minimizeDiv);
|
||||
this.minimizeDiv = null;
|
||||
}
|
||||
|
||||
this.map.events.un({
|
||||
"moveend": this.update,
|
||||
"changebaselayer": this.baseLayerDraw,
|
||||
buttonclick: this.onButtonClick,
|
||||
moveend: this.update,
|
||||
changebaselayer: this.baseLayerDraw,
|
||||
scope: this
|
||||
});
|
||||
|
||||
@ -203,7 +219,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
if(!(this.layers.length > 0)) {
|
||||
if (this.layers.length === 0) {
|
||||
if (this.map.baseLayer) {
|
||||
var layer = this.map.baseLayer.clone();
|
||||
this.layers = [layer];
|
||||
@ -229,7 +245,6 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.extentRectangle.style.position = 'absolute';
|
||||
this.extentRectangle.style.zIndex = 1000; //HACK
|
||||
this.extentRectangle.className = this.displayClass+'ExtentRectangle';
|
||||
this.mapDiv.appendChild(this.extentRectangle);
|
||||
|
||||
this.element.appendChild(this.mapDiv);
|
||||
|
||||
@ -239,52 +254,35 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
// map viewport.
|
||||
if(!this.outsideViewport) {
|
||||
this.div.className += " " + this.displayClass + 'Container';
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
// maximize button div
|
||||
var img = imgLocation + 'layer-switcher-maximize.png';
|
||||
var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');
|
||||
this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
this.displayClass + 'MaximizeButton',
|
||||
null,
|
||||
new OpenLayers.Size(18,18),
|
||||
null,
|
||||
img,
|
||||
'absolute');
|
||||
this.maximizeDiv.style.display = 'none';
|
||||
this.maximizeDiv.className = this.displayClass + 'MaximizeButton';
|
||||
OpenLayers.Event.observe(this.maximizeDiv, 'click',
|
||||
OpenLayers.Function.bindAsEventListener(this.maximizeControl,
|
||||
this)
|
||||
);
|
||||
this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton';
|
||||
if (this.maximizeTitle) {
|
||||
this.maximizeDiv.title = this.maximizeTitle;
|
||||
}
|
||||
this.div.appendChild(this.maximizeDiv);
|
||||
|
||||
// minimize button div
|
||||
var img = imgLocation + 'layer-switcher-minimize.png';
|
||||
var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');
|
||||
this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(
|
||||
'OpenLayers_Control_minimizeDiv',
|
||||
null,
|
||||
new OpenLayers.Size(18,18),
|
||||
null,
|
||||
img,
|
||||
'absolute');
|
||||
this.minimizeDiv.style.display = 'none';
|
||||
this.minimizeDiv.className = this.displayClass + 'MinimizeButton';
|
||||
OpenLayers.Event.observe(this.minimizeDiv, 'click',
|
||||
OpenLayers.Function.bindAsEventListener(this.minimizeControl,
|
||||
this)
|
||||
);
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
|
||||
var eventsToStop = ['dblclick','mousedown'];
|
||||
|
||||
for (var i=0, len=eventsToStop.length; i<len; i++) {
|
||||
|
||||
OpenLayers.Event.observe(this.maximizeDiv,
|
||||
eventsToStop[i],
|
||||
OpenLayers.Event.stop);
|
||||
|
||||
OpenLayers.Event.observe(this.minimizeDiv,
|
||||
eventsToStop[i],
|
||||
OpenLayers.Event.stop);
|
||||
this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton';
|
||||
if (this.minimizeTitle) {
|
||||
this.minimizeDiv.title = this.minimizeTitle;
|
||||
}
|
||||
|
||||
this.div.appendChild(this.minimizeDiv);
|
||||
this.minimizeControl();
|
||||
} else {
|
||||
// show the overview map
|
||||
@ -294,7 +292,11 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.update();
|
||||
}
|
||||
|
||||
this.map.events.register('moveend', this, this.update);
|
||||
this.map.events.on({
|
||||
buttonclick: this.onButtonClick,
|
||||
moveend: this.update,
|
||||
scope: this
|
||||
});
|
||||
|
||||
if (this.maximized) {
|
||||
this.maximizeControl();
|
||||
@ -365,6 +367,20 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
newTop));
|
||||
this.updateMapToRect();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onButtonClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
onButtonClick: function(evt) {
|
||||
if (evt.buttonElement === this.minimizeDiv) {
|
||||
this.minimizeControl();
|
||||
} else if (evt.buttonElement === this.maximizeDiv) {
|
||||
this.maximizeControl();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: maximizeControl
|
||||
@ -405,8 +421,12 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
* minimize - {Boolean}
|
||||
*/
|
||||
showToggle: function(minimize) {
|
||||
this.maximizeDiv.style.display = minimize ? '' : 'none';
|
||||
this.minimizeDiv.style.display = minimize ? 'none' : '';
|
||||
if (this.maximizeDiv) {
|
||||
this.maximizeDiv.style.display = minimize ? '' : 'none';
|
||||
}
|
||||
if (this.minimizeDiv) {
|
||||
this.minimizeDiv.style.display = minimize ? 'none' : '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -433,7 +453,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
isSuitableOverview: function() {
|
||||
var mapExtent = this.map.getExtent();
|
||||
var maxExtent = this.map.maxExtent;
|
||||
var maxExtent = this.map.getMaxExtent();
|
||||
var testExtent = new OpenLayers.Bounds(
|
||||
Math.max(mapExtent.left, maxExtent.left),
|
||||
Math.max(mapExtent.bottom, maxExtent.bottom),
|
||||
@ -490,6 +510,7 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
{controls: [], maxResolution: 'auto',
|
||||
fallThrough: false}, this.mapOptions);
|
||||
this.ovmap = new OpenLayers.Map(this.mapDiv, options);
|
||||
this.ovmap.viewPortDiv.appendChild(this.extentRectangle);
|
||||
|
||||
// prevent ovmap from being destroyed when the page unloads, because
|
||||
// the OverviewMap control has to do this (and does it).
|
||||
@ -634,12 +655,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
* translated into pixel bounds for the overview map
|
||||
*/
|
||||
getRectBoundsFromMapBounds: function(lonLatBounds) {
|
||||
var leftBottomLonLat = new OpenLayers.LonLat(lonLatBounds.left,
|
||||
lonLatBounds.bottom);
|
||||
var rightTopLonLat = new OpenLayers.LonLat(lonLatBounds.right,
|
||||
lonLatBounds.top);
|
||||
var leftBottomPx = this.getOverviewPxFromLonLat(leftBottomLonLat);
|
||||
var rightTopPx = this.getOverviewPxFromLonLat(rightTopLonLat);
|
||||
var leftBottomPx = this.getOverviewPxFromLonLat({
|
||||
lon: lonLatBounds.left,
|
||||
lat: lonLatBounds.bottom
|
||||
});
|
||||
var rightTopPx = this.getOverviewPxFromLonLat({
|
||||
lon: lonLatBounds.right,
|
||||
lat: lonLatBounds.top
|
||||
});
|
||||
var bounds = null;
|
||||
if (leftBottomPx && rightTopPx) {
|
||||
bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,
|
||||
@ -660,12 +683,14 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
* translated into lon/lat bounds for the overview map
|
||||
*/
|
||||
getMapBoundsFromRectBounds: function(pxBounds) {
|
||||
var leftBottomPx = new OpenLayers.Pixel(pxBounds.left,
|
||||
pxBounds.bottom);
|
||||
var rightTopPx = new OpenLayers.Pixel(pxBounds.right,
|
||||
pxBounds.top);
|
||||
var leftBottomLonLat = this.getLonLatFromOverviewPx(leftBottomPx);
|
||||
var rightTopLonLat = this.getLonLatFromOverviewPx(rightTopPx);
|
||||
var leftBottomLonLat = this.getLonLatFromOverviewPx({
|
||||
x: pxBounds.left,
|
||||
y: pxBounds.bottom
|
||||
});
|
||||
var rightTopLonLat = this.getLonLatFromOverviewPx({
|
||||
x: pxBounds.right,
|
||||
y: pxBounds.top
|
||||
});
|
||||
return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat,
|
||||
rightTopLonLat.lon, rightTopLonLat.lat);
|
||||
},
|
||||
@ -675,22 +700,27 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Get a map location from a pixel location
|
||||
*
|
||||
* Parameters:
|
||||
* overviewMapPx - {<OpenLayers.Pixel>}
|
||||
* overviewMapPx - {<OpenLayers.Pixel>|Object} OpenLayers.Pixel or
|
||||
* an object with a
|
||||
* 'x' and 'y' properties.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.LonLat>} Location which is the passed-in overview map
|
||||
* OpenLayers.Pixel, translated into lon/lat by the overview map
|
||||
* {Object} Location which is the passed-in overview map
|
||||
* OpenLayers.Pixel, translated into lon/lat by the overview
|
||||
* map. An object with a 'lon' and 'lat' properties.
|
||||
*/
|
||||
getLonLatFromOverviewPx: function(overviewMapPx) {
|
||||
var size = this.ovmap.size;
|
||||
var res = this.ovmap.getResolution();
|
||||
var center = this.ovmap.getExtent().getCenterLonLat();
|
||||
|
||||
var delta_x = overviewMapPx.x - (size.w / 2);
|
||||
var delta_y = overviewMapPx.y - (size.h / 2);
|
||||
|
||||
return new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
var deltaX = overviewMapPx.x - (size.w / 2);
|
||||
var deltaY = overviewMapPx.y - (size.h / 2);
|
||||
|
||||
return {
|
||||
lon: center.lon + deltaX * res,
|
||||
lat: center.lat - deltaY * res
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
@ -698,22 +728,22 @@ OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Get a pixel location from a map location
|
||||
*
|
||||
* Parameters:
|
||||
* lonlat - {<OpenLayers.LonLat>}
|
||||
* lonlat - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
|
||||
* object with a 'lon' and 'lat' properties.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Pixel>} Location which is the passed-in OpenLayers.LonLat,
|
||||
* {Object} Location which is the passed-in OpenLayers.LonLat,
|
||||
* translated into overview map pixels
|
||||
*/
|
||||
getOverviewPxFromLonLat: function(lonlat) {
|
||||
var res = this.ovmap.getResolution();
|
||||
var res = this.ovmap.getResolution();
|
||||
var extent = this.ovmap.getExtent();
|
||||
var px = null;
|
||||
if (extent) {
|
||||
px = new OpenLayers.Pixel(
|
||||
Math.round(1/res * (lonlat.lon - extent.left)),
|
||||
Math.round(1/res * (extent.top - lonlat.lat)));
|
||||
return {
|
||||
x: Math.round(1/res * (lonlat.lon - extent.left)),
|
||||
y: Math.round(1/res * (extent.top - lonlat.lat))
|
||||
};
|
||||
}
|
||||
return px;
|
||||
},
|
||||
|
||||
CLASS_NAME: 'OpenLayers.Control.OverviewMap'
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/Button.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -15,29 +15,31 @@
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control.Button, {
|
||||
|
||||
/**
|
||||
* APIProperty: slideFactor
|
||||
* {Integer} Number of pixels by which we'll pan the map in any direction
|
||||
* on clicking the arrow buttons, defaults to 50.
|
||||
* on clicking the arrow buttons, defaults to 50. If you want to pan
|
||||
* by some ratio of the map dimensions, use <slideRatio> instead.
|
||||
*/
|
||||
slideFactor: 50,
|
||||
|
||||
/**
|
||||
* APIProperty: slideRatio
|
||||
* {Number} The fraction of map width/height by which we'll pan the map
|
||||
* on clicking the arrow buttons. Default is null. If set, will
|
||||
* override <slideFactor>. E.g. if slideRatio is .5, then Pan Up will
|
||||
* pan up half the map height.
|
||||
*/
|
||||
slideRatio: null,
|
||||
|
||||
/**
|
||||
* Property: direction
|
||||
* {String} in {'North', 'South', 'East', 'West'}
|
||||
*/
|
||||
direction: null,
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* {String} The type of <OpenLayers.Control> -- When added to a
|
||||
* <Control.Panel>, 'type' is used by the panel to determine how to
|
||||
* handle our events.
|
||||
*/
|
||||
type: OpenLayers.Control.TYPE_BUTTON,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.Pan
|
||||
* Control which handles the panning (in any of the cardinal directions)
|
||||
@ -60,20 +62,27 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: trigger
|
||||
*/
|
||||
trigger: function(){
|
||||
if (this.map) {
|
||||
var getSlideFactor = OpenLayers.Function.bind(function (dim) {
|
||||
return this.slideRatio ?
|
||||
this.map.getSize()[dim] * this.slideRatio :
|
||||
this.slideFactor;
|
||||
}, this);
|
||||
|
||||
switch (this.direction) {
|
||||
case OpenLayers.Control.Pan.NORTH:
|
||||
this.map.pan(0, -this.slideFactor);
|
||||
break;
|
||||
case OpenLayers.Control.Pan.SOUTH:
|
||||
this.map.pan(0, this.slideFactor);
|
||||
break;
|
||||
case OpenLayers.Control.Pan.WEST:
|
||||
this.map.pan(-this.slideFactor, 0);
|
||||
break;
|
||||
case OpenLayers.Control.Pan.EAST:
|
||||
this.map.pan(this.slideFactor, 0);
|
||||
break;
|
||||
switch (this.direction) {
|
||||
case OpenLayers.Control.Pan.NORTH:
|
||||
this.map.pan(0, -getSlideFactor("h"));
|
||||
break;
|
||||
case OpenLayers.Control.Pan.SOUTH:
|
||||
this.map.pan(0, getSlideFactor("h"));
|
||||
break;
|
||||
case OpenLayers.Control.Pan.WEST:
|
||||
this.map.pan(-getSlideFactor("w"), 0);
|
||||
break;
|
||||
case OpenLayers.Control.Pan.EAST:
|
||||
this.map.pan(getSlideFactor("w"), 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -33,10 +33,20 @@ OpenLayers.Control.PanPanel = OpenLayers.Class(OpenLayers.Control.Panel, {
|
||||
/**
|
||||
* APIProperty: slideFactor
|
||||
* {Integer} Number of pixels by which we'll pan the map in any direction
|
||||
* on clicking the arrow buttons, defaults to 50.
|
||||
* on clicking the arrow buttons, defaults to 50. If you want to pan
|
||||
* by some ratio of the map dimensions, use <slideRatio> instead.
|
||||
*/
|
||||
slideFactor: 50,
|
||||
|
||||
/**
|
||||
* APIProperty: slideRatio
|
||||
* {Number} The fraction of map width/height by which we'll pan the map
|
||||
* on clicking the arrow buttons. Default is null. If set, will
|
||||
* override <slideFactor>. E.g. if slideRatio is .5, then Pan Up will
|
||||
* pan up half the map height.
|
||||
*/
|
||||
slideRatio: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.PanPanel
|
||||
* Add the four directional pan buttons.
|
||||
@ -47,15 +57,15 @@ OpenLayers.Control.PanPanel = OpenLayers.Class(OpenLayers.Control.Panel, {
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);
|
||||
var options = {
|
||||
slideFactor: this.slideFactor,
|
||||
slideRatio: this.slideRatio
|
||||
};
|
||||
this.addControls([
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH,
|
||||
{slideFactor: this.slideFactor}),
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH,
|
||||
{slideFactor: this.slideFactor}),
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST,
|
||||
{slideFactor: this.slideFactor}),
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST,
|
||||
{slideFactor: this.slideFactor})
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.NORTH, options),
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.SOUTH, options),
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.EAST, options),
|
||||
new OpenLayers.Control.Pan(OpenLayers.Control.Pan.WEST, options)
|
||||
]);
|
||||
},
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Events/buttonclick.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -64,10 +65,24 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
if (this.map) {
|
||||
this.map.events.unregister("buttonclick", this, this.onButtonClick);
|
||||
}
|
||||
this.removeButtons();
|
||||
this.buttons = null;
|
||||
this.position = null;
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setMap
|
||||
*
|
||||
* Properties:
|
||||
* map - {<OpenLayers.Map>}
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
this.map.events.register("buttonclick", this, this.onButtonClick);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -87,7 +102,7 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
// place the controls
|
||||
this.buttons = [];
|
||||
|
||||
var sz = new OpenLayers.Size(18,18);
|
||||
var sz = {w: 18, h: 18};
|
||||
var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
|
||||
|
||||
this._addButton("panup", "north-mini.png", centered, sz);
|
||||
@ -119,37 +134,16 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
* image of the button, and has all the proper event handlers set.
|
||||
*/
|
||||
_addButton:function(id, img, xy, sz) {
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation() + img;
|
||||
var imgLocation = OpenLayers.Util.getImageLocation(img);
|
||||
var btn = OpenLayers.Util.createAlphaImageDiv(
|
||||
this.id + "_" + id,
|
||||
xy, sz, imgLocation, "absolute");
|
||||
|
||||
btn.style.cursor = "pointer";
|
||||
//we want to add the outer div
|
||||
this.div.appendChild(btn);
|
||||
|
||||
OpenLayers.Event.observe(btn, "mousedown",
|
||||
OpenLayers.Function.bindAsEventListener(this.buttonDown, btn));
|
||||
OpenLayers.Event.observe(btn, "dblclick",
|
||||
OpenLayers.Function.bindAsEventListener(this.doubleClick, btn));
|
||||
OpenLayers.Event.observe(btn, "click",
|
||||
OpenLayers.Function.bindAsEventListener(this.doubleClick, btn));
|
||||
btn.action = id;
|
||||
btn.map = this.map;
|
||||
btn.className = "olButton";
|
||||
|
||||
if(!this.slideRatio){
|
||||
var slideFactorPixels = this.slideFactor;
|
||||
var getSlideFactor = function() {
|
||||
return slideFactorPixels;
|
||||
};
|
||||
} else {
|
||||
var slideRatio = this.slideRatio;
|
||||
var getSlideFactor = function(dim) {
|
||||
return this.map.getSize()[dim] * slideRatio;
|
||||
};
|
||||
}
|
||||
|
||||
btn.getSlideFactor = getSlideFactor;
|
||||
|
||||
//we want to remember/reference the outer div
|
||||
this.buttons.push(btn);
|
||||
return btn;
|
||||
@ -162,9 +156,6 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
* btn - {Object}
|
||||
*/
|
||||
_removeButton: function(btn) {
|
||||
OpenLayers.Event.stopObservingElement(btn);
|
||||
btn.map = null;
|
||||
btn.getSlideFactor = null;
|
||||
this.div.removeChild(btn);
|
||||
OpenLayers.Util.removeItem(this.buttons, btn);
|
||||
},
|
||||
@ -179,31 +170,14 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: doubleClick
|
||||
* Method: onButtonClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean}
|
||||
* evt - {Event}
|
||||
*/
|
||||
doubleClick: function (evt) {
|
||||
OpenLayers.Event.stop(evt);
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: buttonDown
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
buttonDown: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this.action) {
|
||||
onButtonClick: function(evt) {
|
||||
var btn = evt.buttonElement;
|
||||
switch (btn.action) {
|
||||
case "panup":
|
||||
this.map.pan(0, -this.getSlideFactor("h"));
|
||||
break;
|
||||
@ -226,8 +200,21 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.map.zoomToMaxExtent();
|
||||
break;
|
||||
}
|
||||
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getSlideFactor
|
||||
*
|
||||
* Parameters:
|
||||
* dim - {String} "w" or "h" (for width or height).
|
||||
*
|
||||
* Returns:
|
||||
* {Number} The slide factor for panning in the requested direction.
|
||||
*/
|
||||
getSlideFactor: function(dim) {
|
||||
return this.slideRatio ?
|
||||
this.map.getSize()[dim] * this.slideRatio :
|
||||
this.slideFactor;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.PanZoom"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -47,18 +47,20 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
zoombarDiv: null,
|
||||
|
||||
/**
|
||||
* Property: divEvents
|
||||
* {<OpenLayers.Events>}
|
||||
*/
|
||||
divEvents: null,
|
||||
|
||||
/**
|
||||
* APIProperty: zoomWorldIcon
|
||||
* {Boolean}
|
||||
*/
|
||||
zoomWorldIcon: false,
|
||||
|
||||
/**
|
||||
* APIProperty: panIcons
|
||||
* {Boolean} Set this property to false not to display the pan icons. If
|
||||
* false the zoom world icon is placed under the zoom bar. Defaults to
|
||||
* true.
|
||||
*/
|
||||
panIcons: true,
|
||||
|
||||
/**
|
||||
* APIProperty: forceFixedZoomLevel
|
||||
* {Boolean} Force a fixed zoom level even though the map has
|
||||
@ -72,6 +74,12 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
mouseDragStart: null,
|
||||
|
||||
/**
|
||||
* Property: deltaY
|
||||
* {Number} The cumulative vertical pixel offset during a zoom bar drag.
|
||||
*/
|
||||
deltaY: null,
|
||||
|
||||
/**
|
||||
* Property: zoomStart
|
||||
* {<OpenLayers.Pixel>}
|
||||
@ -81,9 +89,6 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.PanZoomBar
|
||||
*/
|
||||
initialize: function() {
|
||||
OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
@ -94,6 +99,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
|
||||
this.map.events.un({
|
||||
"changebaselayer": this.redraw,
|
||||
"updatesize": this.redraw,
|
||||
scope: this
|
||||
});
|
||||
|
||||
@ -111,7 +117,11 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
setMap: function(map) {
|
||||
OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);
|
||||
this.map.events.register("changebaselayer", this, this.redraw);
|
||||
this.map.events.on({
|
||||
"changebaselayer": this.redraw,
|
||||
"updatesize": this.redraw,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@ -140,27 +150,38 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
// place the controls
|
||||
this.buttons = [];
|
||||
|
||||
var sz = new OpenLayers.Size(18,18);
|
||||
var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
|
||||
var wposition = sz.w;
|
||||
var sz = {w: 18, h: 18};
|
||||
if (this.panIcons) {
|
||||
var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
|
||||
var wposition = sz.w;
|
||||
|
||||
if (this.zoomWorldIcon) {
|
||||
centered = new OpenLayers.Pixel(px.x+sz.w, px.y);
|
||||
}
|
||||
if (this.zoomWorldIcon) {
|
||||
centered = new OpenLayers.Pixel(px.x+sz.w, px.y);
|
||||
}
|
||||
|
||||
this._addButton("panup", "north-mini.png", centered, sz);
|
||||
px.y = centered.y+sz.h;
|
||||
this._addButton("panleft", "west-mini.png", px, sz);
|
||||
if (this.zoomWorldIcon) {
|
||||
this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz);
|
||||
|
||||
wposition *= 2;
|
||||
this._addButton("panup", "north-mini.png", centered, sz);
|
||||
px.y = centered.y+sz.h;
|
||||
this._addButton("panleft", "west-mini.png", px, sz);
|
||||
if (this.zoomWorldIcon) {
|
||||
this._addButton("zoomworld", "zoom-world-mini.png", px.add(sz.w, 0), sz);
|
||||
|
||||
wposition *= 2;
|
||||
}
|
||||
this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz);
|
||||
this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz);
|
||||
this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz);
|
||||
centered = this._addZoomBar(centered.add(0, sz.h*4 + 5));
|
||||
this._addButton("zoomout", "zoom-minus-mini.png", centered, sz);
|
||||
}
|
||||
else {
|
||||
this._addButton("zoomin", "zoom-plus-mini.png", px, sz);
|
||||
centered = this._addZoomBar(px.add(0, sz.h));
|
||||
this._addButton("zoomout", "zoom-minus-mini.png", centered, sz);
|
||||
if (this.zoomWorldIcon) {
|
||||
centered = centered.add(0, sz.h+3);
|
||||
this._addButton("zoomworld", "zoom-world-mini.png", centered, sz);
|
||||
}
|
||||
}
|
||||
this._addButton("panright", "east-mini.png", px.add(wposition, 0), sz);
|
||||
this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz);
|
||||
this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz);
|
||||
centered = this._addZoomBar(centered.add(0, sz.h*4 + 5));
|
||||
this._addButton("zoomout", "zoom-minus-mini.png", centered, sz);
|
||||
return this.div;
|
||||
},
|
||||
|
||||
@ -168,41 +189,44 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
* Method: _addZoomBar
|
||||
*
|
||||
* Parameters:
|
||||
* location - {<OpenLayers.Pixel>} where zoombar drawing is to start.
|
||||
* centered - {<OpenLayers.Pixel>} where zoombar drawing is to start.
|
||||
*/
|
||||
_addZoomBar:function(centered) {
|
||||
var imgLocation = OpenLayers.Util.getImagesLocation();
|
||||
|
||||
var imgLocation = OpenLayers.Util.getImageLocation("slider.png");
|
||||
var id = this.id + "_" + this.map.id;
|
||||
var minZoom = this.map.getMinZoom();
|
||||
var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();
|
||||
var slider = OpenLayers.Util.createAlphaImageDiv(id,
|
||||
centered.add(-1, zoomsToEnd * this.zoomStopHeight),
|
||||
new OpenLayers.Size(20,9),
|
||||
imgLocation+"slider.png",
|
||||
{w: 20, h: 9},
|
||||
imgLocation,
|
||||
"absolute");
|
||||
slider.style.cursor = "move";
|
||||
this.slider = slider;
|
||||
|
||||
this.sliderEvents = new OpenLayers.Events(this, slider, null, true,
|
||||
{includeXY: true});
|
||||
this.sliderEvents.on({
|
||||
"touchstart": this.zoomBarDown,
|
||||
"touchmove": this.zoomBarDrag,
|
||||
"touchend": this.zoomBarUp,
|
||||
"mousedown": this.zoomBarDown,
|
||||
"mousemove": this.zoomBarDrag,
|
||||
"mouseup": this.zoomBarUp,
|
||||
"dblclick": this.doubleClick,
|
||||
"click": this.doubleClick
|
||||
"mouseup": this.zoomBarUp
|
||||
});
|
||||
|
||||
var sz = new OpenLayers.Size();
|
||||
sz.h = this.zoomStopHeight * this.map.getNumZoomLevels();
|
||||
sz.w = this.zoomStopWidth;
|
||||
var sz = {
|
||||
w: this.zoomStopWidth,
|
||||
h: this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom)
|
||||
};
|
||||
var imgLocation = OpenLayers.Util.getImageLocation("zoombar.png");
|
||||
var div = null;
|
||||
|
||||
if (OpenLayers.Util.alphaHack()) {
|
||||
var id = this.id + "_" + this.map.id;
|
||||
div = OpenLayers.Util.createAlphaImageDiv(id, centered,
|
||||
new OpenLayers.Size(sz.w,
|
||||
this.zoomStopHeight),
|
||||
imgLocation + "zoombar.png",
|
||||
{w: sz.w, h: this.zoomStopHeight},
|
||||
imgLocation,
|
||||
"absolute", null, "crop");
|
||||
div.style.height = sz.h + "px";
|
||||
} else {
|
||||
@ -210,20 +234,12 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
'OpenLayers_Control_PanZoomBar_Zoombar' + this.map.id,
|
||||
centered,
|
||||
sz,
|
||||
imgLocation+"zoombar.png");
|
||||
imgLocation);
|
||||
}
|
||||
|
||||
div.style.cursor = "pointer";
|
||||
div.className = "olButton";
|
||||
this.zoombarDiv = div;
|
||||
|
||||
this.divEvents = new OpenLayers.Events(this, div, null, true,
|
||||
{includeXY: true});
|
||||
this.divEvents.on({
|
||||
"mousedown": this.divClick,
|
||||
"mousemove": this.passEventToSlider,
|
||||
"dblclick": this.doubleClick,
|
||||
"click": this.doubleClick
|
||||
});
|
||||
|
||||
this.div.appendChild(div);
|
||||
|
||||
this.startTop = parseInt(div.style.top);
|
||||
@ -232,7 +248,7 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
this.map.events.register("zoomend", this, this.moveZoomBar);
|
||||
|
||||
centered = centered.add(0,
|
||||
this.zoomStopHeight * this.map.getNumZoomLevels());
|
||||
this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom));
|
||||
return centered;
|
||||
},
|
||||
|
||||
@ -241,21 +257,14 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
*/
|
||||
_removeZoomBar: function() {
|
||||
this.sliderEvents.un({
|
||||
"touchstart": this.zoomBarDown,
|
||||
"touchmove": this.zoomBarDrag,
|
||||
"touchend": this.zoomBarUp,
|
||||
"mousedown": this.zoomBarDown,
|
||||
"mousemove": this.zoomBarDrag,
|
||||
"mouseup": this.zoomBarUp,
|
||||
"dblclick": this.doubleClick,
|
||||
"click": this.doubleClick
|
||||
"mouseup": this.zoomBarUp
|
||||
});
|
||||
this.sliderEvents.destroy();
|
||||
|
||||
this.divEvents.un({
|
||||
"mousedown": this.divClick,
|
||||
"mousemove": this.passEventToSlider,
|
||||
"dblclick": this.doubleClick,
|
||||
"click": this.doubleClick
|
||||
});
|
||||
this.divEvents.destroy();
|
||||
|
||||
this.div.removeChild(this.zoombarDiv);
|
||||
this.zoombarDiv = null;
|
||||
@ -265,6 +274,25 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
this.map.events.unregister("zoomend", this, this.moveZoomBar);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onButtonClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
onButtonClick: function(evt) {
|
||||
OpenLayers.Control.PanZoom.prototype.onButtonClick.apply(this, arguments);
|
||||
if (evt.buttonElement === this.zoombarDiv) {
|
||||
var levels = evt.buttonXY.y / this.zoomStopHeight;
|
||||
if(this.forceFixedZoomLevel || !this.map.fractionalZoom) {
|
||||
levels = Math.floor(levels);
|
||||
}
|
||||
var zoom = (this.map.getNumZoomLevels() - 1) - levels;
|
||||
zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);
|
||||
this.map.zoomTo(zoom);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: passEventToSlider
|
||||
* This function is used to pass events that happen on the div, or the map,
|
||||
@ -277,27 +305,6 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
this.sliderEvents.handleBrowserEvent(evt);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: divClick
|
||||
* Picks up on clicks directly on the zoombar div
|
||||
* and sets the zoom level appropriately.
|
||||
*/
|
||||
divClick: function (evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
var y = evt.xy.y;
|
||||
var top = OpenLayers.Util.pagePosition(evt.object)[1];
|
||||
var levels = (y - top)/this.zoomStopHeight;
|
||||
if(this.forceFixedZoomLevel || !this.map.fractionalZoom) {
|
||||
levels = Math.floor(levels);
|
||||
}
|
||||
var zoom = (this.map.getNumZoomLevels() - 1) - levels;
|
||||
zoom = Math.min(Math.max(zoom, 0), this.map.getNumZoomLevels() - 1);
|
||||
this.map.zoomTo(zoom);
|
||||
OpenLayers.Event.stop(evt);
|
||||
},
|
||||
|
||||
/*
|
||||
* Method: zoomBarDown
|
||||
* event listener for clicks on the slider
|
||||
@ -306,10 +313,11 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
zoomBarDown:function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt) && !OpenLayers.Event.isSingleTouch(evt)) {
|
||||
return;
|
||||
}
|
||||
this.map.events.on({
|
||||
"touchmove": this.passEventToSlider,
|
||||
"mousemove": this.passEventToSlider,
|
||||
"mouseup": this.passEventToSlider,
|
||||
scope: this
|
||||
@ -342,6 +350,8 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
this.slider.style.top = newTop+"px";
|
||||
this.mouseDragStart = evt.xy.clone();
|
||||
}
|
||||
// set cumulative displacement
|
||||
this.deltaY = this.zoomStart.y - evt.xy.y;
|
||||
OpenLayers.Event.stop(evt);
|
||||
}
|
||||
},
|
||||
@ -355,28 +365,30 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
zoomBarUp:function(evt) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt)) {
|
||||
if (!OpenLayers.Event.isLeftClick(evt) && evt.type !== "touchend") {
|
||||
return;
|
||||
}
|
||||
if (this.mouseDragStart) {
|
||||
this.div.style.cursor="";
|
||||
this.map.events.un({
|
||||
"touchmove": this.passEventToSlider,
|
||||
"mouseup": this.passEventToSlider,
|
||||
"mousemove": this.passEventToSlider,
|
||||
scope: this
|
||||
});
|
||||
var deltaY = this.zoomStart.y - evt.xy.y;
|
||||
var zoomLevel = this.map.zoom;
|
||||
if (!this.forceFixedZoomLevel && this.map.fractionalZoom) {
|
||||
zoomLevel += deltaY/this.zoomStopHeight;
|
||||
zoomLevel += this.deltaY/this.zoomStopHeight;
|
||||
zoomLevel = Math.min(Math.max(zoomLevel, 0),
|
||||
this.map.getNumZoomLevels() - 1);
|
||||
} else {
|
||||
zoomLevel += Math.round(deltaY/this.zoomStopHeight);
|
||||
zoomLevel += this.deltaY/this.zoomStopHeight;
|
||||
zoomLevel = Math.max(Math.round(zoomLevel), 0);
|
||||
}
|
||||
this.map.zoomTo(zoomLevel);
|
||||
this.mouseDragStart = null;
|
||||
this.zoomStart = null;
|
||||
this.deltaY = 0;
|
||||
OpenLayers.Event.stop(evt);
|
||||
}
|
||||
},
|
||||
@ -393,4 +405,4 @@ OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.PanZoomBar"
|
||||
});
|
||||
});
|
||||
@ -1,10 +1,11 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Events/buttonclick.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -46,6 +47,14 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
saveState: false,
|
||||
|
||||
/**
|
||||
* APIProperty: allowDepress
|
||||
* {Boolean} If is true the <OpenLayers.Control.TYPE_TOOL> controls can
|
||||
* be deactivated by clicking the icon that represents them. Default
|
||||
* is false.
|
||||
*/
|
||||
allowDepress: false,
|
||||
|
||||
/**
|
||||
* Property: activeState
|
||||
* {Object} stores the active state of this panel's controls.
|
||||
@ -95,17 +104,19 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.map) {
|
||||
this.map.events.unregister("buttonclick", this, this.onButtonClick);
|
||||
}
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
for(var i = this.controls.length - 1 ; i >= 0; i--) {
|
||||
if(this.controls[i].events) {
|
||||
this.controls[i].events.un({
|
||||
"activate": this.redraw,
|
||||
"deactivate": this.redraw,
|
||||
scope: this
|
||||
for (var ctl, i = this.controls.length - 1; i >= 0; i--) {
|
||||
ctl = this.controls[i];
|
||||
if (ctl.events) {
|
||||
ctl.events.un({
|
||||
activate: this.iconOn,
|
||||
deactivate: this.iconOff
|
||||
});
|
||||
}
|
||||
OpenLayers.Event.stopObservingElement(this.controls[i].panel_div);
|
||||
this.controls[i].panel_div = null;
|
||||
ctl.panel_div = null;
|
||||
}
|
||||
this.activeState = null;
|
||||
},
|
||||
@ -143,6 +154,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
control = this.controls[i];
|
||||
this.activeState[control.id] = control.deactivate();
|
||||
}
|
||||
this.redraw();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@ -157,6 +169,12 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
if (this.outsideViewport) {
|
||||
this.events.attachToElement(this.div);
|
||||
this.events.register("buttonclick", this, this.onButtonClick);
|
||||
} else {
|
||||
this.map.events.register("buttonclick", this, this.onButtonClick);
|
||||
}
|
||||
this.addControlsToMap(this.controls);
|
||||
return this.div;
|
||||
},
|
||||
@ -165,25 +183,17 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: redraw
|
||||
*/
|
||||
redraw: function() {
|
||||
if (this.div.children.length>0) {
|
||||
for (var l=this.div.children.length, i=l-1 ; i>=0 ; i--) {
|
||||
this.div.removeChild(this.div.children[i]);
|
||||
}
|
||||
for (var l=this.div.childNodes.length, i=l-1; i>=0; i--) {
|
||||
this.div.removeChild(this.div.childNodes[i]);
|
||||
}
|
||||
this.div.innerHTML = "";
|
||||
if (this.active) {
|
||||
for (var i=0, len=this.controls.length; i<len; i++) {
|
||||
var element = this.controls[i].panel_div;
|
||||
if (this.controls[i].active) {
|
||||
element.className = this.controls[i].displayClass + "ItemActive";
|
||||
} else {
|
||||
element.className = this.controls[i].displayClass + "ItemInactive";
|
||||
}
|
||||
this.div.appendChild(element);
|
||||
this.div.appendChild(this.controls[i].panel_div);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: activateControl
|
||||
* This method is called when the user click on the icon representing a
|
||||
@ -196,7 +206,6 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (!this.active) { return false; }
|
||||
if (control.type == OpenLayers.Control.TYPE_BUTTON) {
|
||||
control.trigger();
|
||||
this.redraw();
|
||||
return;
|
||||
}
|
||||
if (control.type == OpenLayers.Control.TYPE_TOGGLE) {
|
||||
@ -205,18 +214,21 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
} else {
|
||||
control.activate();
|
||||
}
|
||||
this.redraw();
|
||||
return;
|
||||
}
|
||||
var c;
|
||||
for (var i=0, len=this.controls.length; i<len; i++) {
|
||||
c = this.controls[i];
|
||||
if (c != control &&
|
||||
(c.type === OpenLayers.Control.TYPE_TOOL || c.type == null)) {
|
||||
c.deactivate();
|
||||
if (this.allowDepress && control.active) {
|
||||
control.deactivate();
|
||||
} else {
|
||||
var c;
|
||||
for (var i=0, len=this.controls.length; i<len; i++) {
|
||||
c = this.controls[i];
|
||||
if (c != control &&
|
||||
(c.type === OpenLayers.Control.TYPE_TOOL || c.type == null)) {
|
||||
c.deactivate();
|
||||
}
|
||||
}
|
||||
control.activate();
|
||||
}
|
||||
control.activate();
|
||||
},
|
||||
|
||||
/**
|
||||
@ -229,35 +241,62 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
* controls - {<OpenLayers.Control>} Controls to add in the panel.
|
||||
*/
|
||||
addControls: function(controls) {
|
||||
if (!(controls instanceof Array)) {
|
||||
if (!(OpenLayers.Util.isArray(controls))) {
|
||||
controls = [controls];
|
||||
}
|
||||
this.controls = this.controls.concat(controls);
|
||||
|
||||
// Give each control a panel_div which will be used later.
|
||||
// Access to this div is via the panel_div attribute of the
|
||||
// control added to the panel.
|
||||
// Also, stop mousedowns and clicks, but don't stop mouseup,
|
||||
// since they need to pass through.
|
||||
|
||||
for (var i=0, len=controls.length; i<len; i++) {
|
||||
var element = document.createElement("div");
|
||||
controls[i].panel_div = element;
|
||||
if (controls[i].title != "") {
|
||||
controls[i].panel_div.title = controls[i].title;
|
||||
var control = controls[i],
|
||||
element = this.createControlMarkup(control);
|
||||
OpenLayers.Element.addClass(element,
|
||||
control.displayClass + "ItemInactive");
|
||||
OpenLayers.Element.addClass(element, "olButton");
|
||||
if (control.title != "" && !element.title) {
|
||||
element.title = control.title;
|
||||
}
|
||||
OpenLayers.Event.observe(controls[i].panel_div, "click",
|
||||
OpenLayers.Function.bind(this.onClick, this, controls[i]));
|
||||
OpenLayers.Event.observe(controls[i].panel_div, "dblclick",
|
||||
OpenLayers.Function.bind(this.onDoubleClick, this, controls[i]));
|
||||
OpenLayers.Event.observe(controls[i].panel_div, "mousedown",
|
||||
OpenLayers.Function.bindAsEventListener(OpenLayers.Event.stop));
|
||||
}
|
||||
control.panel_div = element;
|
||||
}
|
||||
|
||||
if (this.map) { // map.addControl() has already been called on the panel
|
||||
this.addControlsToMap(controls);
|
||||
this.redraw();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: createControlMarkup
|
||||
* This function just creates a div for the control. If specific HTML
|
||||
* markup is needed this function can be overridden in specific classes,
|
||||
* or at panel instantiation time:
|
||||
*
|
||||
* Example:
|
||||
* (code)
|
||||
* var panel = new OpenLayers.Control.Panel({
|
||||
* defaultControl: control,
|
||||
* // ovverride createControlMarkup to create actual buttons
|
||||
* // including texts wrapped into span elements.
|
||||
* createControlMarkup: function(control) {
|
||||
* var button = document.createElement('button'),
|
||||
* span = document.createElement('span');
|
||||
* if (control.text) {
|
||||
* span.innerHTML = control.text;
|
||||
* }
|
||||
* return button;
|
||||
* }
|
||||
* });
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* control - {<OpenLayers.Control>} The control to create the HTML
|
||||
* markup for.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} The markup.
|
||||
*/
|
||||
createControlMarkup: function(control) {
|
||||
return document.createElement("div");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addControlsToMap
|
||||
@ -279,33 +318,54 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
control.deactivate();
|
||||
}
|
||||
control.events.on({
|
||||
"activate": this.redraw,
|
||||
"deactivate": this.redraw,
|
||||
scope: this
|
||||
activate: this.iconOn,
|
||||
deactivate: this.iconOff
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onClick
|
||||
* Method: iconOn
|
||||
* Internal use, for use only with "controls[i].events.on/un".
|
||||
*/
|
||||
onClick: function (ctrl, evt) {
|
||||
OpenLayers.Event.stop(evt ? evt : window.event);
|
||||
this.activateControl(ctrl);
|
||||
iconOn: function() {
|
||||
var d = this.panel_div; // "this" refers to a control on panel!
|
||||
var re = new RegExp("\\b(" + this.displayClass + "Item)Inactive\\b");
|
||||
d.className = d.className.replace(re, "$1Active");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onDoubleClick
|
||||
* Method: iconOff
|
||||
* Internal use, for use only with "controls[i].events.on/un".
|
||||
*/
|
||||
onDoubleClick: function(ctrl, evt) {
|
||||
OpenLayers.Event.stop(evt ? evt : window.event);
|
||||
iconOff: function() {
|
||||
var d = this.panel_div; // "this" refers to a control on panel!
|
||||
var re = new RegExp("\\b(" + this.displayClass + "Item)Active\\b");
|
||||
d.className = d.className.replace(re, "$1Inactive");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onButtonClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
onButtonClick: function (evt) {
|
||||
var controls = this.controls,
|
||||
button = evt.buttonElement;
|
||||
for (var i=controls.length-1; i>=0; --i) {
|
||||
if (controls[i].panel_div === button) {
|
||||
this.activateControl(controls[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: getControlsBy
|
||||
* Get a list of controls with properties matching the given criteria.
|
||||
*
|
||||
* Parameter:
|
||||
* Parameters:
|
||||
* property - {String} A control property to be matched.
|
||||
* match - {String | Object} A string to match. Can also be a regular
|
||||
* expression literal or object. In addition, it can be any object
|
||||
@ -330,7 +390,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIMethod: getControlsByName
|
||||
* Get a list of contorls with names matching the given name.
|
||||
*
|
||||
* Parameter:
|
||||
* Parameters:
|
||||
* match - {String | Object} A control name. The name can also be a regular
|
||||
* expression literal or object. In addition, it can be any object
|
||||
* with a method named test. For reqular expressions or other, if
|
||||
@ -350,7 +410,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIMethod: getControlsByClass
|
||||
* Get a list of controls of a given type (CLASS_NAME).
|
||||
*
|
||||
* Parameter:
|
||||
* Parameters:
|
||||
* match - {String | Object} A control class name. The type can also be a
|
||||
* regular expression literal or object. In addition, it can be any
|
||||
* object with a method named test. For reqular expressions or other,
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/ArgParser.js
|
||||
* @requires OpenLayers/Lang.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -15,7 +16,7 @@
|
||||
* current map view. By default it is drawn in the lower right corner of the
|
||||
* map. The href is updated as the map is zoomed, panned and whilst layers
|
||||
* are switched.
|
||||
* `
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
@ -34,6 +35,16 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
element: null,
|
||||
|
||||
/**
|
||||
* APIProperty: anchor
|
||||
* {Boolean} This option changes 3 things:
|
||||
* the character '#' is used in place of the character '?',
|
||||
* the window.href is updated if no element is provided.
|
||||
* When this option is set to true it's not recommend to provide
|
||||
* a base without provide an element.
|
||||
*/
|
||||
anchor: false,
|
||||
|
||||
/**
|
||||
* APIProperty: base
|
||||
* {String}
|
||||
@ -58,24 +69,38 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Parameters:
|
||||
* element - {DOMElement}
|
||||
* base - {String}
|
||||
* options - {Object} options to the control.
|
||||
* options - {Object} options to the control.
|
||||
*
|
||||
* Or for anchor:
|
||||
* options - {Object} options to the control.
|
||||
*/
|
||||
initialize: function(element, base, options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.element = OpenLayers.Util.getElement(element);
|
||||
this.base = base || document.location.href;
|
||||
if (element !== null && typeof element == 'object' && !OpenLayers.Util.isElement(element)) {
|
||||
options = element;
|
||||
this.base = document.location.href;
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
if (this.element != null) {
|
||||
this.element = OpenLayers.Util.getElement(this.element);
|
||||
}
|
||||
}
|
||||
else {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.element = OpenLayers.Util.getElement(element);
|
||||
this.base = base || document.location.href;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.element.parentNode == this.div) {
|
||||
if (this.element && this.element.parentNode == this.div) {
|
||||
this.div.removeChild(this.element);
|
||||
this.element = null;
|
||||
}
|
||||
if (this.map) {
|
||||
this.map.events.unregister('moveend', this, this.updateLink);
|
||||
}
|
||||
this.element = null;
|
||||
|
||||
this.map.events.unregister('moveend', this, this.updateLink);
|
||||
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
@ -121,10 +146,9 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
||||
draw: function() {
|
||||
OpenLayers.Control.prototype.draw.apply(this, arguments);
|
||||
|
||||
if (!this.element) {
|
||||
this.div.className = this.displayClass;
|
||||
if (!this.element && !this.anchor) {
|
||||
this.element = document.createElement("a");
|
||||
this.element.innerHTML = OpenLayers.i18n("permalink");
|
||||
this.element.innerHTML = OpenLayers.i18n("Permalink");
|
||||
this.element.href="";
|
||||
this.div.appendChild(this.element);
|
||||
}
|
||||
@ -146,13 +170,26 @@ OpenLayers.Control.Permalink = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: updateLink
|
||||
*/
|
||||
updateLink: function() {
|
||||
var separator = this.anchor ? '#' : '?';
|
||||
var href = this.base;
|
||||
if (href.indexOf('?') != -1) {
|
||||
href = href.substring( 0, href.indexOf('?') );
|
||||
var anchor = null;
|
||||
if (href.indexOf("#") != -1 && this.anchor == false) {
|
||||
anchor = href.substring( href.indexOf("#"), href.length);
|
||||
}
|
||||
if (href.indexOf(separator) != -1) {
|
||||
href = href.substring( 0, href.indexOf(separator) );
|
||||
}
|
||||
var splits = href.split("#");
|
||||
href = splits[0] + separator+ OpenLayers.Util.getParameterString(this.createParams());
|
||||
if (anchor) {
|
||||
href += anchor;
|
||||
}
|
||||
if (this.anchor && !this.element) {
|
||||
window.location.href = href;
|
||||
}
|
||||
else {
|
||||
this.element.href = href;
|
||||
}
|
||||
|
||||
href += '?' + OpenLayers.Util.getParameterString(this.createParams());
|
||||
this.element.href = href;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
157
js/openlayers/src/openlayers/lib/OpenLayers/Control/PinchZoom.js
Normal file
@ -0,0 +1,157 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Handler/Pinch.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.PinchZoom
|
||||
*
|
||||
* Inherits:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* {OpenLayers.Control.TYPES}
|
||||
*/
|
||||
type: OpenLayers.Control.TYPE_TOOL,
|
||||
|
||||
/**
|
||||
* Property: pinchOrigin
|
||||
* {Object} Cached object representing the pinch start (in pixels).
|
||||
*/
|
||||
pinchOrigin: null,
|
||||
|
||||
/**
|
||||
* Property: currentCenter
|
||||
* {Object} Cached object representing the latest pinch center (in pixels).
|
||||
*/
|
||||
currentCenter: null,
|
||||
|
||||
/**
|
||||
* APIProperty: autoActivate
|
||||
* {Boolean} Activate the control when it is added to a map. Default is
|
||||
* true.
|
||||
*/
|
||||
autoActivate: true,
|
||||
|
||||
/**
|
||||
* APIProperty: preserveCenter
|
||||
* {Boolean} Set this to true if you don't want the map center to change
|
||||
* while pinching. For example you may want to set preserveCenter to
|
||||
* true when the user location is being watched and you want to preserve
|
||||
* the user location at the center of the map even if he zooms in or
|
||||
* out using pinch. This property's value can be changed any time on an
|
||||
* existing instance. Default is false.
|
||||
*/
|
||||
preserveCenter: false,
|
||||
|
||||
/**
|
||||
* APIProperty: handlerOptions
|
||||
* {Object} Used to set non-default properties on the pinch handler
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.PinchZoom
|
||||
* Create a control for zooming with pinch gestures. This works on devices
|
||||
* with multi-touch support.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* the control
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
this.handler = new OpenLayers.Handler.Pinch(this, {
|
||||
start: this.pinchStart,
|
||||
move: this.pinchMove,
|
||||
done: this.pinchDone
|
||||
}, this.handlerOptions);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: pinchStart
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
* pinchData - {Object} pinch data object related to the current touchmove
|
||||
* of the pinch gesture. This give us the current scale of the pinch.
|
||||
*/
|
||||
pinchStart: function(evt, pinchData) {
|
||||
var xy = (this.preserveCenter) ?
|
||||
this.map.getPixelFromLonLat(this.map.getCenter()) : evt.xy;
|
||||
this.pinchOrigin = xy;
|
||||
this.currentCenter = xy;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: pinchMove
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
* pinchData - {Object} pinch data object related to the current touchmove
|
||||
* of the pinch gesture. This give us the current scale of the pinch.
|
||||
*/
|
||||
pinchMove: function(evt, pinchData) {
|
||||
var scale = pinchData.scale;
|
||||
var containerOrigin = this.map.layerContainerOriginPx;
|
||||
var pinchOrigin = this.pinchOrigin;
|
||||
var current = (this.preserveCenter) ?
|
||||
this.map.getPixelFromLonLat(this.map.getCenter()) : evt.xy;
|
||||
|
||||
var dx = Math.round((containerOrigin.x + current.x - pinchOrigin.x) + (scale - 1) * (containerOrigin.x - pinchOrigin.x));
|
||||
var dy = Math.round((containerOrigin.y + current.y - pinchOrigin.y) + (scale - 1) * (containerOrigin.y - pinchOrigin.y));
|
||||
|
||||
this.map.applyTransform(dx, dy, scale);
|
||||
this.currentCenter = current;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: pinchDone
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
* start - {Object} pinch data object related to the touchstart event that
|
||||
* started the pinch gesture.
|
||||
* last - {Object} pinch data object related to the last touchmove event
|
||||
* of the pinch gesture. This give us the final scale of the pinch.
|
||||
*/
|
||||
pinchDone: function(evt, start, last) {
|
||||
this.map.applyTransform();
|
||||
var zoom = this.map.getZoomForResolution(this.map.getResolution() / last.scale, true);
|
||||
if (zoom !== this.map.getZoom() || !this.currentCenter.equals(this.pinchOrigin)) {
|
||||
var resolution = this.map.getResolutionForZoom(zoom);
|
||||
|
||||
var location = this.map.getLonLatFromPixel(this.pinchOrigin);
|
||||
var zoomPixel = this.currentCenter;
|
||||
var size = this.map.getSize();
|
||||
|
||||
location.lon += resolution * ((size.w / 2) - zoomPixel.x);
|
||||
location.lat -= resolution * ((size.h / 2) - zoomPixel.y);
|
||||
|
||||
// Force a reflow before calling setCenter. This is to work
|
||||
// around an issue occuring in iOS.
|
||||
//
|
||||
// See https://github.com/openlayers/openlayers/pull/351.
|
||||
//
|
||||
// Without a reflow setting the layer container div's top left
|
||||
// style properties to "0px" - as done in Map.moveTo when zoom
|
||||
// is changed - won't actually correctly reposition the layer
|
||||
// container div.
|
||||
//
|
||||
// Also, we need to use a statement that the Google Closure
|
||||
// compiler won't optimize away.
|
||||
this.map.div.clientWidth = this.map.div.clientWidth;
|
||||
|
||||
this.map.setCenter(location, zoom);
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.PinchZoom"
|
||||
|
||||
});
|
||||
@ -1,16 +1,17 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Layer/WMS/Post.js
|
||||
* @requires OpenLayers/Layer/WMS.js
|
||||
* @requires OpenLayers/Handler/RegularPolygon.js
|
||||
* @requires OpenLayers/Handler/Polygon.js
|
||||
* @requires OpenLayers/Handler/Path.js
|
||||
* @requires OpenLayers/Handler/Click.js
|
||||
* @requires OpenLayers/Filter/Spatial.js
|
||||
* @requires OpenLayers/Format/SLD/v1_0_0.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -22,25 +23,22 @@
|
||||
*/
|
||||
OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
* {Array(String)} Supported application event types. Register a listener
|
||||
* for a particular event with the following syntax:
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Listeners will be called with a reference to an event object. The
|
||||
* properties of this event depends on exactly what happened.
|
||||
*
|
||||
* Supported control event types (in addition to those from
|
||||
* <OpenLayers.Control>):
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* selected - Triggered when a selection occurs. Listeners receive an
|
||||
* event with *filters* and *layer* properties. Filters will be an
|
||||
* array of OpenLayers.Filter objects created in order to perform
|
||||
* the particular selection.
|
||||
*/
|
||||
EVENT_TYPES: ["selected"],
|
||||
|
||||
/**
|
||||
* APIProperty: clearOnDeactivate
|
||||
@ -84,7 +82,6 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIProperty: handlerOptions
|
||||
* {Object} Used to set non-default properties on the control's handler
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* APIProperty: sketchStyle
|
||||
@ -99,7 +96,7 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
* layerOptions: {
|
||||
* styleMap: new OpenLayers.StyleMap({
|
||||
* "default": {strokeColor: "yellow"}
|
||||
* });
|
||||
* })
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
@ -119,7 +116,7 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
* APIProperty: layerCache
|
||||
* {Object} Cache to use for storing references to the selection layers.
|
||||
* Normally each source layer will have exactly 1 selection layer of
|
||||
* type OpenLayers.Layer.WMS.Post. If not provided, layers will
|
||||
* type OpenLayers.Layer.WMS. If not provided, layers will
|
||||
* be cached on the prototype. Note that if <clearOnDeactivate> is
|
||||
* true, the layer will no longer be cached after deactivating the
|
||||
* control.
|
||||
@ -147,18 +144,14 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
* selection on.
|
||||
*/
|
||||
initialize: function(handler, options) {
|
||||
// concatenate events specific to this control with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.SLDSelect.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
|
||||
this.callbacks = OpenLayers.Util.extend({done: this.select,
|
||||
click: this.select}, this.callbacks);
|
||||
this.handlerOptions = this.handlerOptions || {};
|
||||
this.layerOptions = OpenLayers.Util.applyDefaults(this.layerOptions, {
|
||||
displayInLayerSwitcher: false
|
||||
displayInLayerSwitcher: false,
|
||||
tileOptions: {maxGetUrlLength: 2048}
|
||||
});
|
||||
if (this.sketchStyle) {
|
||||
this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(
|
||||
@ -189,6 +182,9 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
* layer visibility. So if the source layer is turned off, the
|
||||
* selection layer is also turned off.
|
||||
*
|
||||
* Context:
|
||||
* - {<OpenLayers.Layer>}
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object}
|
||||
*/
|
||||
@ -207,14 +203,14 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
* is performed.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Layer.WMS.Post>} A WMS Post layer since SLD selections can
|
||||
* easily get quite long.
|
||||
* {<OpenLayers.Layer.WMS>} A WMS layer with maxGetUrlLength configured to 2048
|
||||
* since SLD selections can easily get quite long.
|
||||
*/
|
||||
createSelectionLayer: function(source) {
|
||||
// check if we already have a selection layer for the source layer
|
||||
var selectionLayer;
|
||||
if (!this.layerCache[source.id]) {
|
||||
selectionLayer = new OpenLayers.Layer.WMS.Post(source.name,
|
||||
selectionLayer = new OpenLayers.Layer.WMS(source.name,
|
||||
source.url, source.params,
|
||||
OpenLayers.Util.applyDefaults(
|
||||
this.layerOptions,
|
||||
@ -271,7 +267,7 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
maxScaleDenominator: layer.options.minScale})
|
||||
]});
|
||||
}
|
||||
return new OpenLayers.Format.SLD().write(sld);
|
||||
return new OpenLayers.Format.SLD({srsName: this.map.getProjection()}).write(sld);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -537,12 +533,13 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
|
||||
var selectionLayer = this.createSelectionLayer(layer);
|
||||
var sld = this.createSLD(layer, filters, geometryAttributes);
|
||||
|
||||
this.events.triggerEvent("selected", {
|
||||
layer: layer,
|
||||
filters: filters
|
||||
});
|
||||
|
||||
var sld = this.createSLD(layer, filters, geometryAttributes);
|
||||
|
||||
selectionLayer.mergeNewParams({SLD_BODY: sld});
|
||||
delete this._queue;
|
||||
@ -567,4 +564,4 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.SLDSelect"
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Lang.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -19,7 +20,7 @@
|
||||
OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Parameter: element
|
||||
* Property: element
|
||||
* {DOMElement}
|
||||
*/
|
||||
element: null,
|
||||
@ -91,7 +92,7 @@ OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {
|
||||
scale = Math.round(scale);
|
||||
}
|
||||
|
||||
this.element.innerHTML = OpenLayers.i18n("scale", {'scaleDenom':scale});
|
||||
this.element.innerHTML = OpenLayers.i18n("Scale = 1 : ${scaleDenom}", {'scaleDenom':scale});
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.Scale"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -80,9 +80,6 @@ OpenLayers.Control.ScaleLine = OpenLayers.Class(OpenLayers.Control, {
|
||||
* options - {Object} An optional object whose properties will be used
|
||||
* to extend the control.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -21,15 +21,23 @@
|
||||
*/
|
||||
OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Supported event types:
|
||||
* - *beforefeaturehighlighted* Triggered before a feature is highlighted
|
||||
* - *featurehighlighted* Triggered when a feature is highlighted
|
||||
* - *featureunhighlighted* Triggered when a feature is unhighlighted
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforefeaturehighlighted - Triggered before a feature is highlighted
|
||||
* featurehighlighted - Triggered when a feature is highlighted
|
||||
* featureunhighlighted - Triggered when a feature is unhighlighted
|
||||
* boxselectionstart - Triggered before box selection starts
|
||||
* boxselectionend - Triggered after box selection ends
|
||||
*/
|
||||
EVENT_TYPES: ["beforefeaturehighlighted", "featurehighlighted", "featureunhighlighted"],
|
||||
|
||||
/**
|
||||
* Property: multipleKey
|
||||
@ -74,9 +82,9 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: highlightOnly
|
||||
* {Boolean} If true do not actually select features (i.e. place them in the
|
||||
* layer's selected features array), just highlight them. This property has
|
||||
* no effect if hover is false. Defaults to false.
|
||||
* {Boolean} If true do not actually select features (that is place them in
|
||||
* the layer's selected features array), just highlight them. This property
|
||||
* has no effect if hover is false. Defaults to false.
|
||||
*/
|
||||
highlightOnly: false,
|
||||
|
||||
@ -132,7 +140,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Property: layers
|
||||
* {Array(<OpenLayers.Layer.Vector>} The layers this control will work on,
|
||||
* {Array(<OpenLayers.Layer.Vector>)} The layers this control will work on,
|
||||
* or null if the control was configured with a single layer
|
||||
*/
|
||||
layers: null,
|
||||
@ -173,11 +181,6 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(layers, options) {
|
||||
// concatenate events specific to this control with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.SelectFeature.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
|
||||
if(this.scope === null) {
|
||||
@ -218,7 +221,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* layers - {<OpenLayers.Layer.Vector>}, or an array of vector layers.
|
||||
*/
|
||||
initLayer: function(layers) {
|
||||
if(layers instanceof Array) {
|
||||
if(OpenLayers.Util.isArray(layers)) {
|
||||
this.layers = layers;
|
||||
this.layer = new OpenLayers.Layer.Vector.RootContainer(
|
||||
this.id + "_container", {
|
||||
@ -297,14 +300,22 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
unselectAll: function(options) {
|
||||
// we'll want an option to supress notification here
|
||||
var layers = this.layers || [this.layer];
|
||||
var layer, feature;
|
||||
for(var l=0; l<layers.length; ++l) {
|
||||
var layers = this.layers || [this.layer],
|
||||
layer, feature, l, numExcept;
|
||||
for(l=0; l<layers.length; ++l) {
|
||||
layer = layers[l];
|
||||
for(var i=layer.selectedFeatures.length-1; i>=0; --i) {
|
||||
feature = layer.selectedFeatures[i];
|
||||
if(!options || options.except != feature) {
|
||||
this.unselect(feature);
|
||||
numExcept = 0;
|
||||
//layer.selectedFeatures is null when layer is destroyed and
|
||||
//one of it's preremovelayer listener calls setLayer
|
||||
//with another layer on this control
|
||||
if(layer.selectedFeatures != null) {
|
||||
while(layer.selectedFeatures.length > numExcept) {
|
||||
feature = layer.selectedFeatures[numExcept];
|
||||
if(!options || options.except != feature) {
|
||||
this.unselect(feature);
|
||||
} else {
|
||||
++numExcept;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -463,8 +474,23 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
unhighlight: function(feature) {
|
||||
var layer = feature.layer;
|
||||
feature._lastHighlighter = feature._prevHighlighter;
|
||||
delete feature._prevHighlighter;
|
||||
// three cases:
|
||||
// 1. there's no other highlighter, in that case _prev is undefined,
|
||||
// and we just need to undef _last
|
||||
// 2. another control highlighted the feature after we did it, in
|
||||
// that case _last references this other control, and we just
|
||||
// need to undef _prev
|
||||
// 3. another control highlighted the feature before we did it, in
|
||||
// that case _prev references this other control, and we need to
|
||||
// set _last to _prev and undef _prev
|
||||
if(feature._prevHighlighter == undefined) {
|
||||
delete feature._lastHighlighter;
|
||||
} else if(feature._prevHighlighter == this.id) {
|
||||
delete feature._prevHighlighter;
|
||||
} else {
|
||||
feature._lastHighlighter = feature._prevHighlighter;
|
||||
delete feature._prevHighlighter;
|
||||
}
|
||||
layer.drawFeature(feature, feature.style || feature.layer.style ||
|
||||
"default");
|
||||
this.events.triggerEvent("featureunhighlighted", {feature : feature});
|
||||
@ -528,12 +554,14 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
selectBox: 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 minXY = this.map.getLonLatFromPixel({
|
||||
x: position.left,
|
||||
y: position.bottom
|
||||
});
|
||||
var maxXY = this.map.getLonLatFromPixel({
|
||||
x: position.right,
|
||||
y: position.top
|
||||
});
|
||||
var bounds = new OpenLayers.Bounds(
|
||||
minXY.lon, minXY.lat, maxXY.lon, maxXY.lat
|
||||
);
|
||||
@ -547,6 +575,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var prevMultiple = this.multiple;
|
||||
this.multiple = true;
|
||||
var layers = this.layers || [this.layer];
|
||||
this.events.triggerEvent("boxselectionstart", {layers: layers});
|
||||
var layer;
|
||||
for(var l=0; l<layers.length; ++l) {
|
||||
layer = layers[l];
|
||||
@ -568,6 +597,7 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
}
|
||||
this.multiple = prevMultiple;
|
||||
this.events.triggerEvent("boxselectionend", {layers: layers});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -17,18 +17,17 @@
|
||||
*/
|
||||
OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
* {Array(String)} Supported application event types. Register a listener
|
||||
* for a particular event with the following syntax:
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Listeners will be called with a reference to an event object. The
|
||||
* properties of this event depends on exactly what happened.
|
||||
*
|
||||
* Supported control event types (in addition to those from <OpenLayers.Control>):
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforesnap - Triggered before a snap occurs. Listeners receive an
|
||||
* event object with *point*, *x*, *y*, *distance*, *layer*, and
|
||||
* *snapType* properties. The point property will be original point
|
||||
@ -45,7 +44,6 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* unsnap - Triggered when a vertex is unsnapped. Listeners receive an
|
||||
* event with a *point* property.
|
||||
*/
|
||||
EVENT_TYPES: ["beforesnap", "snap", "unsnap"],
|
||||
|
||||
/**
|
||||
* CONSTANT: DEFAULTS
|
||||
@ -118,7 +116,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* the control.
|
||||
*
|
||||
* Valid options:
|
||||
* layer - {OpenLayers.Layer.Vector} The editable layer. Features from this
|
||||
* layer - {<OpenLayers.Layer.Vector>} The editable layer. Features from this
|
||||
* layer that are digitized or modified may have vertices snapped to
|
||||
* features from any of the target layers.
|
||||
* targets - {Array(Object | OpenLayers.Layer.Vector)} A list of objects for
|
||||
@ -126,7 +124,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* objects below. If the items in the targets list are vector layers
|
||||
* (instead of configuration objects), the defaults from the <defaults>
|
||||
* property will apply. The editable layer itself may be a target
|
||||
* layer - allowing newly created or edited features to be snapped to
|
||||
* layer, allowing newly created or edited features to be snapped to
|
||||
* existing features from the same layer. If no targets are provided
|
||||
* the layer given in the constructor (as <layer>) will become the
|
||||
* initial target.
|
||||
@ -144,7 +142,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* continues after an eligible feature is found in a target layer.
|
||||
*
|
||||
* Valid target properties:
|
||||
* layer - {OpenLayers.Layer.Vector} A target layer. Features from this
|
||||
* layer - {<OpenLayers.Layer.Vector>} A target layer. Features from this
|
||||
* layer will be eligible to act as snapping target for the editable
|
||||
* layer.
|
||||
* tolerance - {Float} The distance (in pixels) at which snapping may occur.
|
||||
@ -162,15 +160,19 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* edgeTolerance - {Float} Optional distance at which snapping may occur
|
||||
* for edges specifically. If none is provided, <tolerance> will be
|
||||
* used.
|
||||
* filter - {OpenLayers.Filter} Optional filter to evaluate to determine if
|
||||
* filter - {<OpenLayers.Filter>} Optional filter to evaluate to determine if
|
||||
* feature is eligible for snapping. If filter evaluates to true for a
|
||||
* target feature a vertex may be snapped to the feature.
|
||||
* minResolution - {Number} If a minResolution is provided, snapping to this
|
||||
* target will only be considered if the map resolution is greater than
|
||||
* or equal to this value (the minResolution is inclusive). Default is
|
||||
* no minimum resolution limit.
|
||||
* maxResolution - {Number} If a maxResolution is provided, snapping to this
|
||||
* target will only be considered if the map resolution is strictly
|
||||
* less than this value (the maxResolution is exclusive). Default is
|
||||
* no maximum resolution limit.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
// concatenate events specific to measure with those from the base
|
||||
Array.prototype.push.apply(
|
||||
this.EVENT_TYPES, OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.options = options || {}; // TODO: this could be done by the super
|
||||
|
||||
@ -197,7 +199,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* layer is set.
|
||||
*
|
||||
* Parameters:
|
||||
* layer - {OpenLayers.Layer.Vector} The new editable layer.
|
||||
* layer - {<OpenLayers.Layer.Vector>} The new editable layer.
|
||||
*/
|
||||
setLayer: function(layer) {
|
||||
if(this.active) {
|
||||
@ -364,7 +366,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: considerSnapping
|
||||
*
|
||||
* Parameters:
|
||||
* point - {<OpenLayers.Geometry.Point}} The vertex to be snapped (or
|
||||
* point - {<OpenLayers.Geometry.Point>} The vertex to be snapped (or
|
||||
* unsnapped).
|
||||
* loc - {<OpenLayers.Geometry.Point>} The location of the mouse in map
|
||||
* coords.
|
||||
@ -436,10 +438,21 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Returns null if candidate is not eligible for snapping.
|
||||
*/
|
||||
testTarget: function(target, loc) {
|
||||
var resolution = this.layer.map.getResolution();
|
||||
if ("minResolution" in target) {
|
||||
if (resolution < target.minResolution) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if ("maxResolution" in target) {
|
||||
if (resolution >= target.maxResolution) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
var tolerance = {
|
||||
node: this.getGeoTolerance(target.nodeTolerance),
|
||||
vertex: this.getGeoTolerance(target.vertexTolerance),
|
||||
edge: this.getGeoTolerance(target.edgeTolerance)
|
||||
node: this.getGeoTolerance(target.nodeTolerance, resolution),
|
||||
vertex: this.getGeoTolerance(target.vertexTolerance, resolution),
|
||||
edge: this.getGeoTolerance(target.edgeTolerance, resolution)
|
||||
};
|
||||
// this could be cached if we don't support setting tolerance values directly
|
||||
var maxTolerance = Math.max(
|
||||
@ -457,7 +470,7 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
feature = features[i];
|
||||
if(feature !== this.feature && !feature._sketch &&
|
||||
feature.state !== OpenLayers.State.DELETE &&
|
||||
(!target.filter || target.filter.evaluate(feature.attributes))) {
|
||||
(!target.filter || target.filter.evaluate(feature))) {
|
||||
if(feature.atPoint(ll, maxTolerance, maxTolerance)) {
|
||||
for(var j=0, stop=Math.min(result.rank+1, numTypes); j<stop; ++j) {
|
||||
type = this.precedence[j];
|
||||
@ -512,12 +525,12 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
|
||||
*
|
||||
* Parameters:
|
||||
* tolerance - {Number} A tolerance value in pixels.
|
||||
* resolution - {Number} Map resolution.
|
||||
*
|
||||
* Returns:
|
||||
* {Number} A tolerance value in map units.
|
||||
*/
|
||||
getGeoTolerance: function(tolerance) {
|
||||
var resolution = this.layer.map.getResolution();
|
||||
getGeoTolerance: function(tolerance, resolution) {
|
||||
if(resolution !== this.resolution) {
|
||||
this.resolution = resolution;
|
||||
this.geoToleranceCache = {};
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -18,18 +18,17 @@
|
||||
*/
|
||||
OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
* {Array(String)} Supported application event types. Register a listener
|
||||
* for a particular event with the following syntax:
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Listeners will be called with a reference to an event object. The
|
||||
* properties of this event depends on exactly what happened.
|
||||
*
|
||||
* Supported control event types (in addition to those from <OpenLayers.Control>):
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforesplit - Triggered before a split occurs. Listeners receive an
|
||||
* event object with *source* and *target* properties.
|
||||
* split - Triggered when a split occurs. Listeners receive an event with
|
||||
@ -47,7 +46,6 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* sketch or modified feature used as a splitter. The features
|
||||
* property is a list of all resulting features.
|
||||
*/
|
||||
EVENT_TYPES: ["beforesplit", "split", "aftersplit"],
|
||||
|
||||
/**
|
||||
* APIProperty: layer
|
||||
@ -109,7 +107,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: targetFilter
|
||||
* {OpenLayers.Filter} Optional filter that will be evaluated
|
||||
* {<OpenLayers.Filter>} Optional filter that will be evaluated
|
||||
* to determine if a feature from the target layer is eligible for
|
||||
* splitting.
|
||||
*/
|
||||
@ -117,8 +115,8 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: sourceFilter
|
||||
* {OpenLayers.Filter} Optional filter that will be evaluated
|
||||
* to determine if a feature from the target layer is eligible for
|
||||
* {<OpenLayers.Filter>} Optional filter that will be evaluated
|
||||
* to determine if a feature from the source layer is eligible for
|
||||
* splitting.
|
||||
*/
|
||||
sourceFilter: null,
|
||||
@ -144,10 +142,10 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* the control.
|
||||
*
|
||||
* Valid options:
|
||||
* layer - {OpenLayers.Layer.Vector} The target layer. Features from this
|
||||
* layer - {<OpenLayers.Layer.Vector>} The target layer. Features from this
|
||||
* layer will be split by new or modified features on the source layer
|
||||
* or temporary sketch layer.
|
||||
* source - {OpenLayers.Layer.Vector} Optional source layer. If provided
|
||||
* source - {<OpenLayers.Layer.Vector>} Optional source layer. If provided
|
||||
* newly created features or modified features will be used to split
|
||||
* features on the target layer. If not provided, a temporary sketch
|
||||
* layer will be created for drawing lines.
|
||||
@ -161,18 +159,14 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* mutual - {Boolean} If source and target are the same, split source
|
||||
* features and target features where they intersect. Default is
|
||||
* true. If false, only target features will be split.
|
||||
* targetFilter - {OpenLayers.Filter} Optional filter that will be evaluated
|
||||
* targetFilter - {<OpenLayers.Filter>} Optional filter that will be evaluated
|
||||
* to determine if a feature from the target layer is eligible for
|
||||
* splitting.
|
||||
* sourceFilter - {OpenLayers.Filter} Optional filter that will be evaluated
|
||||
* sourceFilter - {<OpenLayers.Filter>} Optional filter that will be evaluated
|
||||
* to determine if a feature from the target layer is eligible for
|
||||
* splitting.
|
||||
*/
|
||||
initialize: function(options) {
|
||||
// concatenate events specific to measure with those from the base
|
||||
Array.prototype.push.apply(
|
||||
this.EVENT_TYPES, OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.options = options || {}; // TODO: this could be done by the super
|
||||
|
||||
@ -187,7 +181,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Set the source layer for edits layer.
|
||||
*
|
||||
* Parameters:
|
||||
* layer - {OpenLayers.Layer.Vector} The new source layer layer. If
|
||||
* layer - {<OpenLayers.Layer.Vector>} The new source layer layer. If
|
||||
* null, a temporary sketch layer will be created.
|
||||
*/
|
||||
setSource: function(layer) {
|
||||
@ -246,7 +240,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
var deactivated = OpenLayers.Control.prototype.deactivate.call(this);
|
||||
if(deactivated) {
|
||||
if(this.source && this.source.events) {
|
||||
this.layer.events.un({
|
||||
this.source.events.un({
|
||||
sketchcomplete: this.onSketchComplete,
|
||||
afterfeaturemodified: this.afterFeatureModified,
|
||||
scope: this
|
||||
@ -284,8 +278,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
afterFeatureModified: function(event) {
|
||||
if(event.modified) {
|
||||
var feature = event.feature;
|
||||
if(feature.geometry instanceof OpenLayers.Geometry.LineString ||
|
||||
feature.geometry instanceof OpenLayers.Geometry.MultiLineString) {
|
||||
if (typeof feature.geometry.split === "function") {
|
||||
this.feature = event.feature;
|
||||
this.considerSplit(event.feature);
|
||||
}
|
||||
@ -297,7 +290,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Remove a feature from a list based on the given geometry.
|
||||
*
|
||||
* Parameters:
|
||||
* features - {Array(<OpenLayers.Feature.Vector>} A list of features.
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)} A list of features.
|
||||
* geometry - {<OpenLayers.Geometry>} A geometry.
|
||||
*/
|
||||
removeByGeometry: function(features, geometry) {
|
||||
@ -320,17 +313,20 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* {Boolean} The target is eligible for splitting.
|
||||
*/
|
||||
isEligible: function(target) {
|
||||
return (
|
||||
target.state !== OpenLayers.State.DELETE
|
||||
) && (
|
||||
target.geometry instanceof OpenLayers.Geometry.LineString ||
|
||||
target.geometry instanceof OpenLayers.Geometry.MultiLineString
|
||||
) && (
|
||||
this.feature !== target
|
||||
) && (
|
||||
!this.targetFilter ||
|
||||
this.targetFilter.evaluate(target.attributes)
|
||||
);
|
||||
if (!target.geometry) {
|
||||
return false;
|
||||
} else {
|
||||
return (
|
||||
target.state !== OpenLayers.State.DELETE
|
||||
) && (
|
||||
typeof target.geometry.split === "function"
|
||||
) && (
|
||||
this.feature !== target
|
||||
) && (
|
||||
!this.targetFilter ||
|
||||
this.targetFilter.evaluate(target.attributes)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -340,7 +336,7 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
|
||||
* will be split if eligible.
|
||||
*
|
||||
* Parameters:
|
||||
* feature - {<OpenLayers.Feature.Vector}} The newly created or modified
|
||||
* feature - {<OpenLayers.Feature.Vector>} The newly created or modified
|
||||
* feature.
|
||||
*
|
||||
* Returns:
|
||||
|
||||
@ -0,0 +1,182 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control/DragPan.js
|
||||
* @requires OpenLayers/Control/PinchZoom.js
|
||||
* @requires OpenLayers/Handler/Click.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.TouchNavigation
|
||||
* The navigation control handles map browsing with touch events (dragging,
|
||||
* double-tapping, tap with two fingers, and pinch zoom). Create a new
|
||||
* control with the <OpenLayers.Control.TouchNavigation> constructor.
|
||||
*
|
||||
* If you’re only targeting touch enabled devices with your mapping application,
|
||||
* you can create a map with only a TouchNavigation control. The
|
||||
* <OpenLayers.Control.Navigation> control is mobile ready by default, but
|
||||
* you can generate a smaller build of the library by only including this
|
||||
* touch navigation control if you aren't concerned about mouse interaction.
|
||||
*
|
||||
* Inherits:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Property: dragPan
|
||||
* {<OpenLayers.Control.DragPan>}
|
||||
*/
|
||||
dragPan: null,
|
||||
|
||||
/**
|
||||
* APIProperty: dragPanOptions
|
||||
* {Object} Options passed to the DragPan control.
|
||||
*/
|
||||
dragPanOptions: null,
|
||||
|
||||
/**
|
||||
* Property: pinchZoom
|
||||
* {<OpenLayers.Control.PinchZoom>}
|
||||
*/
|
||||
pinchZoom: null,
|
||||
|
||||
/**
|
||||
* APIProperty: pinchZoomOptions
|
||||
* {Object} Options passed to the PinchZoom control.
|
||||
*/
|
||||
pinchZoomOptions: null,
|
||||
|
||||
/**
|
||||
* APIProperty: clickHandlerOptions
|
||||
* {Object} Options passed to the Click handler.
|
||||
*/
|
||||
clickHandlerOptions: null,
|
||||
|
||||
/**
|
||||
* APIProperty: documentDrag
|
||||
* {Boolean} Allow panning of the map by dragging outside map viewport.
|
||||
* Default is false.
|
||||
*/
|
||||
documentDrag: false,
|
||||
|
||||
/**
|
||||
* APIProperty: autoActivate
|
||||
* {Boolean} Activate the control when it is added to a map. Default is
|
||||
* true.
|
||||
*/
|
||||
autoActivate: true,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.TouchNavigation
|
||||
* Create a new navigation control
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object whose properties will be set on
|
||||
* the control
|
||||
*/
|
||||
initialize: function(options) {
|
||||
this.handlers = {};
|
||||
OpenLayers.Control.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
* The destroy method is used to perform any clean up before the control
|
||||
* is dereferenced. Typically this is where event listeners are removed
|
||||
* to prevent memory leaks.
|
||||
*/
|
||||
destroy: function() {
|
||||
this.deactivate();
|
||||
if(this.dragPan) {
|
||||
this.dragPan.destroy();
|
||||
}
|
||||
this.dragPan = null;
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.destroy();
|
||||
delete this.pinchZoom;
|
||||
}
|
||||
OpenLayers.Control.prototype.destroy.apply(this,arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: activate
|
||||
*/
|
||||
activate: function() {
|
||||
if(OpenLayers.Control.prototype.activate.apply(this,arguments)) {
|
||||
this.dragPan.activate();
|
||||
this.handlers.click.activate();
|
||||
this.pinchZoom.activate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: deactivate
|
||||
*/
|
||||
deactivate: function() {
|
||||
if(OpenLayers.Control.prototype.deactivate.apply(this,arguments)) {
|
||||
this.dragPan.deactivate();
|
||||
this.handlers.click.deactivate();
|
||||
this.pinchZoom.deactivate();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
*/
|
||||
draw: function() {
|
||||
var clickCallbacks = {
|
||||
click: this.defaultClick,
|
||||
dblclick: this.defaultDblClick
|
||||
};
|
||||
var clickOptions = OpenLayers.Util.extend({
|
||||
"double": true,
|
||||
stopDouble: true,
|
||||
pixelTolerance: 2
|
||||
}, this.clickHandlerOptions);
|
||||
this.handlers.click = new OpenLayers.Handler.Click(
|
||||
this, clickCallbacks, clickOptions
|
||||
);
|
||||
this.dragPan = new OpenLayers.Control.DragPan(
|
||||
OpenLayers.Util.extend({
|
||||
map: this.map,
|
||||
documentDrag: this.documentDrag
|
||||
}, this.dragPanOptions)
|
||||
);
|
||||
this.dragPan.draw();
|
||||
this.pinchZoom = new OpenLayers.Control.PinchZoom(
|
||||
OpenLayers.Util.extend({map: this.map}, this.pinchZoomOptions)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultClick: function (evt) {
|
||||
if(evt.lastTouches && evt.lastTouches.length == 2) {
|
||||
this.map.zoomOut();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: defaultDblClick
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
defaultDblClick: function (evt) {
|
||||
this.map.zoomTo(this.map.zoom + 1, evt.xy);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.TouchNavigation"
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -21,38 +21,43 @@
|
||||
*/
|
||||
OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Supported event types:
|
||||
* - *beforesetfeature* Triggered before a feature is set for
|
||||
* tranformation. The feature will not be set if a listener returns
|
||||
* false. Listeners receive a *feature* property, with the feature
|
||||
* that will be set for transformation. Listeners are allowed to
|
||||
* set the control's *scale*, *ratio* and *rotation* properties,
|
||||
* which will set the initial scale, ratio and rotation of the
|
||||
* feature, like the <setFeature> method's initialParams argument.
|
||||
* - *setfeature* Triggered when a feature is set for tranformation.
|
||||
* Listeners receive a *feature* property, with the feature that
|
||||
* is now set for transformation.
|
||||
* - *beforetransform* Triggered while dragging, before a feature is
|
||||
* transformed. The feature will not be transformed if a listener
|
||||
* returns false (but the box still will). Listeners receive one or
|
||||
* more of *center*, *scale*, *ratio* and *rotation*. The *center*
|
||||
* property is an <OpenLayers.Geometry.Point> object with the new
|
||||
* center of the transformed feature, the others are Floats with the
|
||||
* scale, ratio or rotation change since the last transformation.
|
||||
* - *transform* Triggered while dragging, when a feature is transformed.
|
||||
* Listeners receive an event object with one or more of *center*,
|
||||
* *scale*, *ratio* and *rotation*. The *center* property is an
|
||||
* <OpenLayers.Geometry.Point> object with the new center of the
|
||||
* transformed feature, the others are Floats with the scale, ratio
|
||||
* or rotation change of the feature since the last transformation.
|
||||
* - *transformcomplete* Triggered after dragging. Listeners receive
|
||||
* an event object with the transformed *feature*.
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforesetfeature - Triggered before a feature is set for
|
||||
* tranformation. The feature will not be set if a listener returns
|
||||
* false. Listeners receive a *feature* property, with the feature
|
||||
* that will be set for transformation. Listeners are allowed to
|
||||
* set the control's *scale*, *ratio* and *rotation* properties,
|
||||
* which will set the initial scale, ratio and rotation of the
|
||||
* feature, like the <setFeature> method's initialParams argument.
|
||||
* setfeature - Triggered when a feature is set for tranformation.
|
||||
* Listeners receive a *feature* property, with the feature that
|
||||
* is now set for transformation.
|
||||
* beforetransform - Triggered while dragging, before a feature is
|
||||
* transformed. The feature will not be transformed if a listener
|
||||
* returns false (but the box still will). Listeners receive one or
|
||||
* more of *center*, *scale*, *ratio* and *rotation*. The *center*
|
||||
* property is an <OpenLayers.Geometry.Point> object with the new
|
||||
* center of the transformed feature, the others are Floats with the
|
||||
* scale, ratio or rotation change since the last transformation.
|
||||
* transform - Triggered while dragging, when a feature is transformed.
|
||||
* Listeners receive an event object with one or more of *center*,
|
||||
* scale*, *ratio* and *rotation*. The *center* property is an
|
||||
* <OpenLayers.Geometry.Point> object with the new center of the
|
||||
* transformed feature, the others are Floats with the scale, ratio
|
||||
* or rotation change of the feature since the last transformation.
|
||||
* transformcomplete - Triggered after dragging. Listeners receive
|
||||
* an event object with the transformed *feature*.
|
||||
*/
|
||||
EVENT_TYPES: ["beforesetfeature", "setfeature", "beforetransform",
|
||||
"transform", "transformcomplete"],
|
||||
|
||||
/**
|
||||
* APIProperty: geometryTypes
|
||||
@ -170,6 +175,15 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
dragControl: null,
|
||||
|
||||
/**
|
||||
* APIProperty: irregular
|
||||
* {Boolean} Make scaling/resizing work irregularly. If true then
|
||||
* dragging a handle causes the feature to resize in the direction
|
||||
* of movement. If false then the feature resizes symetrically
|
||||
* about it's center.
|
||||
*/
|
||||
irregular: false,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Control.TransformFeature
|
||||
* Create a new transform feature control.
|
||||
@ -181,11 +195,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
* control.
|
||||
*/
|
||||
initialize: function(layer, options) {
|
||||
// concatenate events specific to this control with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.TransformFeature.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
|
||||
this.layer = layer;
|
||||
@ -265,13 +274,15 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
scale: 1,
|
||||
ratio: 1
|
||||
});
|
||||
var evt = {feature: feature};
|
||||
|
||||
|
||||
var oldRotation = this.rotation;
|
||||
var oldCenter = this.center;
|
||||
OpenLayers.Util.extend(this, initialParams);
|
||||
|
||||
if(this.events.triggerEvent("beforesetfeature", evt) === false) {
|
||||
var cont = this.events.triggerEvent("beforesetfeature",
|
||||
{feature: feature}
|
||||
);
|
||||
if (cont === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -303,7 +314,23 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
delete this._setfeature;
|
||||
|
||||
this.events.triggerEvent("setfeature", evt);
|
||||
this.events.triggerEvent("setfeature", {feature: feature});
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: unsetFeature
|
||||
* Remove the transformation box off any feature.
|
||||
* If the control is active, it will be deactivated first.
|
||||
*/
|
||||
unsetFeature: function() {
|
||||
if (this.active) {
|
||||
this.deactivate();
|
||||
} else {
|
||||
this.feature = null;
|
||||
this.rotation = 0;
|
||||
this.scale = 1;
|
||||
this.ratio = 1;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -314,7 +341,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var control = this;
|
||||
|
||||
this.center = new OpenLayers.Geometry.Point(0, 0);
|
||||
var box = new OpenLayers.Feature.Vector(
|
||||
this.box = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString([
|
||||
new OpenLayers.Geometry.Point(-1, -1),
|
||||
new OpenLayers.Geometry.Point(0, -1),
|
||||
@ -330,7 +357,7 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
);
|
||||
|
||||
// Override for box move - make sure that the center gets updated
|
||||
box.geometry.move = function(x, y) {
|
||||
this.box.geometry.move = function(x, y) {
|
||||
control._moving = true;
|
||||
OpenLayers.Geometry.LineString.prototype.move.apply(this, arguments);
|
||||
control.center.move(x, y);
|
||||
@ -378,6 +405,10 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var dy1 = this.y - centerGeometry.y;
|
||||
var dx0 = dx1 - (this.x - oldGeom.x);
|
||||
var dy0 = dy1 - (this.y - oldGeom.y);
|
||||
if (control.irregular && !control._setfeature) {
|
||||
dx1 -= (this.x - oldGeom.x) / 2;
|
||||
dy1 -= (this.y - oldGeom.y) / 2;
|
||||
}
|
||||
this.x = oldX;
|
||||
this.y = oldY;
|
||||
var scale, ratio = 1;
|
||||
@ -399,6 +430,13 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
control.box.geometry.resize(scale, centerGeometry, ratio);
|
||||
control.box.geometry.rotate(control.rotation, centerGeometry);
|
||||
control.transformFeature({scale: scale, ratio: ratio});
|
||||
if (control.irregular && !control._setfeature) {
|
||||
var newCenter = centerGeometry.clone();
|
||||
newCenter.x += Math.abs(oldX - centerGeometry.x) < 0.00001 ? 0 : (this.x - oldX);
|
||||
newCenter.y += Math.abs(oldY - centerGeometry.y) < 0.00001 ? 0 : (this.y - oldY);
|
||||
control.box.geometry.move(this.x - oldX, this.y - oldY);
|
||||
control.transformFeature({center: newCenter});
|
||||
}
|
||||
};
|
||||
|
||||
// Override for rotation handle move - make sure that the box and
|
||||
@ -436,14 +474,17 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
var handles = new Array(8);
|
||||
var rotationHandles = new Array(4);
|
||||
var geom, handle, rotationHandle;
|
||||
var positions = ["sw", "s", "se", "e", "ne", "n", "nw", "w"];
|
||||
for(var i=0; i<8; ++i) {
|
||||
geom = box.geometry.components[i];
|
||||
handle = new OpenLayers.Feature.Vector(geom.clone(), null,
|
||||
typeof this.renderIntent == "string" ? null :
|
||||
geom = this.box.geometry.components[i];
|
||||
handle = new OpenLayers.Feature.Vector(geom.clone(), {
|
||||
role: positions[i] + "-resize"
|
||||
}, typeof this.renderIntent == "string" ? null :
|
||||
this.renderIntent);
|
||||
if(i % 2 == 0) {
|
||||
rotationHandle = new OpenLayers.Feature.Vector(geom.clone(),
|
||||
null, typeof this.rotationHandleSymbolizer == "string" ?
|
||||
rotationHandle = new OpenLayers.Feature.Vector(geom.clone(), {
|
||||
role: positions[i] + "-rotate"
|
||||
}, typeof this.rotationHandleSymbolizer == "string" ?
|
||||
null : this.rotationHandleSymbolizer);
|
||||
rotationHandle.geometry.move = rotationHandleMoveFn;
|
||||
geom._rotationHandle = rotationHandle;
|
||||
@ -457,7 +498,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
handles[i] = handle;
|
||||
}
|
||||
|
||||
this.box = box;
|
||||
this.rotationHandles = rotationHandles;
|
||||
this.handles = handles;
|
||||
},
|
||||
@ -482,7 +522,6 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
onDrag: function(feature, pixel) {
|
||||
if(feature === control.box) {
|
||||
control.transformFeature({center: control.center});
|
||||
control.drawHandles();
|
||||
}
|
||||
},
|
||||
// set a new feature
|
||||
@ -568,10 +607,16 @@ OpenLayers.Control.TransformFeature = OpenLayers.Class(OpenLayers.Control, {
|
||||
geom._rotationHandle && geom._rotationHandle.destroy();
|
||||
geom._rotationHandle = null;
|
||||
}
|
||||
this.center = null;
|
||||
this.feature = null;
|
||||
this.handles = null;
|
||||
this.rotationHandleSymbolizer = null;
|
||||
this.rotationHandles = null;
|
||||
this.box.destroy();
|
||||
this.box = null;
|
||||
this.layer = null;
|
||||
this.dragControl.destroy();
|
||||
this.dragControl = null;
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
||||
240
js/openlayers/src/openlayers/lib/OpenLayers/Control/UTFGrid.js
Normal file
@ -0,0 +1,240 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Handler/Hover.js
|
||||
* @requires OpenLayers/Handler/Click.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.UTFGrid
|
||||
*
|
||||
* This Control provides behavior associated with UTFGrid Layers.
|
||||
* These 'hit grids' provide underlying feature attributes without
|
||||
* calling the server (again). This control allows Mousemove, Hovering
|
||||
* and Click events to trigger callbacks that use the attributes in
|
||||
* whatever way you need.
|
||||
*
|
||||
* The most common example may be a UTFGrid layer containing feature
|
||||
* attributes that are displayed in a div as you mouseover.
|
||||
*
|
||||
* Example Code:
|
||||
*
|
||||
* (start code)
|
||||
* var world_utfgrid = new OpenLayers.Layer.UTFGrid(
|
||||
* 'UTFGrid Layer',
|
||||
* "http://tiles/world_utfgrid/${z}/${x}/${y}.json"
|
||||
* );
|
||||
* map.addLayer(world_utfgrid);
|
||||
*
|
||||
* var control = new OpenLayers.Control.UTFGrid({
|
||||
* layers: [world_utfgrid],
|
||||
* handlerMode: 'move',
|
||||
* callback: function(infoLookup) {
|
||||
* // do something with returned data
|
||||
*
|
||||
* }
|
||||
* })
|
||||
* (end code)
|
||||
*
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.UTFGrid = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: autoActivate
|
||||
* {Boolean} Activate the control when it is added to a map. Default is
|
||||
* true.
|
||||
*/
|
||||
autoActivate: true,
|
||||
|
||||
/**
|
||||
* APIProperty: Layers
|
||||
* List of layers to consider. Must be Layer.UTFGrids
|
||||
* `null` is the default indicating all UTFGrid Layers are queried.
|
||||
* {Array} <OpenLayers.Layer.UTFGrid>
|
||||
*/
|
||||
layers: null,
|
||||
|
||||
/* Property: defaultHandlerOptions
|
||||
* The default opts passed to the handler constructors
|
||||
*/
|
||||
defaultHandlerOptions: {
|
||||
'delay': 300,
|
||||
'pixelTolerance': 4,
|
||||
'stopMove': false,
|
||||
'single': true,
|
||||
'double': false,
|
||||
'stopSingle': false,
|
||||
'stopDouble': false
|
||||
},
|
||||
|
||||
/* APIProperty: handlerMode
|
||||
* Defaults to 'click'. Can be 'hover' or 'move'.
|
||||
*/
|
||||
handlerMode: 'click',
|
||||
|
||||
/**
|
||||
* APIMethod: setHandler
|
||||
* sets this.handlerMode and calls resetHandler()
|
||||
*
|
||||
* Parameters:
|
||||
* hm - {String} Handler Mode string; 'click', 'hover' or 'move'.
|
||||
*/
|
||||
setHandler: function(hm) {
|
||||
this.handlerMode = hm;
|
||||
this.resetHandler();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: resetHandler
|
||||
* Deactivates the old hanlder and creates a new
|
||||
* <OpenLayers.Handler> based on the mode specified in
|
||||
* this.handlerMode
|
||||
*
|
||||
*/
|
||||
resetHandler: function() {
|
||||
if (this.handler) {
|
||||
this.handler.deactivate();
|
||||
this.handler.destroy();
|
||||
this.handler = null;
|
||||
}
|
||||
|
||||
if (this.handlerMode == 'hover') {
|
||||
// Handle this event on hover
|
||||
this.handler = new OpenLayers.Handler.Hover(
|
||||
this,
|
||||
{'pause': this.handleEvent, 'move': this.reset},
|
||||
this.handlerOptions
|
||||
);
|
||||
} else if (this.handlerMode == 'click') {
|
||||
// Handle this event on click
|
||||
this.handler = new OpenLayers.Handler.Click(
|
||||
this, {
|
||||
'click': this.handleEvent
|
||||
}, this.handlerOptions
|
||||
);
|
||||
} else if (this.handlerMode == 'move') {
|
||||
this.handler = new OpenLayers.Handler.Hover(
|
||||
this,
|
||||
// Handle this event while hovering OR moving
|
||||
{'pause': this.handleEvent, 'move': this.handleEvent},
|
||||
this.handlerOptions
|
||||
);
|
||||
}
|
||||
if (this.handler) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Constructor: <OpenLayers.Control.UTFGrid>
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
options.handlerOptions = options.handlerOptions || this.defaultHandlerOptions;
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
this.resetHandler();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: handleEvent
|
||||
* Internal method called when specified event is triggered.
|
||||
*
|
||||
* This method does several things:
|
||||
*
|
||||
* Gets the lonLat of the event.
|
||||
*
|
||||
* Loops through the appropriate hit grid layers and gathers the attributes.
|
||||
*
|
||||
* Passes the attributes to the callback
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
handleEvent: function(evt) {
|
||||
if (evt == null) {
|
||||
this.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
var lonLat = this.map.getLonLatFromPixel(evt.xy);
|
||||
if (!lonLat) {
|
||||
return;
|
||||
}
|
||||
|
||||
var layers = this.findLayers();
|
||||
if (layers.length > 0) {
|
||||
var infoLookup = {};
|
||||
var layer, idx;
|
||||
for (var i=0, len=layers.length; i<len; i++) {
|
||||
layer = layers[i];
|
||||
idx = OpenLayers.Util.indexOf(this.map.layers, layer);
|
||||
infoLookup[idx] = layer.getFeatureInfo(lonLat);
|
||||
}
|
||||
this.callback(infoLookup, lonLat, evt.xy);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: callback
|
||||
* Function to be called when a mouse event corresponds with a location that
|
||||
* includes data in one of the configured UTFGrid layers.
|
||||
*
|
||||
* Parameters:
|
||||
* infoLookup - {Object} Keys of this object are layer indexes and can be
|
||||
* used to resolve a layer in the map.layers array. The structure of
|
||||
* the property values depend on the data included in the underlying
|
||||
* UTFGrid and may be any valid JSON type.
|
||||
*/
|
||||
callback: function(infoLookup) {
|
||||
// to be provided in the constructor
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: reset
|
||||
* Calls the callback with null.
|
||||
*/
|
||||
reset: function(evt) {
|
||||
this.callback(null);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: findLayers
|
||||
* Internal method to get the layers, independent of whether we are
|
||||
* inspecting the map or using a client-provided array
|
||||
*
|
||||
* The default value of this.layers is null; this causes the
|
||||
* findLayers method to return ALL UTFGrid layers encountered.
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
*
|
||||
* Returns:
|
||||
* {Array} Layers to handle on each event
|
||||
*/
|
||||
findLayers: function() {
|
||||
var candidates = this.layers || this.map.layers;
|
||||
var layers = [];
|
||||
var layer;
|
||||
for (var i=candidates.length-1; i>=0; --i) {
|
||||
layer = candidates[i];
|
||||
if (layer instanceof OpenLayers.Layer.UTFGrid ) {
|
||||
layers.push(layer);
|
||||
}
|
||||
}
|
||||
return layers;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.UTFGrid"
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -9,15 +9,16 @@
|
||||
* @requires OpenLayers/Handler/Click.js
|
||||
* @requires OpenLayers/Handler/Hover.js
|
||||
* @requires OpenLayers/Request.js
|
||||
* @requires OpenLayers/Format/WMSGetFeatureInfo.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.WMSGetFeatureInfo
|
||||
* The WMSGetFeatureInfo control uses a WMS query to get information about a point on the map. The
|
||||
* information may be in a display-friendly format such as HTML, or a machine-friendly format such
|
||||
* as GML, depending on the server's capabilities and the client's configuration. This control
|
||||
* handles click or hover events, attempts to parse the results using an OpenLayers.Format, and
|
||||
* fires a 'getfeatureinfo' event with the click position, the raw body of the response, and an
|
||||
* information may be in a display-friendly format such as HTML, or a machine-friendly format such
|
||||
* as GML, depending on the server's capabilities and the client's configuration. This control
|
||||
* handles click or hover events, attempts to parse the results using an OpenLayers.Format, and
|
||||
* fires a 'getfeatureinfo' event with the click position, the raw body of the response, and an
|
||||
* array of features if it successfully read the response.
|
||||
*
|
||||
* Inherits from:
|
||||
@ -48,15 +49,25 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
maxFeatures: 10,
|
||||
|
||||
/** APIProperty: clickCallback
|
||||
* {String} The click callback to register in the
|
||||
* {<OpenLayers.Handler.Click>} object created when the hover
|
||||
* option is set to false. Default is "click".
|
||||
/**
|
||||
* APIProperty: clickCallback
|
||||
* {String} The click callback to register in the
|
||||
* {<OpenLayers.Handler.Click>} object created when the hover
|
||||
* option is set to false. Default is "click".
|
||||
*/
|
||||
clickCallback: "click",
|
||||
|
||||
|
||||
/**
|
||||
* Property: layers
|
||||
* APIProperty: output
|
||||
* {String} Either "features" or "object". When triggering a getfeatureinfo
|
||||
* request should we pass on an array of features or an object with with
|
||||
* a "features" property and other properties (such as the url of the
|
||||
* WMS). Default is "features".
|
||||
*/
|
||||
output: "features",
|
||||
|
||||
/**
|
||||
* APIProperty: layers
|
||||
* {Array(<OpenLayers.Layer.WMS>)} The layers to query for feature info.
|
||||
* If omitted, all map WMS layers with a url that matches this <url> or
|
||||
* <layerUrls> will be considered.
|
||||
@ -64,21 +75,21 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
layers: null,
|
||||
|
||||
/**
|
||||
* Property: queryVisible
|
||||
* APIProperty: queryVisible
|
||||
* {Boolean} If true, filter out hidden layers when searching the map for
|
||||
* layers to query. Default is false.
|
||||
*/
|
||||
queryVisible: false,
|
||||
|
||||
/**
|
||||
* Property: url
|
||||
* APIProperty: url
|
||||
* {String} The URL of the WMS service to use. If not provided, the url
|
||||
* of the first eligible layer will be used.
|
||||
*/
|
||||
url: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: layerUrls
|
||||
* APIProperty: layerUrls
|
||||
* {Array(String)} Optional list of urls for layers that should be queried.
|
||||
* This can be used when the layer url differs from the url used for
|
||||
* making GetFeatureInfo requests (in the case of a layer using cached
|
||||
@ -87,15 +98,18 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
layerUrls: null,
|
||||
|
||||
/**
|
||||
* Property: infoFormat
|
||||
* {String} The mimetype to request from the server
|
||||
* APIProperty: infoFormat
|
||||
* {String} The mimetype to request from the server. If you are using
|
||||
* drillDown mode and have multiple servers that do not share a common
|
||||
* infoFormat, you can override the control's infoFormat by providing an
|
||||
* INFO_FORMAT parameter in your <OpenLayers.Layer.WMS> instance(s).
|
||||
*/
|
||||
infoFormat: 'text/html',
|
||||
|
||||
|
||||
/**
|
||||
* Property: vendorParams
|
||||
* APIProperty: vendorParams
|
||||
* {Object} Additional parameters that will be added to the request, for
|
||||
* WMS implementations that support them. This could e.g. look like
|
||||
* WMS implementations that support them. This could e.g. look like
|
||||
* (start code)
|
||||
* {
|
||||
* radius: 5
|
||||
@ -103,16 +117,16 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* (end)
|
||||
*/
|
||||
vendorParams: {},
|
||||
|
||||
|
||||
/**
|
||||
* Property: format
|
||||
* APIProperty: format
|
||||
* {<OpenLayers.Format>} A format for parsing GetFeatureInfo responses.
|
||||
* Default is <OpenLayers.Format.WMSGetFeatureInfo>.
|
||||
*/
|
||||
format: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: formatOptions
|
||||
* APIProperty: formatOptions
|
||||
* {Object} Optional properties to set on the format (if one is not provided
|
||||
* in the <format> property.
|
||||
*/
|
||||
@ -128,27 +142,33 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* }
|
||||
* (end)
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: handler
|
||||
* {Object} Reference to the <OpenLayers.Handler> for this control
|
||||
*/
|
||||
handler: null,
|
||||
|
||||
|
||||
/**
|
||||
* Property: hoverRequest
|
||||
* {<OpenLayers.Request>} contains the currently running hover request
|
||||
* (if any).
|
||||
*/
|
||||
hoverRequest: null,
|
||||
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control>):
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforegetfeatureinfo - Triggered before the request is sent.
|
||||
* The event object has an *xy* property with the position of the
|
||||
* The event object has an *xy* property with the position of the
|
||||
* mouse click or hover event that triggers the request.
|
||||
* nogetfeatureinfo - no queryable layers were found.
|
||||
* getfeatureinfo - Triggered when a GetFeatureInfo response is received.
|
||||
@ -161,32 +181,25 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* layers, *text* and *request* will only contain the response body
|
||||
* and request object of the last request.
|
||||
*/
|
||||
EVENT_TYPES: ["beforegetfeatureinfo", "nogetfeatureinfo", "getfeatureinfo"],
|
||||
|
||||
/**
|
||||
* Constructor: <OpenLayers.Control.WMSGetFeatureInfo>
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object}
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
// concatenate events specific to vector with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.WMSGetFeatureInfo.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
|
||||
options = options || {};
|
||||
options.handlerOptions = options.handlerOptions || {};
|
||||
|
||||
OpenLayers.Control.prototype.initialize.apply(this, [options]);
|
||||
|
||||
|
||||
if(!this.format) {
|
||||
this.format = new OpenLayers.Format.WMSGetFeatureInfo(
|
||||
options.formatOptions
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(this.drillDown === true) {
|
||||
this.hover = false;
|
||||
}
|
||||
@ -209,40 +222,11 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: activate
|
||||
* Activates the control.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The control was effectively activated.
|
||||
*/
|
||||
activate: function () {
|
||||
if (!this.active) {
|
||||
this.handler.activate();
|
||||
}
|
||||
return OpenLayers.Control.prototype.activate.apply(
|
||||
this, arguments
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: deactivate
|
||||
* Deactivates the control.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The control was effectively deactivated.
|
||||
*/
|
||||
deactivate: function () {
|
||||
return OpenLayers.Control.prototype.deactivate.apply(
|
||||
this, arguments
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getInfoForClick
|
||||
* Method: getInfoForClick
|
||||
* Called on click
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
getInfoForClick: function(evt) {
|
||||
this.events.triggerEvent("beforegetfeatureinfo", {xy: evt.xy});
|
||||
@ -251,7 +235,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Element.addClass(this.map.viewPortDiv, "olCursorWait");
|
||||
this.request(evt.xy, {});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: getInfoForHover
|
||||
* Pause callback for the hover handler
|
||||
@ -285,11 +269,11 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
var candidates = this.layers || this.map.layers;
|
||||
var layers = [];
|
||||
var layer, url;
|
||||
for(var i=0, len=candidates.length; i<len; ++i) {
|
||||
for(var i = candidates.length - 1; i >= 0; --i) {
|
||||
layer = candidates[i];
|
||||
if(layer instanceof OpenLayers.Layer.WMS &&
|
||||
(!this.queryVisible || layer.getVisibility())) {
|
||||
url = layer.url instanceof Array ? layer.url[0] : layer.url;
|
||||
url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
|
||||
// if the control was not configured with a url, set it
|
||||
// to the first layer url
|
||||
if(this.drillDown === false && !this.url) {
|
||||
@ -302,7 +286,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
return layers;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: urlMatches
|
||||
* Test to see if the provided url matches either the control <url> or one
|
||||
@ -341,42 +325,57 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
buildWMSOptions: function(url, layers, clickPosition, format) {
|
||||
var layerNames = [], styleNames = [];
|
||||
for (var i = 0, len = layers.length; i < len; i++) {
|
||||
layerNames = layerNames.concat(layers[i].params.LAYERS);
|
||||
styleNames = styleNames.concat(this.getStyleNames(layers[i]));
|
||||
for (var i = 0, len = layers.length; i < len; i++) {
|
||||
if (layers[i].params.LAYERS != null) {
|
||||
layerNames = layerNames.concat(layers[i].params.LAYERS);
|
||||
styleNames = styleNames.concat(this.getStyleNames(layers[i]));
|
||||
}
|
||||
}
|
||||
var firstLayer = layers[0];
|
||||
// use the firstLayer's projection if it matches the map projection -
|
||||
// this assumes that all layers will be available in this projection
|
||||
var projection = this.map.getProjection();
|
||||
var layerProj = firstLayer.projection;
|
||||
if (layerProj && layerProj.equals(this.map.getProjectionObject())) {
|
||||
projection = layerProj.getCode();
|
||||
}
|
||||
var params = OpenLayers.Util.extend({
|
||||
service: "WMS",
|
||||
version: layers[0].params.VERSION,
|
||||
version: firstLayer.params.VERSION,
|
||||
request: "GetFeatureInfo",
|
||||
layers: layerNames,
|
||||
query_layers: layerNames,
|
||||
styles: styleNames,
|
||||
exceptions: firstLayer.params.EXCEPTIONS,
|
||||
bbox: this.map.getExtent().toBBOX(null,
|
||||
layers[0].reverseAxisOrder()),
|
||||
firstLayer.reverseAxisOrder()),
|
||||
feature_count: this.maxFeatures,
|
||||
height: this.map.getSize().h,
|
||||
width: this.map.getSize().w,
|
||||
format: format,
|
||||
info_format: this.infoFormat
|
||||
}, (parseFloat(layers[0].params.VERSION) >= 1.3) ?
|
||||
info_format: firstLayer.params.INFO_FORMAT || this.infoFormat
|
||||
}, (parseFloat(firstLayer.params.VERSION) >= 1.3) ?
|
||||
{
|
||||
crs: this.map.getProjection(),
|
||||
i: clickPosition.x,
|
||||
j: clickPosition.y
|
||||
crs: projection,
|
||||
i: parseInt(clickPosition.x),
|
||||
j: parseInt(clickPosition.y)
|
||||
} :
|
||||
{
|
||||
srs: this.map.getProjection(),
|
||||
x: clickPosition.x,
|
||||
y: clickPosition.y
|
||||
srs: projection,
|
||||
x: parseInt(clickPosition.x),
|
||||
y: parseInt(clickPosition.y)
|
||||
}
|
||||
);
|
||||
if (layerNames.length != 0) {
|
||||
params = OpenLayers.Util.extend({
|
||||
layers: layerNames,
|
||||
query_layers: layerNames,
|
||||
styles: styleNames
|
||||
}, params);
|
||||
}
|
||||
OpenLayers.Util.applyDefaults(params, this.vendorParams);
|
||||
return {
|
||||
url: url,
|
||||
params: OpenLayers.Util.upperCaseObject(params),
|
||||
callback: function(request) {
|
||||
this.handleResponse(clickPosition, request);
|
||||
this.handleResponse(clickPosition, request, url);
|
||||
},
|
||||
scope: this
|
||||
};
|
||||
@ -386,7 +385,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: getStyleNames
|
||||
* Gets the STYLES parameter for the layer. Make sure the STYLES parameter
|
||||
* matches the LAYERS parameter
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* layer - {<OpenLayers.Layer.WMS>}
|
||||
*
|
||||
@ -402,7 +401,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (layer.params.STYLES) {
|
||||
styleNames = layer.params.STYLES;
|
||||
} else {
|
||||
if (layer.params.LAYERS instanceof Array) {
|
||||
if (OpenLayers.Util.isArray(layer.params.LAYERS)) {
|
||||
styleNames = new Array(layer.params.LAYERS.length);
|
||||
} else { // Assume it's a String
|
||||
styleNames = layer.params.LAYERS.replace(/[^,]/g, "");
|
||||
@ -414,12 +413,12 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
/**
|
||||
* Method: request
|
||||
* Sends a GetFeatureInfo request to the WMS
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* clickPosition - {<OpenLayers.Pixel>} The position on the map where the
|
||||
* mouse event occurred.
|
||||
* options - {Object} additional options for this method.
|
||||
*
|
||||
*
|
||||
* Valid options:
|
||||
* - *hover* {Boolean} true if we do the request for the hover handler
|
||||
*/
|
||||
@ -431,13 +430,13 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Element.removeClass(this.map.viewPortDiv, "olCursorWait");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
options = options || {};
|
||||
if(this.drillDown === false) {
|
||||
var wmsOptions = this.buildWMSOptions(this.url, layers,
|
||||
clickPosition, layers[0].params.FORMAT);
|
||||
clickPosition, layers[0].params.FORMAT);
|
||||
var request = OpenLayers.Request.GET(wmsOptions);
|
||||
|
||||
|
||||
if (options.hover === true) {
|
||||
this.hoverRequest = request;
|
||||
}
|
||||
@ -450,7 +449,7 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
for(var i=0, len=layers.length; i<len; i++) {
|
||||
var layer = layers[i];
|
||||
var service, found = false;
|
||||
url = layer.url instanceof Array ? layer.url[0] : layer.url;
|
||||
url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;
|
||||
if(url in services) {
|
||||
services[url].push(layer);
|
||||
} else {
|
||||
@ -461,9 +460,9 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
var layers;
|
||||
for (var url in services) {
|
||||
layers = services[url];
|
||||
var wmsOptions = this.buildWMSOptions(url, layers,
|
||||
var wmsOptions = this.buildWMSOptions(url, layers,
|
||||
clickPosition, layers[0].params.FORMAT);
|
||||
OpenLayers.Request.GET(wmsOptions);
|
||||
OpenLayers.Request.GET(wmsOptions);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -476,7 +475,9 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* request - {XMLHttpRequest} The request object
|
||||
* xy - {<OpenLayers.Pixel>} The position on the map where the
|
||||
* mouse event occurred.
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)}
|
||||
* features - {Array(<OpenLayers.Feature.Vector>)} or
|
||||
* {Array({Object}) when output is "object". The object has a url and a
|
||||
* features property which contains an array of features.
|
||||
*/
|
||||
triggerGetFeatureInfo: function(request, xy, features) {
|
||||
this.events.triggerEvent("getfeatureinfo", {
|
||||
@ -489,18 +490,19 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
// Reset the cursor.
|
||||
OpenLayers.Element.removeClass(this.map.viewPortDiv, "olCursorWait");
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: handleResponse
|
||||
* Handler for the GetFeatureInfo response.
|
||||
*
|
||||
*
|
||||
* Parameters:
|
||||
* xy - {<OpenLayers.Pixel>} The position on the map where the
|
||||
* mouse event occurred.
|
||||
* request - {XMLHttpRequest} The request object.
|
||||
* url - {String} The url which was used for this request.
|
||||
*/
|
||||
handleResponse: function(xy, request) {
|
||||
|
||||
handleResponse: function(xy, request, url) {
|
||||
|
||||
var doc = request.responseXML;
|
||||
if(!doc || !doc.documentElement) {
|
||||
doc = request.responseText;
|
||||
@ -510,9 +512,15 @@ OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.triggerGetFeatureInfo(request, xy, features);
|
||||
} else {
|
||||
this._requestCount++;
|
||||
if (this.output === "object") {
|
||||
this._features = (this._features || []).concat(
|
||||
{url: url, features: features}
|
||||
);
|
||||
} else {
|
||||
this._features = (this._features || []).concat(features);
|
||||
}
|
||||
if (this._requestCount === this._numRequests) {
|
||||
this.triggerGetFeatureInfo(request, xy, this._features.concat());
|
||||
this.triggerGetFeatureInfo(request, xy, this._features.concat());
|
||||
delete this._features;
|
||||
delete this._requestCount;
|
||||
delete this._numRequests;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -120,7 +120,6 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* }
|
||||
* (end)
|
||||
*/
|
||||
handlerOptions: null,
|
||||
|
||||
/**
|
||||
* Property: handler
|
||||
@ -135,10 +134,17 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
hoverRequest: null,
|
||||
|
||||
/**
|
||||
* Constant: EVENT_TYPES
|
||||
/**
|
||||
* APIProperty: events
|
||||
* {<OpenLayers.Events>} Events instance for listeners and triggering
|
||||
* control specific events.
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control>):
|
||||
* Register a listener for a particular event with the following syntax:
|
||||
* (code)
|
||||
* control.events.register(type, obj, listener);
|
||||
* (end)
|
||||
*
|
||||
* Supported event types (in addition to those from <OpenLayers.Control.events>):
|
||||
* beforegetfeatureinfo - Triggered before each request is sent.
|
||||
* The event object has an *xy* property with the position of the
|
||||
* mouse click or hover event that triggers the request and a *layer*
|
||||
@ -157,7 +163,6 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* an event with *request*, *xy*, and *layer* properties. In the case
|
||||
* of a parsing error, the event will also contain an *error* property.
|
||||
*/
|
||||
EVENT_TYPES: ["beforegetfeatureinfo", "getfeatureinfo", "exception"],
|
||||
|
||||
/**
|
||||
* Property: pending
|
||||
@ -172,12 +177,6 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
// concatenate events specific to vector with those from the base
|
||||
this.EVENT_TYPES =
|
||||
OpenLayers.Control.WMTSGetFeatureInfo.prototype.EVENT_TYPES.concat(
|
||||
OpenLayers.Control.prototype.EVENT_TYPES
|
||||
);
|
||||
|
||||
options = options || {};
|
||||
options.handlerOptions = options.handlerOptions || {};
|
||||
|
||||
@ -212,35 +211,6 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: activate
|
||||
* Activates the control.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The control was effectively activated.
|
||||
*/
|
||||
activate: function () {
|
||||
if (!this.active) {
|
||||
this.handler.activate();
|
||||
}
|
||||
return OpenLayers.Control.prototype.activate.apply(
|
||||
this, arguments
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: deactivate
|
||||
* Deactivates the control.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The control was effectively deactivated.
|
||||
*/
|
||||
deactivate: function () {
|
||||
return OpenLayers.Control.prototype.deactivate.apply(
|
||||
this, arguments
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getInfoForClick
|
||||
* Called on click
|
||||
@ -328,7 +298,7 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
});
|
||||
OpenLayers.Util.applyDefaults(params, this.vendorParams);
|
||||
return {
|
||||
url: layer.url instanceof Array ? layer.url[0] : layer.url,
|
||||
url: OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url,
|
||||
params: OpenLayers.Util.upperCaseObject(params),
|
||||
callback: function(request) {
|
||||
this.handleResponse(xy, request, layer);
|
||||
@ -425,18 +395,6 @@ OpenLayers.Control.WMTSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setMap
|
||||
* Set the map property for the control.
|
||||
*
|
||||
* Parameters:
|
||||
* map - {<OpenLayers.Map>}
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.handler.setMap(map);
|
||||
OpenLayers.Control.prototype.setMap.apply(this, arguments);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.WMTSGetFeatureInfo"
|
||||
});
|
||||
|
||||
138
js/openlayers/src/openlayers/lib/OpenLayers/Control/Zoom.js
Normal file
@ -0,0 +1,138 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Events/buttonclick.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Control.Zoom
|
||||
* The Zoom control is a pair of +/- links for zooming in and out.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.Zoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
|
||||
/**
|
||||
* APIProperty: zoomInText
|
||||
* {String}
|
||||
* Text for zoom-in link. Default is "+".
|
||||
*/
|
||||
zoomInText: "+",
|
||||
|
||||
/**
|
||||
* APIProperty: zoomInId
|
||||
* {String}
|
||||
* Instead of having the control create a zoom in link, you can provide
|
||||
* the identifier for an anchor element already added to the document.
|
||||
* By default, an element with id "olZoomInLink" will be searched for
|
||||
* and used if it exists.
|
||||
*/
|
||||
zoomInId: "olZoomInLink",
|
||||
|
||||
/**
|
||||
* APIProperty: zoomOutText
|
||||
* {String}
|
||||
* Text for zoom-out link. Default is "\u2212".
|
||||
*/
|
||||
zoomOutText: "\u2212",
|
||||
|
||||
/**
|
||||
* APIProperty: zoomOutId
|
||||
* {String}
|
||||
* Instead of having the control create a zoom out link, you can provide
|
||||
* the identifier for an anchor element already added to the document.
|
||||
* By default, an element with id "olZoomOutLink" will be searched for
|
||||
* and used if it exists.
|
||||
*/
|
||||
zoomOutId: "olZoomOutLink",
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} A reference to the DOMElement containing the zoom links.
|
||||
*/
|
||||
draw: function() {
|
||||
var div = OpenLayers.Control.prototype.draw.apply(this),
|
||||
links = this.getOrCreateLinks(div),
|
||||
zoomIn = links.zoomIn,
|
||||
zoomOut = links.zoomOut,
|
||||
eventsInstance = this.map.events;
|
||||
|
||||
if (zoomOut.parentNode !== div) {
|
||||
eventsInstance = this.events;
|
||||
eventsInstance.attachToElement(zoomOut.parentNode);
|
||||
}
|
||||
eventsInstance.register("buttonclick", this, this.onZoomClick);
|
||||
|
||||
this.zoomInLink = zoomIn;
|
||||
this.zoomOutLink = zoomOut;
|
||||
return div;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getOrCreateLinks
|
||||
*
|
||||
* Parameters:
|
||||
* el - {DOMElement}
|
||||
*
|
||||
* Return:
|
||||
* {Object} Object with zoomIn and zoomOut properties referencing links.
|
||||
*/
|
||||
getOrCreateLinks: function(el) {
|
||||
var zoomIn = document.getElementById(this.zoomInId),
|
||||
zoomOut = document.getElementById(this.zoomOutId);
|
||||
if (!zoomIn) {
|
||||
zoomIn = document.createElement("a");
|
||||
zoomIn.href = "#zoomIn";
|
||||
zoomIn.appendChild(document.createTextNode(this.zoomInText));
|
||||
zoomIn.className = "olControlZoomIn";
|
||||
el.appendChild(zoomIn);
|
||||
}
|
||||
OpenLayers.Element.addClass(zoomIn, "olButton");
|
||||
if (!zoomOut) {
|
||||
zoomOut = document.createElement("a");
|
||||
zoomOut.href = "#zoomOut";
|
||||
zoomOut.appendChild(document.createTextNode(this.zoomOutText));
|
||||
zoomOut.className = "olControlZoomOut";
|
||||
el.appendChild(zoomOut);
|
||||
}
|
||||
OpenLayers.Element.addClass(zoomOut, "olButton");
|
||||
return {
|
||||
zoomIn: zoomIn, zoomOut: zoomOut
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onZoomClick
|
||||
* Called when zoomin/out link is clicked.
|
||||
*/
|
||||
onZoomClick: function(evt) {
|
||||
var button = evt.buttonElement;
|
||||
if (button === this.zoomInLink) {
|
||||
this.map.zoomIn();
|
||||
} else if (button === this.zoomOutLink) {
|
||||
this.map.zoomOut();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
* Clean up.
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.map) {
|
||||
this.map.events.unregister("buttonclick", this, this.onZoomClick);
|
||||
}
|
||||
delete this.zoomInLink;
|
||||
delete this.zoomOutLink;
|
||||
OpenLayers.Control.prototype.destroy.apply(this);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.Zoom"
|
||||
});
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
@ -31,10 +31,27 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
|
||||
out: false,
|
||||
|
||||
/**
|
||||
* Property: alwaysZoom
|
||||
* {Boolean} Always zoom in/out, when box drawed
|
||||
* APIProperty: keyMask
|
||||
* {Integer} Zoom only occurs if the keyMask matches the combination of
|
||||
* keys down. Use bitwise operators and one or more of the
|
||||
* <OpenLayers.Handler> constants to construct a keyMask. Leave null if
|
||||
* not used mask. Default is null.
|
||||
*/
|
||||
keyMask: null,
|
||||
|
||||
/**
|
||||
* APIProperty: alwaysZoom
|
||||
* {Boolean} Always zoom in/out when box drawn, even if the zoom level does
|
||||
* not change.
|
||||
*/
|
||||
alwaysZoom: false,
|
||||
|
||||
/**
|
||||
* APIProperty: zoomOnClick
|
||||
* {Boolean} Should we zoom when no box was dragged, i.e. the user only
|
||||
* clicked? Default is true.
|
||||
*/
|
||||
zoomOnClick: true,
|
||||
|
||||
/**
|
||||
* Method: draw
|
||||
@ -52,22 +69,26 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
zoomBox: function (position) {
|
||||
if (position instanceof OpenLayers.Bounds) {
|
||||
var bounds;
|
||||
var bounds,
|
||||
targetCenterPx = position.getCenterPixel();
|
||||
if (!this.out) {
|
||||
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 minXY = this.map.getLonLatFromPixel({
|
||||
x: position.left,
|
||||
y: position.bottom
|
||||
});
|
||||
var maxXY = this.map.getLonLatFromPixel({
|
||||
x: position.right,
|
||||
y: position.top
|
||||
});
|
||||
bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
|
||||
maxXY.lon, maxXY.lat);
|
||||
} else {
|
||||
var pixWidth = Math.abs(position.right-position.left);
|
||||
var pixHeight = Math.abs(position.top-position.bottom);
|
||||
var pixWidth = position.right - position.left;
|
||||
var pixHeight = position.bottom - position.top;
|
||||
var zoomFactor = Math.min((this.map.size.h / pixHeight),
|
||||
(this.map.size.w / pixWidth));
|
||||
var extent = this.map.getExtent();
|
||||
var center = this.map.getLonLatFromPixel(
|
||||
position.getCenterPixel());
|
||||
var center = this.map.getLonLatFromPixel(targetCenterPx);
|
||||
var xmin = center.lon - (extent.getWidth()/2)*zoomFactor;
|
||||
var xmax = center.lon + (extent.getWidth()/2)*zoomFactor;
|
||||
var ymin = center.lat - (extent.getHeight()/2)*zoomFactor;
|
||||
@ -75,18 +96,31 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
|
||||
bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);
|
||||
}
|
||||
// always zoom in/out
|
||||
var lastZoom = this.map.getZoom();
|
||||
this.map.zoomToExtent(bounds);
|
||||
var lastZoom = this.map.getZoom(),
|
||||
size = this.map.getSize(),
|
||||
centerPx = {x: size.w / 2, y: size.h / 2},
|
||||
zoom = this.map.getZoomForExtent(bounds),
|
||||
oldRes = this.map.getResolution(),
|
||||
newRes = this.map.getResolutionForZoom(zoom);
|
||||
if (oldRes == newRes) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(targetCenterPx));
|
||||
} else {
|
||||
var zoomOriginPx = {
|
||||
x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /
|
||||
(oldRes - newRes),
|
||||
y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /
|
||||
(oldRes - newRes)
|
||||
};
|
||||
this.map.zoomTo(zoom, zoomOriginPx);
|
||||
}
|
||||
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){
|
||||
this.map.zoomTo(lastZoom + (this.out ? -1 : 1));
|
||||
}
|
||||
} else { // it's a pixel
|
||||
} else if (this.zoomOnClick) { // it's a pixel
|
||||
if (!this.out) {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(position),
|
||||
this.map.getZoom() + 1);
|
||||
this.map.zoomTo(this.map.getZoom() + 1, position);
|
||||
} else {
|
||||
this.map.setCenter(this.map.getLonLatFromPixel(position),
|
||||
this.map.getZoom() - 1);
|
||||
this.map.zoomTo(this.map.getZoom() - 1, position);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/Button.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -14,21 +14,15 @@
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.ZoomIn = OpenLayers.Class(OpenLayers.Control.Button, {
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* {String} The type of <OpenLayers.Control> -- When added to a
|
||||
* <Control.Panel>, 'type' is used by the panel to determine how to
|
||||
* handle our events.
|
||||
*/
|
||||
type: OpenLayers.Control.TYPE_BUTTON,
|
||||
|
||||
/**
|
||||
* Method: trigger
|
||||
*/
|
||||
trigger: function(){
|
||||
this.map.zoomIn();
|
||||
if (this.map) {
|
||||
this.map.zoomIn();
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.ZoomIn"
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/Button.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -14,21 +14,15 @@
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.ZoomOut = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.ZoomOut = OpenLayers.Class(OpenLayers.Control.Button, {
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* {String} The type of <OpenLayers.Control> -- When added to a
|
||||
* <Control.Panel>, 'type' is used by the panel to determine how to
|
||||
* handle our events.
|
||||
*/
|
||||
type: OpenLayers.Control.TYPE_BUTTON,
|
||||
|
||||
/**
|
||||
* Method: trigger
|
||||
*/
|
||||
trigger: function(){
|
||||
this.map.zoomOut();
|
||||
if (this.map) {
|
||||
this.map.zoomOut();
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Control.ZoomOut"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Control.js
|
||||
* @requires OpenLayers/Control/Button.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -16,19 +16,14 @@
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Control>
|
||||
*/
|
||||
OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class(OpenLayers.Control, {
|
||||
OpenLayers.Control.ZoomToMaxExtent = OpenLayers.Class(OpenLayers.Control.Button, {
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* {String} The type of <OpenLayers.Control> -- When added to a
|
||||
* <Control.Panel>, 'type' is used by the panel to determine how to
|
||||
* handle our events.
|
||||
*/
|
||||
type: OpenLayers.Control.TYPE_BUTTON,
|
||||
|
||||
/*
|
||||
* Method: trigger
|
||||
* Do the zoom.
|
||||
*
|
||||
* Called whenever this control is being rendered inside of a panel and a
|
||||
* click occurs on this controls element. Actually zooms to the maximum
|
||||
* extent of this controls map.
|
||||
*/
|
||||
trigger: function() {
|
||||
if (this.map) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -20,6 +20,12 @@ OpenLayers.Event = {
|
||||
* element._eventCacheID
|
||||
*/
|
||||
observers: false,
|
||||
|
||||
/**
|
||||
* Constant: KEY_SPACE
|
||||
* {int}
|
||||
*/
|
||||
KEY_SPACE: 32,
|
||||
|
||||
/**
|
||||
* Constant: KEY_BACKSPACE
|
||||
@ -90,6 +96,34 @@ OpenLayers.Event = {
|
||||
return event.target || event.srcElement;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: isSingleTouch
|
||||
* Determine whether event was caused by a single touch
|
||||
*
|
||||
* Parameters:
|
||||
* event - {Event}
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean}
|
||||
*/
|
||||
isSingleTouch: function(event) {
|
||||
return event.touches && event.touches.length == 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: isMultiTouch
|
||||
* Determine whether event was caused by a multi touch
|
||||
*
|
||||
* Parameters:
|
||||
* event - {Event}
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean}
|
||||
*/
|
||||
isMultiTouch: function(event) {
|
||||
return event.touches && event.touches.length > 1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: isLeftClick
|
||||
* Determine whether event was caused by a left click.
|
||||
@ -127,19 +161,13 @@ OpenLayers.Event = {
|
||||
* Parameters:
|
||||
* event - {Event}
|
||||
* allowDefault - {Boolean} If true, we stop the event chain but
|
||||
* still allow the default browser
|
||||
* behaviour (text selection, radio-button
|
||||
* clicking, etc)
|
||||
* Default false
|
||||
* still allow the default browser behaviour (text selection,
|
||||
* radio-button clicking, etc). Default is false.
|
||||
*/
|
||||
stop: function(event, allowDefault) {
|
||||
|
||||
if (!allowDefault) {
|
||||
if (event.preventDefault) {
|
||||
event.preventDefault();
|
||||
} else {
|
||||
event.returnValue = false;
|
||||
}
|
||||
OpenLayers.Event.preventDefault(event);
|
||||
}
|
||||
|
||||
if (event.stopPropagation) {
|
||||
@ -149,6 +177,22 @@ OpenLayers.Event = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: preventDefault
|
||||
* Cancels the event if it is cancelable, without stopping further
|
||||
* propagation of the event.
|
||||
*
|
||||
* Parameters:
|
||||
* event - {Event}
|
||||
*/
|
||||
preventDefault: function(event) {
|
||||
if (event.preventDefault) {
|
||||
event.preventDefault();
|
||||
} else {
|
||||
event.returnValue = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: findElement
|
||||
*
|
||||
@ -253,11 +297,9 @@ OpenLayers.Event = {
|
||||
if (elementObservers) {
|
||||
for(var i = elementObservers.length-1; i >= 0; i--) {
|
||||
var entry = elementObservers[i];
|
||||
var args = new Array(entry.element,
|
||||
entry.name,
|
||||
entry.observer,
|
||||
entry.useCapture);
|
||||
var removed = OpenLayers.Event.stopObserving.apply(this, args);
|
||||
OpenLayers.Event.stopObserving.apply(this, [
|
||||
entry.element, entry.name, entry.observer, entry.useCapture
|
||||
]);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -348,14 +390,6 @@ OpenLayers.Event = {
|
||||
/* prevent memory leaks in IE */
|
||||
OpenLayers.Event.observe(window, 'unload', OpenLayers.Event.unloadCache, false);
|
||||
|
||||
// FIXME: Remove this in 3.0. In 3.0, Event.stop will no longer be provided
|
||||
// by OpenLayers.
|
||||
if (window.Event) {
|
||||
OpenLayers.Util.applyDefaults(window.Event, OpenLayers.Event);
|
||||
} else {
|
||||
var Event = OpenLayers.Event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Events
|
||||
*/
|
||||
@ -369,7 +403,9 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
"mouseover", "mouseout",
|
||||
"mousedown", "mouseup", "mousemove",
|
||||
"click", "dblclick", "rightclick", "dblrightclick",
|
||||
"resize", "focus", "blur"
|
||||
"resize", "focus", "blur",
|
||||
"touchstart", "touchmove", "touchend",
|
||||
"keydown"
|
||||
],
|
||||
|
||||
/**
|
||||
@ -390,12 +426,6 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
*/
|
||||
element: null,
|
||||
|
||||
/**
|
||||
* Property: eventTypes
|
||||
* {Array(String)} list of support application events
|
||||
*/
|
||||
eventTypes: null,
|
||||
|
||||
/**
|
||||
* Property: eventHandler
|
||||
* {Function} bound event handler attached to elements
|
||||
@ -435,6 +465,77 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* the location of the element in the page changes
|
||||
*/
|
||||
includeXY: false,
|
||||
|
||||
/**
|
||||
* APIProperty: extensions
|
||||
* {Object} Event extensions registered with this instance. Keys are
|
||||
* event types, values are {OpenLayers.Events.*} extension instances or
|
||||
* {Boolean} for events that an instantiated extension provides in
|
||||
* addition to the one it was created for.
|
||||
*
|
||||
* Extensions create an event in addition to browser events, which usually
|
||||
* fires when a sequence of browser events is completed. Extensions are
|
||||
* automatically instantiated when a listener is registered for an event
|
||||
* provided by an extension.
|
||||
*
|
||||
* Extensions are created in the <OpenLayers.Events> namespace using
|
||||
* <OpenLayers.Class>, and named after the event they provide.
|
||||
* The constructor receives the target <OpenLayers.Events> instance as
|
||||
* argument. Extensions that need to capture browser events before they
|
||||
* propagate can register their listeners events using <register>, with
|
||||
* {extension: true} as 4th argument.
|
||||
*
|
||||
* If an extension creates more than one event, an alias for each event
|
||||
* type should be created and reference the same class. The constructor
|
||||
* should set a reference in the target's extensions registry to itself.
|
||||
*
|
||||
* Below is a minimal extension that provides the "foostart" and "fooend"
|
||||
* event types, which replace the native "click" event type if clicked on
|
||||
* an element with the css class "foo":
|
||||
*
|
||||
* (code)
|
||||
* OpenLayers.Events.foostart = OpenLayers.Class({
|
||||
* initialize: function(target) {
|
||||
* this.target = target;
|
||||
* this.target.register("click", this, this.doStuff, {extension: true});
|
||||
* // only required if extension provides more than one event type
|
||||
* this.target.extensions["foostart"] = true;
|
||||
* this.target.extensions["fooend"] = true;
|
||||
* },
|
||||
* destroy: function() {
|
||||
* var target = this.target;
|
||||
* target.unregister("click", this, this.doStuff);
|
||||
* delete this.target;
|
||||
* // only required if extension provides more than one event type
|
||||
* delete target.extensions["foostart"];
|
||||
* delete target.extensions["fooend"];
|
||||
* },
|
||||
* doStuff: function(evt) {
|
||||
* var propagate = true;
|
||||
* if (OpenLayers.Event.element(evt).className === "foo") {
|
||||
* propagate = false;
|
||||
* var target = this.target;
|
||||
* target.triggerEvent("foostart");
|
||||
* window.setTimeout(function() {
|
||||
* target.triggerEvent("fooend");
|
||||
* }, 1000);
|
||||
* }
|
||||
* return propagate;
|
||||
* }
|
||||
* });
|
||||
* // only required if extension provides more than one event type
|
||||
* OpenLayers.Events.fooend = OpenLayers.Events.foostart;
|
||||
* (end)
|
||||
*
|
||||
*/
|
||||
extensions: null,
|
||||
|
||||
/**
|
||||
* Property: extensionCount
|
||||
* {Object} Keys are event types (like in <listeners>), values are the
|
||||
* number of extension listeners for each event type.
|
||||
*/
|
||||
extensionCount: null,
|
||||
|
||||
/**
|
||||
* Method: clearMouseListener
|
||||
@ -449,9 +550,11 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* Construct an OpenLayers.Events object.
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object} The js object to which this Events object is being
|
||||
* added element - {DOMElement} A dom element to respond to browser events
|
||||
* eventTypes - {Array(String)} Array of custom application events
|
||||
* object - {Object} The js object to which this Events object is being added
|
||||
* element - {DOMElement} A dom element to respond to browser events
|
||||
* eventTypes - {Array(String)} Deprecated. Array of custom application
|
||||
* events. A listener may be registered for any named event, regardless
|
||||
* of the values provided here.
|
||||
* fallThrough - {Boolean} Allow events to fall through after these have
|
||||
* been handled?
|
||||
* options - {Object} Options for the events object.
|
||||
@ -461,26 +564,9 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
this.object = object;
|
||||
this.fallThrough = fallThrough;
|
||||
this.listeners = {};
|
||||
|
||||
// keep a bound copy of handleBrowserEvent() so that we can
|
||||
// pass the same function to both Event.observe() and .stopObserving()
|
||||
this.eventHandler = OpenLayers.Function.bindAsEventListener(
|
||||
this.handleBrowserEvent, this
|
||||
);
|
||||
|
||||
// to be used with observe and stopObserving
|
||||
this.clearMouseListener = OpenLayers.Function.bind(
|
||||
this.clearMouseCache, this
|
||||
);
|
||||
|
||||
// if eventTypes is specified, create a listeners list for each
|
||||
// custom application event.
|
||||
this.eventTypes = [];
|
||||
if (eventTypes != null) {
|
||||
for (var i=0, len=eventTypes.length; i<len; i++) {
|
||||
this.addEventType(eventTypes[i]);
|
||||
}
|
||||
}
|
||||
this.extensions = {};
|
||||
this.extensionCount = {};
|
||||
this._msTouches = [];
|
||||
|
||||
// if a dom element is specified, add a listeners list
|
||||
// for browser events on the element and register them
|
||||
@ -493,6 +579,12 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* APIMethod: destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
for (var e in this.extensions) {
|
||||
if (typeof this.extensions[e] !== "boolean") {
|
||||
this.extensions[e].destroy();
|
||||
}
|
||||
}
|
||||
this.extensions = null;
|
||||
if (this.element) {
|
||||
OpenLayers.Event.stopObservingElement(this.element);
|
||||
if(this.element.hasScrollEvent) {
|
||||
@ -505,24 +597,18 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
|
||||
this.listeners = null;
|
||||
this.object = null;
|
||||
this.eventTypes = null;
|
||||
this.fallThrough = null;
|
||||
this.eventHandler = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: addEventType
|
||||
* Add a new event type to this events object.
|
||||
* If the event type has already been added, do nothing.
|
||||
* Deprecated. Any event can be triggered without adding it first.
|
||||
*
|
||||
* Parameters:
|
||||
* eventName - {String}
|
||||
*/
|
||||
addEventType: function(eventName) {
|
||||
if (!this.listeners[eventName]) {
|
||||
this.eventTypes.push(eventName);
|
||||
this.listeners[eventName] = [];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -532,19 +618,31 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* element - {HTMLDOMElement} a DOM element to attach browser events to
|
||||
*/
|
||||
attachToElement: function (element) {
|
||||
if(this.element) {
|
||||
if (this.element) {
|
||||
OpenLayers.Event.stopObservingElement(this.element);
|
||||
} else {
|
||||
// keep a bound copy of handleBrowserEvent() so that we can
|
||||
// pass the same function to both Event.observe() and .stopObserving()
|
||||
this.eventHandler = OpenLayers.Function.bindAsEventListener(
|
||||
this.handleBrowserEvent, this
|
||||
);
|
||||
|
||||
// to be used with observe and stopObserving
|
||||
this.clearMouseListener = OpenLayers.Function.bind(
|
||||
this.clearMouseCache, this
|
||||
);
|
||||
}
|
||||
this.element = element;
|
||||
for (var i=0, len=this.BROWSER_EVENTS.length; i<len; i++) {
|
||||
var eventType = this.BROWSER_EVENTS[i];
|
||||
|
||||
// every browser event has a corresponding application event
|
||||
// (whether it's listened for or not).
|
||||
this.addEventType(eventType);
|
||||
|
||||
// use Prototype to register the event cross-browser
|
||||
OpenLayers.Event.observe(element, eventType, this.eventHandler);
|
||||
var msTouch = !!window.navigator.msMaxTouchPoints;
|
||||
var type;
|
||||
for (var i = 0, len = this.BROWSER_EVENTS.length; i < len; i++) {
|
||||
type = this.BROWSER_EVENTS[i];
|
||||
// register the event cross-browser
|
||||
OpenLayers.Event.observe(element, type, this.eventHandler
|
||||
);
|
||||
if (msTouch && type.indexOf('touch') === 0) {
|
||||
this.addMsTouchListener(element, type, this.eventHandler);
|
||||
}
|
||||
}
|
||||
// disable dragstart in IE so that mousedown/move/up works normally
|
||||
OpenLayers.Event.observe(element, "dragstart", OpenLayers.Event.stop);
|
||||
@ -559,7 +657,7 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* Example use:
|
||||
* (code)
|
||||
* // register a single listener for the "loadstart" event
|
||||
* events.on({"loadstart", loadStartListener});
|
||||
* events.on({"loadstart": loadStartListener});
|
||||
*
|
||||
* // this is equivalent to the following
|
||||
* events.register("loadstart", undefined, loadStartListener);
|
||||
@ -573,12 +671,15 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
*
|
||||
* // this is equivalent to the following
|
||||
* events.register("loadstart", object, loadStartListener);
|
||||
* events.register("loadstart", object, loadEndListener);
|
||||
* events.register("loadend", object, loadEndListener);
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* object - {Object}
|
||||
*/
|
||||
on: function(object) {
|
||||
for(var type in object) {
|
||||
if(type != "scope") {
|
||||
if(type != "scope" && object.hasOwnProperty(type)) {
|
||||
this.register(type, object.scope, object[type]);
|
||||
}
|
||||
}
|
||||
@ -604,23 +705,40 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* Parameters:
|
||||
* type - {String} Name of the event to register
|
||||
* obj - {Object} The object to bind the context to for the callback#.
|
||||
* If no object is specified, default is the Events's
|
||||
* 'object' property.
|
||||
* If no object is specified, default is the Events's 'object' property.
|
||||
* func - {Function} The callback function. If no callback is
|
||||
* specified, this function does nothing.
|
||||
*
|
||||
*
|
||||
* specified, this function does nothing.
|
||||
* priority - {Boolean|Object} If true, adds the new listener to the
|
||||
* *front* of the events queue instead of to the end.
|
||||
*
|
||||
* Valid options for priority:
|
||||
* extension - {Boolean} If true, then the event will be registered as
|
||||
* extension event. Extension events are handled before all other
|
||||
* events.
|
||||
*/
|
||||
register: function (type, obj, func) {
|
||||
|
||||
if ( (func != null) &&
|
||||
(OpenLayers.Util.indexOf(this.eventTypes, type) != -1) ) {
|
||||
|
||||
register: function (type, obj, func, priority) {
|
||||
if (type in OpenLayers.Events && !this.extensions[type]) {
|
||||
this.extensions[type] = new OpenLayers.Events[type](this);
|
||||
}
|
||||
if (func != null) {
|
||||
if (obj == null) {
|
||||
obj = this.object;
|
||||
}
|
||||
var listeners = this.listeners[type];
|
||||
listeners.push( {obj: obj, func: func} );
|
||||
if (!listeners) {
|
||||
listeners = [];
|
||||
this.listeners[type] = listeners;
|
||||
this.extensionCount[type] = 0;
|
||||
}
|
||||
var listener = {obj: obj, func: func};
|
||||
if (priority) {
|
||||
listeners.splice(this.extensionCount[type], 0, listener);
|
||||
if (typeof priority === "object" && priority.extension) {
|
||||
this.extensionCount[type]++;
|
||||
}
|
||||
} else {
|
||||
listeners.push(listener);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -642,16 +760,7 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* specified, this function does nothing.
|
||||
*/
|
||||
registerPriority: function (type, obj, func) {
|
||||
|
||||
if (func != null) {
|
||||
if (obj == null) {
|
||||
obj = this.object;
|
||||
}
|
||||
var listeners = this.listeners[type];
|
||||
if (listeners != null) {
|
||||
listeners.unshift( {obj: obj, func: func} );
|
||||
}
|
||||
}
|
||||
this.register(type, obj, func, true);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -663,7 +772,7 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* Example use:
|
||||
* (code)
|
||||
* // unregister a single listener for the "loadstart" event
|
||||
* events.un({"loadstart", loadStartListener});
|
||||
* events.un({"loadstart": loadStartListener});
|
||||
*
|
||||
* // this is equivalent to the following
|
||||
* events.unregister("loadstart", undefined, loadStartListener);
|
||||
@ -677,12 +786,12 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
*
|
||||
* // this is equivalent to the following
|
||||
* events.unregister("loadstart", object, loadStartListener);
|
||||
* events.unregister("loadstart", object, loadEndListener);
|
||||
* events.unregister("loadend", object, loadEndListener);
|
||||
* (end)
|
||||
*/
|
||||
un: function(object) {
|
||||
for(var type in object) {
|
||||
if(type != "scope") {
|
||||
if(type != "scope" && object.hasOwnProperty(type)) {
|
||||
this.unregister(type, object.scope, object[type]);
|
||||
}
|
||||
}
|
||||
@ -731,7 +840,7 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
*
|
||||
* Parameters:
|
||||
* type - {String}
|
||||
* evt - {Event}
|
||||
* evt - {Event || Object} will be passed to the listeners.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The last listener return. If a listener returns false, the
|
||||
@ -742,7 +851,7 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
|
||||
// fast path
|
||||
if(!listeners || listeners.length == 0) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// prep evt object with object & div references
|
||||
@ -758,7 +867,8 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
// execute all callbacks registered for specified type
|
||||
// get a clone of the listeners array to
|
||||
// allow for splicing during callbacks
|
||||
var listeners = listeners.slice(), continueChain;
|
||||
listeners = listeners.slice();
|
||||
var continueChain;
|
||||
for (var i=0, len=listeners.length; i<len; i++) {
|
||||
var callback = listeners[i];
|
||||
// bind the context to callback.obj
|
||||
@ -786,12 +896,73 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
* evt - {Event}
|
||||
*/
|
||||
handleBrowserEvent: function (evt) {
|
||||
var type = evt.type, listeners = this.listeners[type];
|
||||
if(!listeners || listeners.length == 0) {
|
||||
// noone's listening, bail out
|
||||
return;
|
||||
}
|
||||
// add clientX & clientY to all events - corresponds to average x, y
|
||||
var touches = evt.touches;
|
||||
if (touches && touches[0]) {
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var num = touches.length;
|
||||
var touch;
|
||||
for (var i=0; i<num; ++i) {
|
||||
touch = this.getTouchClientXY(touches[i]);
|
||||
x += touch.clientX;
|
||||
y += touch.clientY;
|
||||
}
|
||||
evt.clientX = x / num;
|
||||
evt.clientY = y / num;
|
||||
}
|
||||
if (this.includeXY) {
|
||||
evt.xy = this.getMousePosition(evt);
|
||||
}
|
||||
this.triggerEvent(evt.type, evt);
|
||||
this.triggerEvent(type, evt);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: getTouchClientXY
|
||||
* WebKit has a few bugs for clientX/clientY. This method detects them
|
||||
* and calculate the correct values.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Touch} a Touch object from a TouchEvent
|
||||
*
|
||||
* Returns:
|
||||
* {Object} An object with only clientX and clientY properties with the
|
||||
* calculated values.
|
||||
*/
|
||||
getTouchClientXY: function (evt) {
|
||||
// olMochWin is to override window, used for testing
|
||||
var win = window.olMockWin || window,
|
||||
winPageX = win.pageXOffset,
|
||||
winPageY = win.pageYOffset,
|
||||
x = evt.clientX,
|
||||
y = evt.clientY;
|
||||
|
||||
if (evt.pageY === 0 && Math.floor(y) > Math.floor(evt.pageY) ||
|
||||
evt.pageX === 0 && Math.floor(x) > Math.floor(evt.pageX)) {
|
||||
// iOS4 include scroll offset in clientX/Y
|
||||
x = x - winPageX;
|
||||
y = y - winPageY;
|
||||
} else if (y < (evt.pageY - winPageY) || x < (evt.pageX - winPageX) ) {
|
||||
// Some Android browsers have totally bogus values for clientX/Y
|
||||
// when scrolling/zooming a page
|
||||
x = evt.pageX - winPageX;
|
||||
y = evt.pageY - winPageY;
|
||||
}
|
||||
|
||||
evt.olClientX = x;
|
||||
evt.olClientY = y;
|
||||
|
||||
return {
|
||||
clientX: x,
|
||||
clientY: y
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: clearMouseCache
|
||||
* Clear cached data about the mouse position. This should be called any
|
||||
@ -823,11 +994,10 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
}
|
||||
|
||||
if (!this.element.scrolls) {
|
||||
var viewportElement = OpenLayers.Util.getViewportElement();
|
||||
this.element.scrolls = [
|
||||
(document.documentElement.scrollLeft
|
||||
|| document.body.scrollLeft),
|
||||
(document.documentElement.scrollTop
|
||||
|| document.body.scrollTop)
|
||||
window.pageXOffset || viewportElement.scrollLeft,
|
||||
window.pageYOffset || viewportElement.scrollTop
|
||||
];
|
||||
}
|
||||
|
||||
@ -840,9 +1010,8 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
|
||||
if (!this.element.offsets) {
|
||||
this.element.offsets = OpenLayers.Util.pagePosition(this.element);
|
||||
this.element.offsets[0] += this.element.scrolls[0];
|
||||
this.element.offsets[1] += this.element.scrolls[1];
|
||||
}
|
||||
|
||||
return new OpenLayers.Pixel(
|
||||
(evt.clientX + this.element.scrolls[0]) - this.element.offsets[0]
|
||||
- this.element.lefttop[0],
|
||||
@ -851,5 +1020,151 @@ OpenLayers.Events = OpenLayers.Class({
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addMsTouchListener
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} The DOM element to register the listener on
|
||||
* type - {String} The event type
|
||||
* handler - {Function} the handler
|
||||
*/
|
||||
addMsTouchListener: function (element, type, handler) {
|
||||
var eventHandler = this.eventHandler;
|
||||
var touches = this._msTouches;
|
||||
|
||||
function msHandler(evt) {
|
||||
handler(OpenLayers.Util.applyDefaults({
|
||||
stopPropagation: function() {
|
||||
for (var i=touches.length-1; i>=0; --i) {
|
||||
touches[i].stopPropagation();
|
||||
}
|
||||
},
|
||||
preventDefault: function() {
|
||||
for (var i=touches.length-1; i>=0; --i) {
|
||||
touches[i].preventDefault();
|
||||
}
|
||||
},
|
||||
type: type
|
||||
}, evt));
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'touchstart':
|
||||
return this.addMsTouchListenerStart(element, type, msHandler);
|
||||
case 'touchend':
|
||||
return this.addMsTouchListenerEnd(element, type, msHandler);
|
||||
case 'touchmove':
|
||||
return this.addMsTouchListenerMove(element, type, msHandler);
|
||||
default:
|
||||
throw 'Unknown touch event type';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addMsTouchListenerStart
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} The DOM element to register the listener on
|
||||
* type - {String} The event type
|
||||
* handler - {Function} the handler
|
||||
*/
|
||||
addMsTouchListenerStart: function(element, type, handler) {
|
||||
var touches = this._msTouches;
|
||||
|
||||
var cb = function(e) {
|
||||
|
||||
var alreadyInArray = false;
|
||||
for (var i=0, ii=touches.length; i<ii; ++i) {
|
||||
if (touches[i].pointerId == e.pointerId) {
|
||||
alreadyInArray = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyInArray) {
|
||||
touches.push(e);
|
||||
}
|
||||
|
||||
e.touches = touches.slice();
|
||||
handler(e);
|
||||
};
|
||||
|
||||
OpenLayers.Event.observe(element, 'MSPointerDown', cb);
|
||||
|
||||
// Need to also listen for end events to keep the _msTouches list
|
||||
// accurate
|
||||
var internalCb = function(e) {
|
||||
for (var i=0, ii=touches.length; i<ii; ++i) {
|
||||
if (touches[i].pointerId == e.pointerId) {
|
||||
touches.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
OpenLayers.Event.observe(element, 'MSPointerUp', internalCb);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addMsTouchListenerMove
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} The DOM element to register the listener on
|
||||
* type - {String} The event type
|
||||
* handler - {Function} the handler
|
||||
*/
|
||||
addMsTouchListenerMove: function (element, type, handler) {
|
||||
var touches = this._msTouches;
|
||||
var cb = function(e) {
|
||||
|
||||
//Don't fire touch moves when mouse isn't down
|
||||
if (e.pointerType == e.MSPOINTER_TYPE_MOUSE && e.buttons == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (touches.length == 1 && touches[0].pageX == e.pageX &&
|
||||
touches[0].pageY == e.pageY) {
|
||||
// don't trigger event when pointer has not moved
|
||||
return;
|
||||
}
|
||||
for (var i=0, ii=touches.length; i<ii; ++i) {
|
||||
if (touches[i].pointerId == e.pointerId) {
|
||||
touches[i] = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
e.touches = touches.slice();
|
||||
handler(e);
|
||||
};
|
||||
|
||||
OpenLayers.Event.observe(element, 'MSPointerMove', cb);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addMsTouchListenerEnd
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} The DOM element to register the listener on
|
||||
* type - {String} The event type
|
||||
* handler - {Function} the handler
|
||||
*/
|
||||
addMsTouchListenerEnd: function (element, type, handler) {
|
||||
var touches = this._msTouches;
|
||||
|
||||
var cb = function(e) {
|
||||
|
||||
for (var i=0, ii=touches.length; i<ii; ++i) {
|
||||
if (touches[i].pointerId == e.pointerId) {
|
||||
touches.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
e.touches = touches.slice();
|
||||
handler(e);
|
||||
};
|
||||
|
||||
OpenLayers.Event.observe(element, 'MSPointerUp', cb);
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Events"
|
||||
});
|
||||
|
||||
@ -0,0 +1,206 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Events.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Events.buttonclick
|
||||
* Extension event type for handling buttons on top of a dom element. This
|
||||
* event type fires "buttonclick" on its <target> when a button was
|
||||
* clicked. Buttons are detected by the "olButton" class.
|
||||
*
|
||||
* This event type makes sure that button clicks do not interfere with other
|
||||
* events that are registered on the same <element>.
|
||||
*
|
||||
* Event types provided by this extension:
|
||||
* - *buttonclick* Triggered when a button is clicked. Listeners receive an
|
||||
* object with a *buttonElement* property referencing the dom element of
|
||||
* the clicked button, and an *buttonXY* property with the click position
|
||||
* relative to the button.
|
||||
*/
|
||||
OpenLayers.Events.buttonclick = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Property: target
|
||||
* {<OpenLayers.Events>} The events instance that the buttonclick event will
|
||||
* be triggered on.
|
||||
*/
|
||||
target: null,
|
||||
|
||||
/**
|
||||
* Property: events
|
||||
* {Array} Events to observe and conditionally stop from propagating when
|
||||
* an element with the olButton class (or its olAlphaImg child) is
|
||||
* clicked.
|
||||
*/
|
||||
events: [
|
||||
'mousedown', 'mouseup', 'click', 'dblclick',
|
||||
'touchstart', 'touchmove', 'touchend', 'keydown'
|
||||
],
|
||||
|
||||
/**
|
||||
* Property: startRegEx
|
||||
* {RegExp} Regular expression to test Event.type for events that start
|
||||
* a buttonclick sequence.
|
||||
*/
|
||||
startRegEx: /^mousedown|touchstart$/,
|
||||
|
||||
/**
|
||||
* Property: cancelRegEx
|
||||
* {RegExp} Regular expression to test Event.type for events that cancel
|
||||
* a buttonclick sequence.
|
||||
*/
|
||||
cancelRegEx: /^touchmove$/,
|
||||
|
||||
/**
|
||||
* Property: completeRegEx
|
||||
* {RegExp} Regular expression to test Event.type for events that complete
|
||||
* a buttonclick sequence.
|
||||
*/
|
||||
completeRegEx: /^mouseup|touchend$/,
|
||||
|
||||
/**
|
||||
* Property: startEvt
|
||||
* {Event} The event that started the click sequence
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Events.buttonclick
|
||||
* Construct a buttonclick event type. Applications are not supposed to
|
||||
* create instances of this class - they are created on demand by
|
||||
* <OpenLayers.Events> instances.
|
||||
*
|
||||
* Parameters:
|
||||
* target - {<OpenLayers.Events>} The events instance that the buttonclick
|
||||
* event will be triggered on.
|
||||
*/
|
||||
initialize: function(target) {
|
||||
this.target = target;
|
||||
for (var i=this.events.length-1; i>=0; --i) {
|
||||
this.target.register(this.events[i], this, this.buttonClick, {
|
||||
extension: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
*/
|
||||
destroy: function() {
|
||||
for (var i=this.events.length-1; i>=0; --i) {
|
||||
this.target.unregister(this.events[i], this, this.buttonClick);
|
||||
}
|
||||
delete this.target;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getPressedButton
|
||||
* Get the pressed button, if any. Returns undefined if no button
|
||||
* was pressed.
|
||||
*
|
||||
* Arguments:
|
||||
* element - {DOMElement} The event target.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} The button element, or undefined.
|
||||
*/
|
||||
getPressedButton: function(element) {
|
||||
var depth = 3, // limit the search depth
|
||||
button;
|
||||
do {
|
||||
if(OpenLayers.Element.hasClass(element, "olButton")) {
|
||||
// hit!
|
||||
button = element;
|
||||
break;
|
||||
}
|
||||
element = element.parentNode;
|
||||
} while(--depth > 0 && element);
|
||||
return button;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: ignore
|
||||
* Check for event target elements that should be ignored by OpenLayers.
|
||||
*
|
||||
* Parameters:
|
||||
* element - {DOMElement} The event target.
|
||||
*/
|
||||
ignore: function(element) {
|
||||
var depth = 3,
|
||||
ignore = false;
|
||||
do {
|
||||
if (element.nodeName.toLowerCase() === 'a') {
|
||||
ignore = true;
|
||||
break;
|
||||
}
|
||||
element = element.parentNode;
|
||||
} while (--depth > 0 && element);
|
||||
return ignore;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: buttonClick
|
||||
* Check if a button was clicked, and fire the buttonclick event
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Event}
|
||||
*/
|
||||
buttonClick: function(evt) {
|
||||
var propagate = true,
|
||||
element = OpenLayers.Event.element(evt);
|
||||
if (element && (OpenLayers.Event.isLeftClick(evt) || !~evt.type.indexOf("mouse"))) {
|
||||
// was a button pressed?
|
||||
var button = this.getPressedButton(element);
|
||||
if (button) {
|
||||
if (evt.type === "keydown") {
|
||||
switch (evt.keyCode) {
|
||||
case OpenLayers.Event.KEY_RETURN:
|
||||
case OpenLayers.Event.KEY_SPACE:
|
||||
this.target.triggerEvent("buttonclick", {
|
||||
buttonElement: button
|
||||
});
|
||||
OpenLayers.Event.stop(evt);
|
||||
propagate = false;
|
||||
break;
|
||||
}
|
||||
} else if (this.startEvt) {
|
||||
if (this.completeRegEx.test(evt.type)) {
|
||||
var pos = OpenLayers.Util.pagePosition(button);
|
||||
var viewportElement = OpenLayers.Util.getViewportElement();
|
||||
var scrollTop = window.pageYOffset || viewportElement.scrollTop;
|
||||
var scrollLeft = window.pageXOffset || viewportElement.scrollLeft;
|
||||
pos[0] = pos[0] - scrollLeft;
|
||||
pos[1] = pos[1] - scrollTop;
|
||||
|
||||
this.target.triggerEvent("buttonclick", {
|
||||
buttonElement: button,
|
||||
buttonXY: {
|
||||
x: this.startEvt.clientX - pos[0],
|
||||
y: this.startEvt.clientY - pos[1]
|
||||
}
|
||||
});
|
||||
}
|
||||
if (this.cancelRegEx.test(evt.type)) {
|
||||
delete this.startEvt;
|
||||
}
|
||||
OpenLayers.Event.stop(evt);
|
||||
propagate = false;
|
||||
}
|
||||
if (this.startRegEx.test(evt.type)) {
|
||||
this.startEvt = evt;
|
||||
OpenLayers.Event.stop(evt);
|
||||
propagate = false;
|
||||
}
|
||||
} else {
|
||||
propagate = !this.ignore(OpenLayers.Event.element(evt));
|
||||
delete this.startEvt;
|
||||
}
|
||||
}
|
||||
return propagate;
|
||||
}
|
||||
|
||||
});
|
||||
@ -0,0 +1,321 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Events.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Events.featureclick
|
||||
*
|
||||
* Extension event type for handling feature click events, including overlapping
|
||||
* features.
|
||||
*
|
||||
* Event types provided by this extension:
|
||||
* - featureclick
|
||||
*/
|
||||
OpenLayers.Events.featureclick = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Property: cache
|
||||
* {Object} A cache of features under the mouse.
|
||||
*/
|
||||
cache: null,
|
||||
|
||||
/**
|
||||
* Property: map
|
||||
* {<OpenLayers.Map>} The map to register browser events on.
|
||||
*/
|
||||
map: null,
|
||||
|
||||
/**
|
||||
* Property: provides
|
||||
* {Array(String)} The event types provided by this extension.
|
||||
*/
|
||||
provides: ["featureclick", "nofeatureclick", "featureover", "featureout"],
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Events.featureclick
|
||||
* Create a new featureclick event type.
|
||||
*
|
||||
* Parameters:
|
||||
* target - {<OpenLayers.Events>} The events instance to create the events
|
||||
* for.
|
||||
*/
|
||||
initialize: function(target) {
|
||||
this.target = target;
|
||||
if (target.object instanceof OpenLayers.Map) {
|
||||
this.setMap(target.object);
|
||||
} else if (target.object instanceof OpenLayers.Layer.Vector) {
|
||||
if (target.object.map) {
|
||||
this.setMap(target.object.map);
|
||||
} else {
|
||||
target.object.events.register("added", this, function(evt) {
|
||||
this.setMap(target.object.map);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw("Listeners for '" + this.provides.join("', '") +
|
||||
"' events can only be registered for OpenLayers.Layer.Vector " +
|
||||
"or OpenLayers.Map instances");
|
||||
}
|
||||
for (var i=this.provides.length-1; i>=0; --i) {
|
||||
target.extensions[this.provides[i]] = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: setMap
|
||||
*
|
||||
* Parameters:
|
||||
* map - {<OpenLayers.Map>} The map to register browser events on.
|
||||
*/
|
||||
setMap: function(map) {
|
||||
this.map = map;
|
||||
this.cache = {};
|
||||
map.events.register("mousedown", this, this.start, {extension: true});
|
||||
map.events.register("mouseup", this, this.onClick, {extension: true});
|
||||
map.events.register("touchstart", this, this.start, {extension: true});
|
||||
map.events.register("touchmove", this, this.cancel, {extension: true});
|
||||
map.events.register("touchend", this, this.onClick, {extension: true});
|
||||
map.events.register("mousemove", this, this.onMousemove, {extension: true});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: start
|
||||
* Sets startEvt = evt.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
start: function(evt) {
|
||||
this.startEvt = evt;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: cancel
|
||||
* Deletes the start event.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
cancel: function(evt) {
|
||||
delete this.startEvt;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onClick
|
||||
* Listener for the click event.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
onClick: function(evt) {
|
||||
if (!this.startEvt || evt.type !== "touchend" &&
|
||||
!OpenLayers.Event.isLeftClick(evt)) {
|
||||
return;
|
||||
}
|
||||
var features = this.getFeatures(this.startEvt);
|
||||
delete this.startEvt;
|
||||
// fire featureclick events
|
||||
var feature, layer, more, clicked = {};
|
||||
for (var i=0, len=features.length; i<len; ++i) {
|
||||
feature = features[i];
|
||||
layer = feature.layer;
|
||||
clicked[layer.id] = true;
|
||||
more = this.triggerEvent("featureclick", {feature: feature});
|
||||
if (more === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// fire nofeatureclick events on all vector layers with no targets
|
||||
for (i=0, len=this.map.layers.length; i<len; ++i) {
|
||||
layer = this.map.layers[i];
|
||||
if (layer instanceof OpenLayers.Layer.Vector && !clicked[layer.id]) {
|
||||
this.triggerEvent("nofeatureclick", {layer: layer});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onMousemove
|
||||
* Listener for the mousemove event.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {<OpenLayers.Event>}
|
||||
*/
|
||||
onMousemove: function(evt) {
|
||||
delete this.startEvt;
|
||||
var features = this.getFeatures(evt);
|
||||
var over = {}, newly = [], feature;
|
||||
for (var i=0, len=features.length; i<len; ++i) {
|
||||
feature = features[i];
|
||||
over[feature.id] = feature;
|
||||
if (!this.cache[feature.id]) {
|
||||
newly.push(feature);
|
||||
}
|
||||
}
|
||||
// check if already over features
|
||||
var out = [];
|
||||
for (var id in this.cache) {
|
||||
feature = this.cache[id];
|
||||
if (feature.layer && feature.layer.map) {
|
||||
if (!over[feature.id]) {
|
||||
out.push(feature);
|
||||
}
|
||||
} else {
|
||||
// removed
|
||||
delete this.cache[id];
|
||||
}
|
||||
}
|
||||
// fire featureover events
|
||||
var more;
|
||||
for (i=0, len=newly.length; i<len; ++i) {
|
||||
feature = newly[i];
|
||||
this.cache[feature.id] = feature;
|
||||
more = this.triggerEvent("featureover", {feature: feature});
|
||||
if (more === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// fire featureout events
|
||||
for (i=0, len=out.length; i<len; ++i) {
|
||||
feature = out[i];
|
||||
delete this.cache[feature.id];
|
||||
more = this.triggerEvent("featureout", {feature: feature});
|
||||
if (more === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: triggerEvent
|
||||
* Determines where to trigger the event and triggers it.
|
||||
*
|
||||
* Parameters:
|
||||
* type - {String} The event type to trigger
|
||||
* evt - {Object} The listener argument
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} The last listener return.
|
||||
*/
|
||||
triggerEvent: function(type, evt) {
|
||||
var layer = evt.feature ? evt.feature.layer : evt.layer,
|
||||
object = this.target.object;
|
||||
if (object instanceof OpenLayers.Map || object === layer) {
|
||||
return this.target.triggerEvent(type, evt);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: getFeatures
|
||||
* Get all features at the given screen location.
|
||||
*
|
||||
* Parameters:
|
||||
* evt - {Object} Event object.
|
||||
*
|
||||
* Returns:
|
||||
* {Array(<OpenLayers.Feature.Vector>)} List of features at the given point.
|
||||
*/
|
||||
getFeatures: function(evt) {
|
||||
var x = evt.clientX, y = evt.clientY,
|
||||
features = [], targets = [], layers = [],
|
||||
layer, target, feature, i, len;
|
||||
// go through all layers looking for targets
|
||||
for (i=this.map.layers.length-1; i>=0; --i) {
|
||||
layer = this.map.layers[i];
|
||||
if (layer.div.style.display !== "none") {
|
||||
if (layer.renderer instanceof OpenLayers.Renderer.Elements) {
|
||||
if (layer instanceof OpenLayers.Layer.Vector) {
|
||||
target = document.elementFromPoint(x, y);
|
||||
while (target && target._featureId) {
|
||||
feature = layer.getFeatureById(target._featureId);
|
||||
if (feature) {
|
||||
features.push(feature);
|
||||
target.style.display = "none";
|
||||
targets.push(target);
|
||||
target = document.elementFromPoint(x, y);
|
||||
} else {
|
||||
// sketch, all bets off
|
||||
target = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
layers.push(layer);
|
||||
layer.div.style.display = "none";
|
||||
} else if (layer.renderer instanceof OpenLayers.Renderer.Canvas) {
|
||||
feature = layer.renderer.getFeatureIdFromEvent(evt);
|
||||
if (feature) {
|
||||
features.push(feature);
|
||||
layers.push(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// restore feature visibility
|
||||
for (i=0, len=targets.length; i<len; ++i) {
|
||||
targets[i].style.display = "";
|
||||
}
|
||||
// restore layer visibility
|
||||
for (i=layers.length-1; i>=0; --i) {
|
||||
layers[i].div.style.display = "block";
|
||||
}
|
||||
return features;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: destroy
|
||||
* Clean up.
|
||||
*/
|
||||
destroy: function() {
|
||||
for (var i=this.provides.length-1; i>=0; --i) {
|
||||
delete this.target.extensions[this.provides[i]];
|
||||
}
|
||||
this.map.events.un({
|
||||
mousemove: this.onMousemove,
|
||||
mousedown: this.start,
|
||||
mouseup: this.onClick,
|
||||
touchstart: this.start,
|
||||
touchmove: this.cancel,
|
||||
touchend: this.onClick,
|
||||
scope: this
|
||||
});
|
||||
delete this.cache;
|
||||
delete this.map;
|
||||
delete this.target;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Events.nofeatureclick
|
||||
*
|
||||
* Extension event type for handling click events that do not hit a feature.
|
||||
*
|
||||
* Event types provided by this extension:
|
||||
* - nofeatureclick
|
||||
*/
|
||||
OpenLayers.Events.nofeatureclick = OpenLayers.Events.featureclick;
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Events.featureover
|
||||
*
|
||||
* Extension event type for handling hovering over a feature.
|
||||
*
|
||||
* Event types provided by this extension:
|
||||
* - featureover
|
||||
*/
|
||||
OpenLayers.Events.featureover = OpenLayers.Events.featureclick;
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Events.featureout
|
||||
*
|
||||
* Extension event type for handling leaving a feature.
|
||||
*
|
||||
* Event types provided by this extension:
|
||||
* - featureout
|
||||
*/
|
||||
OpenLayers.Events.featureout = OpenLayers.Events.featureclick;
|
||||
@ -1,13 +1,12 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/Marker.js
|
||||
* @requires OpenLayers/Popup/AnchoredBubble.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -50,9 +49,9 @@ OpenLayers.Feature = OpenLayers.Class({
|
||||
/**
|
||||
* APIProperty: popupClass
|
||||
* {<OpenLayers.Class>} The class which will be used to instantiate
|
||||
* a new Popup. Default is <OpenLayers.Popup.AnchoredBubble>.
|
||||
* a new Popup. Default is <OpenLayers.Popup.Anchored>.
|
||||
*/
|
||||
popupClass: OpenLayers.Popup.AnchoredBubble,
|
||||
popupClass: null,
|
||||
|
||||
/**
|
||||
* Property: popup
|
||||
@ -186,17 +185,16 @@ OpenLayers.Feature = OpenLayers.Class({
|
||||
createPopup: function(closeBox) {
|
||||
|
||||
if (this.lonlat != null) {
|
||||
|
||||
var id = this.id + "_popup";
|
||||
var anchor = (this.marker) ? this.marker.icon : null;
|
||||
|
||||
if (!this.popup) {
|
||||
this.popup = new this.popupClass(id,
|
||||
this.lonlat,
|
||||
this.data.popupSize,
|
||||
this.data.popupContentHTML,
|
||||
anchor,
|
||||
closeBox);
|
||||
var anchor = (this.marker) ? this.marker.icon : null;
|
||||
var popupClass = this.popupClass ?
|
||||
this.popupClass : OpenLayers.Popup.Anchored;
|
||||
this.popup = new popupClass(this.id + "_popup",
|
||||
this.lonlat,
|
||||
this.data.popupSize,
|
||||
this.data.popupContentHTML,
|
||||
anchor,
|
||||
closeBox);
|
||||
}
|
||||
if (this.data.overflow != null) {
|
||||
this.popup.contentDiv.style.overflow = this.data.overflow;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
// TRASH THIS
|
||||
@ -81,6 +81,42 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* {String} rendering intent currently being used
|
||||
*/
|
||||
renderIntent: "default",
|
||||
|
||||
/**
|
||||
* APIProperty: modified
|
||||
* {Object} An object with the originals of the geometry and attributes of
|
||||
* the feature, if they were changed. Currently this property is only read
|
||||
* by <OpenLayers.Format.WFST.v1>, and written by
|
||||
* <OpenLayers.Control.ModifyFeature>, which sets the geometry property.
|
||||
* Applications can set the originals of modified attributes in the
|
||||
* attributes property. Note that applications have to check if this
|
||||
* object and the attributes property is already created before using it.
|
||||
* After a change made with ModifyFeature, this object could look like
|
||||
*
|
||||
* (code)
|
||||
* {
|
||||
* geometry: >Object
|
||||
* }
|
||||
* (end)
|
||||
*
|
||||
* When an application has made changes to feature attributes, it could
|
||||
* have set the attributes to something like this:
|
||||
*
|
||||
* (code)
|
||||
* {
|
||||
* attributes: {
|
||||
* myAttribute: "original"
|
||||
* }
|
||||
* }
|
||||
* (end)
|
||||
*
|
||||
* Note that <OpenLayers.Format.WFST.v1> only checks for truthy values in
|
||||
* *modified.geometry* and the attribute names in *modified.attributes*,
|
||||
* but it is recommended to set the original values (and not just true) as
|
||||
* attribute value, so applications could use this information to undo
|
||||
* changes.
|
||||
*/
|
||||
modified: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Feature.Vector
|
||||
@ -118,6 +154,7 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
}
|
||||
|
||||
this.geometry = null;
|
||||
this.modified = null;
|
||||
OpenLayers.Feature.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
@ -230,7 +267,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* Determins whether the feature intersects with the specified location.
|
||||
*
|
||||
* Parameters:
|
||||
* lonlat - {<OpenLayers.LonLat>}
|
||||
* lonlat - {<OpenLayers.LonLat>|Object} OpenLayers.LonLat or an
|
||||
* object with a 'lon' and 'lat' properties.
|
||||
* toleranceLon - {float} Optional tolerance in Geometric Coords
|
||||
* toleranceLat - {float} Optional tolerance in Geographic Coords
|
||||
*
|
||||
@ -260,14 +298,14 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* Moves the feature and redraws it at its new location
|
||||
*
|
||||
* Parameters:
|
||||
* state - {OpenLayers.LonLat or OpenLayers.Pixel} the
|
||||
* location - {<OpenLayers.LonLat> or <OpenLayers.Pixel>} the
|
||||
* location to which to move the feature.
|
||||
*/
|
||||
move: function(location) {
|
||||
|
||||
if(!this.layer || !this.geometry.move){
|
||||
//do nothing if no layer or immoveable geometry
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var pixel;
|
||||
@ -365,7 +403,8 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* graphicZIndex - {Number} The integer z-index value to use in rendering.
|
||||
* graphicName - {String} Named graphic to use when rendering points. Supported values include "circle" (default),
|
||||
* "square", "star", "x", "cross", "triangle".
|
||||
* graphicTitle - {String} Tooltip for an external graphic. Only supported in Firefox and Internet Explorer.
|
||||
* graphicTitle - {String} Tooltip when hovering over a feature. *deprecated*, use title instead
|
||||
* title - {String} Tooltip when hovering over a feature. Not supported by the canvas renderer.
|
||||
* backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.
|
||||
* backgroundGraphicZIndex - {Number} The integer z-index value to use in rendering the background graphic.
|
||||
* backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.
|
||||
@ -377,16 +416,19 @@ OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {
|
||||
* labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string
|
||||
* composed of two characters. The first character is for the horizontal alignment, the second for the vertical
|
||||
* alignment. Valid values for horizontal alignment: "l"=left, "c"=center, "r"=right. Valid values for vertical
|
||||
* alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb". The canvas renderer does not
|
||||
* support vertical alignment, it will always use "b".
|
||||
* labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label.
|
||||
* labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label.
|
||||
* alignment: "t"=top, "m"=middle, "b"=bottom. Example values: "lt", "cm", "rb". Default is "cm".
|
||||
* labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer.
|
||||
* labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.
|
||||
* labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.
|
||||
* Default is false.
|
||||
* labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.
|
||||
* labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the SVG renderers.
|
||||
* labelOutlineOpacity - {Number} The opacity (0-1) of the label outline. Default is fontOpacity. Only supported by the canvas & SVG renderers.
|
||||
* fontColor - {String} The font color for the label, to be provided like CSS.
|
||||
* fontOpacity - {Number} Opacity (0-1) for the label
|
||||
* fontFamily - {String} The font family for the label, to be provided like in CSS.
|
||||
* fontSize - {String} The font size for the label, to be provided like in CSS.
|
||||
* fontStyle - {String} The font style for the label, to be provided like in CSS.
|
||||
* fontWeight - {String} The font weight for the label, to be provided like in CSS.
|
||||
* display - {String} Symbolizers will have no effect if display is set to "none". All other values have no effect.
|
||||
*/
|
||||
@ -408,7 +450,11 @@ OpenLayers.Feature.Vector.style = {
|
||||
hoverPointRadius: 1,
|
||||
hoverPointUnit: "%",
|
||||
pointerEvents: "visiblePainted",
|
||||
cursor: "inherit"
|
||||
cursor: "inherit",
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm",
|
||||
labelOutlineColor: "white",
|
||||
labelOutlineWidth: 3
|
||||
},
|
||||
'select': {
|
||||
fillColor: "blue",
|
||||
@ -427,7 +473,12 @@ OpenLayers.Feature.Vector.style = {
|
||||
hoverPointRadius: 1,
|
||||
hoverPointUnit: "%",
|
||||
pointerEvents: "visiblePainted",
|
||||
cursor: "pointer"
|
||||
cursor: "pointer",
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm",
|
||||
labelOutlineColor: "white",
|
||||
labelOutlineWidth: 3
|
||||
|
||||
},
|
||||
'temporary': {
|
||||
fillColor: "#66cccc",
|
||||
@ -446,7 +497,12 @@ OpenLayers.Feature.Vector.style = {
|
||||
hoverPointRadius: 1,
|
||||
hoverPointUnit: "%",
|
||||
pointerEvents: "visiblePainted",
|
||||
cursor: "inherit"
|
||||
cursor: "inherit",
|
||||
fontColor: "#000000",
|
||||
labelAlign: "cm",
|
||||
labelOutlineColor: "white",
|
||||
labelOutlineWidth: 3
|
||||
|
||||
},
|
||||
'delete': {
|
||||
display: "none"
|
||||
|
||||
@ -1,80 +0,0 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Feature.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Feature.WFS
|
||||
* WFS handling class, for use as a featureClass on the WFS layer for handling
|
||||
* 'point' WFS types. Good for subclassing when creating a custom WFS like
|
||||
* XML application.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Feature>
|
||||
*/
|
||||
OpenLayers.Feature.WFS = OpenLayers.Class(OpenLayers.Feature, {
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Feature.WFS
|
||||
* Create a WFS feature.
|
||||
*
|
||||
* Parameters:
|
||||
* layer - {<OpenLayers.Layer>}
|
||||
* xmlNode - {XMLNode}
|
||||
*/
|
||||
initialize: function(layer, xmlNode) {
|
||||
var newArguments = arguments;
|
||||
var data = this.processXMLNode(xmlNode);
|
||||
newArguments = new Array(layer, data.lonlat, data);
|
||||
OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
|
||||
this.createMarker();
|
||||
this.layer.addMarker(this.marker);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: destroy
|
||||
* nullify references to prevent circular references and memory leaks
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.marker != null) {
|
||||
this.layer.removeMarker(this.marker);
|
||||
}
|
||||
OpenLayers.Feature.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: processXMLNode
|
||||
* When passed an xmlNode, parses it for a GML point, and passes
|
||||
* back an object describing that point.
|
||||
*
|
||||
* For subclasses of Feature.WFS, this is the feature to change.
|
||||
*
|
||||
* Parameters:
|
||||
* xmlNode - {XMLNode}
|
||||
*
|
||||
* Returns:
|
||||
* {Object} Data Object with 'id', 'lonlat', and private properties set
|
||||
*/
|
||||
processXMLNode: function(xmlNode) {
|
||||
//this should be overridden by subclasses
|
||||
// must return an Object with 'id' and 'lonlat' values set
|
||||
var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, "http://www.opengis.net/gml", "gml", "Point");
|
||||
var text = OpenLayers.Util.getXmlNodeValue(OpenLayers.Ajax.getElementsByTagNameNS(point[0], "http://www.opengis.net/gml","gml", "coordinates")[0]);
|
||||
var floats = text.split(",");
|
||||
return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
|
||||
parseFloat(floats[1])),
|
||||
id: null};
|
||||
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Feature.WFS"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/Style.js
|
||||
*/
|
||||
@ -17,7 +18,7 @@ OpenLayers.Filter = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Filter
|
||||
* This is an abstract class. Create an instance of a filter subclass.
|
||||
* This class represents a generic filter.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} Optional object whose properties will be set on the
|
||||
@ -39,8 +40,8 @@ OpenLayers.Filter = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: evaluate
|
||||
* Evaluates this filter in a specific context. Should be implemented by
|
||||
* subclasses.
|
||||
* Evaluates this filter in a specific context. Instances or subclasses
|
||||
* are supposed to override this method.
|
||||
*
|
||||
* Parameters:
|
||||
* context - {Object} Context to use in evaluating the filter. If a vector
|
||||
@ -55,7 +56,7 @@ OpenLayers.Filter = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* APIMethod: clone
|
||||
* Clones this filter. Should be implementted by subclasses.
|
||||
* Clones this filter. Should be implemented by subclasses.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Filter>} Clone of this filter.
|
||||
@ -64,5 +65,23 @@ OpenLayers.Filter = OpenLayers.Class({
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: toString
|
||||
*
|
||||
* Returns:
|
||||
* {String} Include <OpenLayers.Format.CQL> in your build to get a CQL
|
||||
* representation of the filter returned. Otherwise "[Object object]"
|
||||
* will be returned.
|
||||
*/
|
||||
toString: function() {
|
||||
var string;
|
||||
if (OpenLayers.Format && OpenLayers.Format.CQL) {
|
||||
string = OpenLayers.Format.CQL.prototype.write(this);
|
||||
} else {
|
||||
string = Object.prototype.toString.call(this);
|
||||
}
|
||||
return string;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Filter"
|
||||
});
|
||||
|
||||
@ -1,18 +1,17 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Filter.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Filter.Comparison
|
||||
* This class represents a comparison filter.
|
||||
*
|
||||
* Inherits from
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Filter>
|
||||
*/
|
||||
OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
@ -27,7 +26,8 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
* - OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||
* - OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||
* - OpenLayers.Filter.Comparison.BETWEEN = "..";
|
||||
* - OpenLayers.Filter.Comparison.LIKE = "~";
|
||||
* - OpenLayers.Filter.Comparison.LIKE = "~";
|
||||
* - OpenLayers.Filter.Comparison.IS_NULL = "NULL";
|
||||
*/
|
||||
type: null,
|
||||
|
||||
@ -55,7 +55,7 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
* elements. This property will be serialized with those elements only
|
||||
* if using the v1.1.0 filter format. However, when evaluating filters
|
||||
* here, the matchCase property will always be respected (for EQUAL_TO
|
||||
* and NOT_EQUAL_TO). Default is true.
|
||||
* and NOT_EQUAL_TO). Default is true.
|
||||
*/
|
||||
matchCase: true,
|
||||
|
||||
@ -90,6 +90,12 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Filter.prototype.initialize.apply(this, [options]);
|
||||
// since matchCase on PropertyIsLike is not schema compliant, we only
|
||||
// want to use this if explicitly asked for
|
||||
if (this.type === OpenLayers.Filter.Comparison.LIKE
|
||||
&& options.matchCase === undefined) {
|
||||
this.matchCase = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@ -109,9 +115,10 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
}
|
||||
var result = false;
|
||||
var got = context[this.property];
|
||||
var exp;
|
||||
switch(this.type) {
|
||||
case OpenLayers.Filter.Comparison.EQUAL_TO:
|
||||
var exp = this.value;
|
||||
exp = this.value;
|
||||
if(!this.matchCase &&
|
||||
typeof got == "string" && typeof exp == "string") {
|
||||
result = (got.toUpperCase() == exp.toUpperCase());
|
||||
@ -120,7 +127,7 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
}
|
||||
break;
|
||||
case OpenLayers.Filter.Comparison.NOT_EQUAL_TO:
|
||||
var exp = this.value;
|
||||
exp = this.value;
|
||||
if(!this.matchCase &&
|
||||
typeof got == "string" && typeof exp == "string") {
|
||||
result = (got.toUpperCase() != exp.toUpperCase());
|
||||
@ -148,6 +155,9 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
var regexp = new RegExp(this.value, "gi");
|
||||
result = regexp.test(got);
|
||||
break;
|
||||
case OpenLayers.Filter.Comparison.IS_NULL:
|
||||
result = (got === null);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
@ -160,11 +170,11 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
* regular expression already.
|
||||
*
|
||||
* Parameters:
|
||||
* wildCard - {<Char>} wildcard character in the above value, default
|
||||
* wildCard - {Char} wildcard character in the above value, default
|
||||
* is "*"
|
||||
* singleChar - {<Char>) single-character wildcard in the above value
|
||||
* singleChar - {Char} single-character wildcard in the above value
|
||||
* default is "."
|
||||
* escape - {<Char>) escape character in the above value, default is
|
||||
* escapeChar - {Char} escape character in the above value, default is
|
||||
* "!"
|
||||
*
|
||||
* Returns:
|
||||
@ -172,10 +182,8 @@ OpenLayers.Filter.Comparison = OpenLayers.Class(OpenLayers.Filter, {
|
||||
*/
|
||||
value2regex: function(wildCard, singleChar, escapeChar) {
|
||||
if (wildCard == ".") {
|
||||
var msg = "'.' is an unsupported wildCard character for "+
|
||||
"OpenLayers.Filter.Comparison";
|
||||
OpenLayers.Console.error(msg);
|
||||
return null;
|
||||
throw new Error("'.' is an unsupported wildCard character for " +
|
||||
"OpenLayers.Filter.Comparison");
|
||||
}
|
||||
|
||||
|
||||
@ -256,3 +264,4 @@ OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO = "<=";
|
||||
OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO = ">=";
|
||||
OpenLayers.Filter.Comparison.BETWEEN = "..";
|
||||
OpenLayers.Filter.Comparison.LIKE = "~";
|
||||
OpenLayers.Filter.Comparison.IS_NULL = "NULL";
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -13,18 +13,24 @@
|
||||
* This class represents a ogc:FeatureId Filter, as being used for rule-based SLD
|
||||
* styling
|
||||
*
|
||||
* Inherits from
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Filter>
|
||||
*/
|
||||
OpenLayers.Filter.FeatureId = OpenLayers.Class(OpenLayers.Filter, {
|
||||
|
||||
/**
|
||||
* APIProperty: fids
|
||||
* {Array(String)} Feature Ids to evaluate this rule against. To be passed
|
||||
* To be passed inside the params object.
|
||||
* {Array(String)} Feature Ids to evaluate this rule against.
|
||||
* To be passed inside the params object.
|
||||
*/
|
||||
fids: null,
|
||||
|
||||
/**
|
||||
* Property: type
|
||||
* {String} Type to identify this filter.
|
||||
*/
|
||||
type: "FID",
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Filter.FeatureId
|
||||
* Creates an ogc:FeatureId rule.
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Filter.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class: OpenLayers.Filter.Function
|
||||
* This class represents a filter function.
|
||||
* We are using this class for creation of complex
|
||||
* filters that can contain filter functions as values.
|
||||
* Nesting function as other functions parameter is supported.
|
||||
*
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Filter>
|
||||
*/
|
||||
OpenLayers.Filter.Function = OpenLayers.Class(OpenLayers.Filter, {
|
||||
|
||||
/**
|
||||
* APIProperty: name
|
||||
* {String} Name of the function.
|
||||
*/
|
||||
name: null,
|
||||
|
||||
/**
|
||||
* APIProperty: params
|
||||
* {Array(<OpenLayers.Filter.Function> || String || Number)} Function parameters
|
||||
* For now support only other Functions, String or Number
|
||||
*/
|
||||
params: null,
|
||||
|
||||
/**
|
||||
* Constructor: OpenLayers.Filter.Function
|
||||
* Creates a filter function.
|
||||
*
|
||||
* Parameters:
|
||||
* options - {Object} An optional object with properties to set on the
|
||||
* function.
|
||||
*
|
||||
* Returns:
|
||||
* {<OpenLayers.Filter.Function>}
|
||||
*/
|
||||
|
||||
CLASS_NAME: "OpenLayers.Filter.Function"
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
* Class: OpenLayers.Filter.Logical
|
||||
* This class represents ogc:And, ogc:Or and ogc:Not rules.
|
||||
*
|
||||
* Inherits from
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Filter>
|
||||
*/
|
||||
OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {
|
||||
@ -70,9 +70,10 @@ OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {
|
||||
* {Boolean} The filter applies.
|
||||
*/
|
||||
evaluate: function(context) {
|
||||
var i, len;
|
||||
switch(this.type) {
|
||||
case OpenLayers.Filter.Logical.AND:
|
||||
for (var i=0, len=this.filters.length; i<len; i++) {
|
||||
for (i=0, len=this.filters.length; i<len; i++) {
|
||||
if (this.filters[i].evaluate(context) == false) {
|
||||
return false;
|
||||
}
|
||||
@ -80,7 +81,7 @@ OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {
|
||||
return true;
|
||||
|
||||
case OpenLayers.Filter.Logical.OR:
|
||||
for (var i=0, len=this.filters.length; i<len; i++) {
|
||||
for (i=0, len=this.filters.length; i<len; i++) {
|
||||
if (this.filters[i].evaluate(context) == true) {
|
||||
return true;
|
||||
}
|
||||
@ -90,6 +91,7 @@ OpenLayers.Filter.Logical = OpenLayers.Class(OpenLayers.Filter, {
|
||||
case OpenLayers.Filter.Logical.NOT:
|
||||
return (!this.filters[0].evaluate(context));
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/Filter.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -13,7 +12,7 @@
|
||||
* This class represents a spatial filter.
|
||||
* Currently implemented: BBOX, DWithin and Intersects
|
||||
*
|
||||
* Inherits from
|
||||
* Inherits from:
|
||||
* - <OpenLayers.Filter>
|
||||
*/
|
||||
OpenLayers.Filter.Spatial = OpenLayers.Class(OpenLayers.Filter, {
|
||||
@ -68,9 +67,6 @@ OpenLayers.Filter.Spatial = OpenLayers.Class(OpenLayers.Filter, {
|
||||
* Returns:
|
||||
* {<OpenLayers.Filter.Spatial>}
|
||||
*/
|
||||
initialize: function(options) {
|
||||
OpenLayers.Filter.prototype.initialize.apply(this, [options]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: evaluate
|
||||
@ -98,9 +94,7 @@ OpenLayers.Filter.Spatial = OpenLayers.Class(OpenLayers.Filter, {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
OpenLayers.Console.error(
|
||||
OpenLayers.i18n("filterEvaluateNotImplemented"));
|
||||
break;
|
||||
throw new Error('evaluate is not implemented for this filter type.');
|
||||
}
|
||||
return intersect;
|
||||
},
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the Clear BSD license.
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the
|
||||
/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for
|
||||
* full list of contributors). Published under the 2-clause BSD license.
|
||||
* See license.txt in the OpenLayers distribution or repository for the
|
||||
* full text of the license. */
|
||||
|
||||
/**
|
||||
* @requires OpenLayers/BaseTypes/Class.js
|
||||
* @requires OpenLayers/Util.js
|
||||
* @requires OpenLayers/Console.js
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -102,7 +102,7 @@ OpenLayers.Format = OpenLayers.Class({
|
||||
* Depends on the subclass
|
||||
*/
|
||||
read: function(data) {
|
||||
OpenLayers.Console.userError(OpenLayers.i18n("readNotImplemented"));
|
||||
throw new Error('Read not implemented.');
|
||||
},
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ OpenLayers.Format = OpenLayers.Class({
|
||||
* {String} A string representation of the object.
|
||||
*/
|
||||
write: function(object) {
|
||||
OpenLayers.Console.userError(OpenLayers.i18n("writeNotImplemented"));
|
||||
throw new Error('Write not implemented.');
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Format"
|
||||
|
||||