{"diffoscope-json-version": 1, "source1": "/srv/reproducible-results/rbuild-debian/r-b-build.DRwMgvt8/b1/openlayers_2.13.1+ds2-10_armhf.changes", "source2": "/srv/reproducible-results/rbuild-debian/r-b-build.DRwMgvt8/b2/openlayers_2.13.1+ds2-10_armhf.changes", "unified_diff": null, "details": [{"source1": "Files", "source2": "Files", "unified_diff": "@@ -1,2 +1,2 @@\n \n- c5b7e5c200b9cd4991cea7757a73d3c3 715764 javascript optional libjs-openlayers_2.13.1+ds2-10_all.deb\n+ cf0c9dfa4e437587b088729c65476571 718104 javascript optional libjs-openlayers_2.13.1+ds2-10_all.deb\n"}, {"source1": "libjs-openlayers_2.13.1+ds2-10_all.deb", "source2": "libjs-openlayers_2.13.1+ds2-10_all.deb", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -1,3 +1,3 @@\n -rw-r--r-- 0 0 0 4 2023-01-14 13:27:41.000000 debian-binary\n -rw-r--r-- 0 0 0 3680 2023-01-14 13:27:41.000000 control.tar.xz\n--rw-r--r-- 0 0 0 711892 2023-01-14 13:27:41.000000 data.tar.xz\n+-rw-r--r-- 0 0 0 714232 2023-01-14 13:27:41.000000 data.tar.xz\n"}, {"source1": "control.tar.xz", "source2": "control.tar.xz", "unified_diff": null, "details": [{"source1": "control.tar", "source2": "control.tar", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "comments": ["Files differ"], "unified_diff": null}]}]}]}, {"source1": "data.tar.xz", "source2": "data.tar.xz", "unified_diff": null, "details": [{"source1": "data.tar", "source2": "data.tar", "unified_diff": null, "details": [{"source1": "./usr/share/javascript/openlayers/OpenLayers.js", "source2": "./usr/share/javascript/openlayers/OpenLayers.js", "unified_diff": null, "details": [{"source1": "js-beautify {}", "source2": "js-beautify {}", "unified_diff": "@@ -136,14 +136,141 @@\n * (code)\n * \n * (end code)\n */\n ImgPath: ''\n };\n /* ======================================================================\n+ OpenLayers/BaseTypes/Class.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n+\n+/**\n+ * Constructor: OpenLayers.Class\n+ * Base class used to construct all other classes. Includes support for \n+ * multiple inheritance. \n+ * \n+ * This constructor is new in OpenLayers 2.5. At OpenLayers 3.0, the old \n+ * syntax for creating classes and dealing with inheritance \n+ * will be removed.\n+ * \n+ * To create a new OpenLayers-style class, use the following syntax:\n+ * (code)\n+ * var MyClass = OpenLayers.Class(prototype);\n+ * (end)\n+ *\n+ * To create a new OpenLayers-style class with multiple inheritance, use the\n+ * following syntax:\n+ * (code)\n+ * var MyClass = OpenLayers.Class(Class1, Class2, prototype);\n+ * (end)\n+ * \n+ * Note that instanceof reflection will only reveal Class1 as superclass.\n+ *\n+ */\n+OpenLayers.Class = function() {\n+ var len = arguments.length;\n+ var P = arguments[0];\n+ var F = arguments[len - 1];\n+\n+ var C = typeof F.initialize == \"function\" ?\n+ F.initialize :\n+ function() {\n+ P.prototype.initialize.apply(this, arguments);\n+ };\n+\n+ if (len > 1) {\n+ var newArgs = [C, P].concat(\n+ Array.prototype.slice.call(arguments).slice(1, len - 1), F);\n+ OpenLayers.inherit.apply(null, newArgs);\n+ } else {\n+ C.prototype = F;\n+ }\n+ return C;\n+};\n+\n+/**\n+ * Function: OpenLayers.inherit\n+ *\n+ * Parameters:\n+ * C - {Object} the class that inherits\n+ * P - {Object} the superclass to inherit from\n+ *\n+ * In addition to the mandatory C and P parameters, an arbitrary number of\n+ * objects can be passed, which will extend C.\n+ */\n+OpenLayers.inherit = function(C, P) {\n+ var F = function() {};\n+ F.prototype = P.prototype;\n+ C.prototype = new F;\n+ var i, l, o;\n+ for (i = 2, l = arguments.length; i < l; i++) {\n+ o = arguments[i];\n+ if (typeof o === \"function\") {\n+ o = o.prototype;\n+ }\n+ OpenLayers.Util.extend(C.prototype, o);\n+ }\n+};\n+\n+/**\n+ * APIFunction: extend\n+ * Copy all properties of a source object to a destination object. Modifies\n+ * the passed in destination object. Any properties on the source object\n+ * that are set to undefined will not be (re)set on the destination object.\n+ *\n+ * Parameters:\n+ * destination - {Object} The object that will be modified\n+ * source - {Object} The object with properties to be set on the destination\n+ *\n+ * Returns:\n+ * {Object} The destination object.\n+ */\n+OpenLayers.Util = OpenLayers.Util || {};\n+OpenLayers.Util.extend = function(destination, source) {\n+ destination = destination || {};\n+ if (source) {\n+ for (var property in source) {\n+ var value = source[property];\n+ if (value !== undefined) {\n+ destination[property] = value;\n+ }\n+ }\n+\n+ /**\n+ * IE doesn't include the toString property when iterating over an object's\n+ * properties with the for(property in object) syntax. Explicitly check if\n+ * the source has its own toString property.\n+ */\n+\n+ /*\n+ * FF/Windows < 2.0.0.13 reports \"Illegal operation on WrappedNative\n+ * prototype object\" when calling hawOwnProperty if the source object\n+ * is an instance of window.Event.\n+ */\n+\n+ var sourceIsEvt = typeof window.Event == \"function\" &&\n+ source instanceof window.Event;\n+\n+ if (!sourceIsEvt &&\n+ source.hasOwnProperty && source.hasOwnProperty(\"toString\")) {\n+ destination.toString = source.toString;\n+ }\n+ }\n+ return destination;\n+};\n+/* ======================================================================\n OpenLayers/BaseTypes.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -603,141 +730,14 @@\n }\n }\n return selected;\n }\n \n };\n /* ======================================================================\n- OpenLayers/BaseTypes/Class.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-/**\n- * Constructor: OpenLayers.Class\n- * Base class used to construct all other classes. Includes support for \n- * multiple inheritance. \n- * \n- * This constructor is new in OpenLayers 2.5. At OpenLayers 3.0, the old \n- * syntax for creating classes and dealing with inheritance \n- * will be removed.\n- * \n- * To create a new OpenLayers-style class, use the following syntax:\n- * (code)\n- * var MyClass = OpenLayers.Class(prototype);\n- * (end)\n- *\n- * To create a new OpenLayers-style class with multiple inheritance, use the\n- * following syntax:\n- * (code)\n- * var MyClass = OpenLayers.Class(Class1, Class2, prototype);\n- * (end)\n- * \n- * Note that instanceof reflection will only reveal Class1 as superclass.\n- *\n- */\n-OpenLayers.Class = function() {\n- var len = arguments.length;\n- var P = arguments[0];\n- var F = arguments[len - 1];\n-\n- var C = typeof F.initialize == \"function\" ?\n- F.initialize :\n- function() {\n- P.prototype.initialize.apply(this, arguments);\n- };\n-\n- if (len > 1) {\n- var newArgs = [C, P].concat(\n- Array.prototype.slice.call(arguments).slice(1, len - 1), F);\n- OpenLayers.inherit.apply(null, newArgs);\n- } else {\n- C.prototype = F;\n- }\n- return C;\n-};\n-\n-/**\n- * Function: OpenLayers.inherit\n- *\n- * Parameters:\n- * C - {Object} the class that inherits\n- * P - {Object} the superclass to inherit from\n- *\n- * In addition to the mandatory C and P parameters, an arbitrary number of\n- * objects can be passed, which will extend C.\n- */\n-OpenLayers.inherit = function(C, P) {\n- var F = function() {};\n- F.prototype = P.prototype;\n- C.prototype = new F;\n- var i, l, o;\n- for (i = 2, l = arguments.length; i < l; i++) {\n- o = arguments[i];\n- if (typeof o === \"function\") {\n- o = o.prototype;\n- }\n- OpenLayers.Util.extend(C.prototype, o);\n- }\n-};\n-\n-/**\n- * APIFunction: extend\n- * Copy all properties of a source object to a destination object. Modifies\n- * the passed in destination object. Any properties on the source object\n- * that are set to undefined will not be (re)set on the destination object.\n- *\n- * Parameters:\n- * destination - {Object} The object that will be modified\n- * source - {Object} The object with properties to be set on the destination\n- *\n- * Returns:\n- * {Object} The destination object.\n- */\n-OpenLayers.Util = OpenLayers.Util || {};\n-OpenLayers.Util.extend = function(destination, source) {\n- destination = destination || {};\n- if (source) {\n- for (var property in source) {\n- var value = source[property];\n- if (value !== undefined) {\n- destination[property] = value;\n- }\n- }\n-\n- /**\n- * IE doesn't include the toString property when iterating over an object's\n- * properties with the for(property in object) syntax. Explicitly check if\n- * the source has its own toString property.\n- */\n-\n- /*\n- * FF/Windows < 2.0.0.13 reports \"Illegal operation on WrappedNative\n- * prototype object\" when calling hawOwnProperty if the source object\n- * is an instance of window.Event.\n- */\n-\n- var sourceIsEvt = typeof window.Event == \"function\" &&\n- source instanceof window.Event;\n-\n- if (!sourceIsEvt &&\n- source.hasOwnProperty && source.hasOwnProperty(\"toString\")) {\n- destination.toString = source.toString;\n- }\n- }\n- return destination;\n-};\n-/* ======================================================================\n OpenLayers/BaseTypes/Bounds.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -4426,813 +4426,1673 @@\n } else {\n str += coordinate < 0 ? OpenLayers.i18n(\"S\") : OpenLayers.i18n(\"N\");\n }\n return str;\n };\n \n /* ======================================================================\n- OpenLayers/Util/vendorPrefix.js\n+ OpenLayers/Feature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/SingleFile.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n */\n \n-OpenLayers.Util = OpenLayers.Util || {};\n /**\n- * Namespace: OpenLayers.Util.vendorPrefix\n- * A collection of utility functions to detect vendor prefixed features\n+ * Class: OpenLayers.Feature\n+ * Features are combinations of geography and attributes. The OpenLayers.Feature\n+ * class specifically combines a marker and a lonlat.\n */\n-OpenLayers.Util.vendorPrefix = (function() {\n- \"use strict\";\n+OpenLayers.Feature = OpenLayers.Class({\n \n- var VENDOR_PREFIXES = [\"\", \"O\", \"ms\", \"Moz\", \"Webkit\"],\n- divStyle = document.createElement(\"div\").style,\n- cssCache = {},\n- jsCache = {};\n+ /** \n+ * Property: layer \n+ * {} \n+ */\n+ layer: null,\n \n+ /** \n+ * Property: id \n+ * {String} \n+ */\n+ id: null,\n \n- /**\n- * Function: domToCss\n- * Converts a upper camel case DOM style property name to a CSS property\n- * i.e. transformOrigin -> transform-origin\n- * or WebkitTransformOrigin -> -webkit-transform-origin\n- *\n- * Parameters:\n- * prefixedDom - {String} The property to convert\n- *\n- * Returns:\n- * {String} The CSS property\n+ /** \n+ * Property: lonlat \n+ * {} \n */\n- function domToCss(prefixedDom) {\n- if (!prefixedDom) {\n- return null;\n- }\n- return prefixedDom.\n- replace(/([A-Z])/g, function(c) {\n- return \"-\" + c.toLowerCase();\n- }).\n- replace(/^ms-/, \"-ms-\");\n- }\n+ lonlat: null,\n \n- /**\n- * APIMethod: css\n- * Detect which property is used for a CSS property\n- *\n- * Parameters:\n- * property - {String} The standard (unprefixed) CSS property name\n- *\n- * Returns:\n- * {String} The standard CSS property, prefixed property or null if not\n- * supported\n+ /** \n+ * Property: data \n+ * {Object} \n */\n- function css(property) {\n- if (cssCache[property] === undefined) {\n- var domProperty = property.\n- replace(/(-[\\s\\S])/g, function(c) {\n- return c.charAt(1).toUpperCase();\n- });\n- var prefixedDom = style(domProperty);\n- cssCache[property] = domToCss(prefixedDom);\n- }\n- return cssCache[property];\n- }\n+ data: null,\n+\n+ /** \n+ * Property: marker \n+ * {} \n+ */\n+ marker: null,\n \n /**\n- * APIMethod: js\n- * Detect which property is used for a JS property/method\n+ * APIProperty: popupClass\n+ * {} The class which will be used to instantiate\n+ * a new Popup. Default is .\n+ */\n+ popupClass: null,\n+\n+ /** \n+ * Property: popup \n+ * {} \n+ */\n+ popup: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Feature\n+ * Constructor for features.\n *\n * Parameters:\n- * obj - {Object} The object to test on\n- * property - {String} The standard (unprefixed) JS property name\n- *\n+ * layer - {} \n+ * lonlat - {} \n+ * data - {Object} \n+ * \n * Returns:\n- * {String} The standard JS property, prefixed property or null if not\n- * supported\n+ * {}\n */\n- function js(obj, property) {\n- if (jsCache[property] === undefined) {\n- var tmpProp,\n- i = 0,\n- l = VENDOR_PREFIXES.length,\n- prefix,\n- isStyleObj = (typeof obj.cssText !== \"undefined\");\n+ initialize: function(layer, lonlat, data) {\n+ this.layer = layer;\n+ this.lonlat = lonlat;\n+ this.data = (data != null) ? data : {};\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\n \n- jsCache[property] = null;\n- for (; i < l; i++) {\n- prefix = VENDOR_PREFIXES[i];\n- if (prefix) {\n- if (!isStyleObj) {\n- // js prefix should be lower-case, while style\n- // properties have upper case on first character\n- prefix = prefix.toLowerCase();\n- }\n- tmpProp = prefix + property.charAt(0).toUpperCase() + property.slice(1);\n- } else {\n- tmpProp = property;\n- }\n+ /** \n+ * Method: destroy\n+ * nullify references to prevent circular references and memory leaks\n+ */\n+ destroy: function() {\n \n- if (obj[tmpProp] !== undefined) {\n- jsCache[property] = tmpProp;\n- break;\n- }\n+ //remove the popup from the map\n+ if ((this.layer != null) && (this.layer.map != null)) {\n+ if (this.popup != null) {\n+ this.layer.map.removePopup(this.popup);\n }\n }\n- return jsCache[property];\n- }\n+ // remove the marker from the layer\n+ if (this.layer != null && this.marker != null) {\n+ this.layer.removeMarker(this.marker);\n+ }\n+\n+ this.layer = null;\n+ this.id = null;\n+ this.lonlat = null;\n+ this.data = null;\n+ if (this.marker != null) {\n+ this.destroyMarker(this.marker);\n+ this.marker = null;\n+ }\n+ if (this.popup != null) {\n+ this.destroyPopup(this.popup);\n+ this.popup = null;\n+ }\n+ },\n \n /**\n- * APIMethod: style\n- * Detect which property is used for a DOM style property\n- *\n- * Parameters:\n- * property - {String} The standard (unprefixed) style property name\n- *\n+ * Method: onScreen\n+ * \n * Returns:\n- * {String} The standard style property, prefixed property or null if not\n- * supported\n+ * {Boolean} Whether or not the feature is currently visible on screen\n+ * (based on its 'lonlat' property)\n */\n- function style(property) {\n- return js(divStyle, property);\n- }\n-\n- return {\n- css: css,\n- js: js,\n- style: style,\n-\n- // used for testing\n- cssCache: cssCache,\n- jsCache: jsCache\n- };\n-}());\n-/* ======================================================================\n- OpenLayers/Animation.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ onScreen: function() {\n \n-/**\n- * @requires OpenLayers/SingleFile.js\n- * @requires OpenLayers/Util/vendorPrefix.js\n- */\n+ var onScreen = false;\n+ if ((this.layer != null) && (this.layer.map != null)) {\n+ var screenBounds = this.layer.map.getExtent();\n+ onScreen = screenBounds.containsLonLat(this.lonlat);\n+ }\n+ return onScreen;\n+ },\n \n-/**\n- * Namespace: OpenLayers.Animation\n- * A collection of utility functions for executing methods that repaint a \n- * portion of the browser window. These methods take advantage of the\n- * browser's scheduled repaints where requestAnimationFrame is available.\n- */\n-OpenLayers.Animation = (function(window) {\n \n /**\n- * Property: isNative\n- * {Boolean} true if a native requestAnimationFrame function is available\n+ * Method: createMarker\n+ * Based on the data associated with the Feature, create and return a marker object.\n+ *\n+ * Returns: \n+ * {} A Marker Object created from the 'lonlat' and 'icon' properties\n+ * set in this.data. If no 'lonlat' is set, returns null. If no\n+ * 'icon' is set, OpenLayers.Marker() will load the default image.\n+ * \n+ * Note - this.marker is set to return value\n+ * \n */\n- var requestAnimationFrame = OpenLayers.Util.vendorPrefix.js(window, \"requestAnimationFrame\");\n- var isNative = !!(requestAnimationFrame);\n+ createMarker: function() {\n+\n+ if (this.lonlat != null) {\n+ this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);\n+ }\n+ return this.marker;\n+ },\n \n /**\n- * Function: requestFrame\n- * Schedule a function to be called at the next available animation frame.\n- * Uses the native method where available. Where requestAnimationFrame is\n- * not available, setTimeout will be called with a 16ms delay.\n- *\n- * Parameters:\n- * callback - {Function} The function to be called at the next animation frame.\n- * element - {DOMElement} Optional element that visually bounds the animation.\n+ * Method: destroyMarker\n+ * Destroys marker.\n+ * If user overrides the createMarker() function, s/he should be able\n+ * to also specify an alternative function for destroying it\n */\n- var requestFrame = (function() {\n- var request = window[requestAnimationFrame] ||\n- function(callback, element) {\n- window.setTimeout(callback, 16);\n- };\n- // bind to window to avoid illegal invocation of native function\n- return function(callback, element) {\n- request.apply(window, [callback, element]);\n- };\n- })();\n-\n- // private variables for animation loops\n- var counter = 0;\n- var loops = {};\n+ destroyMarker: function() {\n+ this.marker.destroy();\n+ },\n \n /**\n- * Function: start\n- * Executes a method with in series for some \n- * duration.\n- *\n- * Parameters:\n- * callback - {Function} The function to be called at the next animation frame.\n- * duration - {Number} Optional duration for the loop. If not provided, the\n- * animation loop will execute indefinitely.\n- * element - {DOMElement} Optional element that visually bounds the animation.\n+ * Method: createPopup\n+ * Creates a popup object created from the 'lonlat', 'popupSize',\n+ * and 'popupContentHTML' properties set in this.data. It uses\n+ * this.marker.icon as default anchor. \n+ * \n+ * If no 'lonlat' is set, returns null. \n+ * If no this.marker has been created, no anchor is sent.\n *\n+ * Note - the returned popup object is 'owned' by the feature, so you\n+ * cannot use the popup's destroy method to discard the popup.\n+ * Instead, you must use the feature's destroyPopup\n+ * \n+ * Note - this.popup is set to return value\n+ * \n+ * Parameters: \n+ * closeBox - {Boolean} create popup with closebox or not\n+ * \n * Returns:\n- * {Number} Identifier for the animation loop. Used to stop animations with\n- * .\n+ * {} Returns the created popup, which is also set\n+ * as 'popup' property of this feature. Will be of whatever type\n+ * specified by this feature's 'popupClass' property, but must be\n+ * of type .\n+ * \n */\n- function start(callback, duration, element) {\n- duration = duration > 0 ? duration : Number.POSITIVE_INFINITY;\n- var id = ++counter;\n- var start = +new Date;\n- loops[id] = function() {\n- if (loops[id] && +new Date - start <= duration) {\n- callback();\n- if (loops[id]) {\n- requestFrame(loops[id], element);\n- }\n- } else {\n- delete loops[id];\n+ createPopup: function(closeBox) {\n+\n+ if (this.lonlat != null) {\n+ if (!this.popup) {\n+ var anchor = (this.marker) ? this.marker.icon : null;\n+ var popupClass = this.popupClass ?\n+ this.popupClass : OpenLayers.Popup.Anchored;\n+ this.popup = new popupClass(this.id + \"_popup\",\n+ this.lonlat,\n+ this.data.popupSize,\n+ this.data.popupContentHTML,\n+ anchor,\n+ closeBox);\n+ }\n+ if (this.data.overflow != null) {\n+ this.popup.contentDiv.style.overflow = this.data.overflow;\n }\n- };\n- requestFrame(loops[id], element);\n- return id;\n- }\n+\n+ this.popup.feature = this;\n+ }\n+ return this.popup;\n+ },\n+\n \n /**\n- * Function: stop\n- * Terminates an animation loop started with .\n+ * Method: destroyPopup\n+ * Destroys the popup created via createPopup.\n *\n- * Parameters:\n- * id - {Number} Identifier returned from .\n+ * As with the marker, if user overrides the createPopup() function, s/he \n+ * should also be able to override the destruction\n */\n- function stop(id) {\n- delete loops[id];\n- }\n-\n- return {\n- isNative: isNative,\n- requestFrame: requestFrame,\n- start: start,\n- stop: stop\n- };\n+ destroyPopup: function() {\n+ if (this.popup) {\n+ this.popup.feature = null;\n+ this.popup.destroy();\n+ this.popup = null;\n+ }\n+ },\n \n-})(window);\n+ CLASS_NAME: \"OpenLayers.Feature\"\n+});\n /* ======================================================================\n- OpenLayers/Kinetic.js\n+ OpenLayers/Feature/Vector.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+// TRASH THIS\n+OpenLayers.State = {\n+ /** states */\n+ UNKNOWN: 'Unknown',\n+ INSERT: 'Insert',\n+ UPDATE: 'Update',\n+ DELETE: 'Delete'\n+};\n+\n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Animation.js\n+ * @requires OpenLayers/Feature.js\n+ * @requires OpenLayers/Util.js\n */\n \n-OpenLayers.Kinetic = OpenLayers.Class({\n+/**\n+ * Class: OpenLayers.Feature.Vector\n+ * Vector features use the OpenLayers.Geometry classes as geometry description.\n+ * They have an 'attributes' property, which is the data object, and a 'style'\n+ * property, the default values of which are defined in the \n+ * objects.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {\n \n- /**\n- * Property: threshold\n- * In most cases changing the threshold isn't needed.\n- * In px/ms, default to 0.\n+ /** \n+ * Property: fid \n+ * {String} \n */\n- threshold: 0,\n+ fid: null,\n \n- /**\n- * Property: deceleration\n- * {Float} the deseleration in px/ms\u00b2, default to 0.0035.\n+ /** \n+ * APIProperty: geometry \n+ * {} \n */\n- deceleration: 0.0035,\n+ geometry: null,\n \n- /**\n- * Property: nbPoints\n- * {Integer} the number of points we use to calculate the kinetic\n- * initial values.\n+ /** \n+ * APIProperty: attributes \n+ * {Object} This object holds arbitrary, serializable properties that\n+ * describe the feature.\n */\n- nbPoints: 100,\n+ attributes: null,\n \n /**\n- * Property: delay\n- * {Float} time to consider to calculate the kinetic initial values.\n- * In ms, default to 200.\n+ * Property: bounds\n+ * {} The box bounding that feature's geometry, that\n+ * property can be set by an object when\n+ * deserializing the feature, so in most cases it represents an\n+ * information set by the server. \n */\n- delay: 200,\n+ bounds: null,\n+\n+ /** \n+ * Property: state \n+ * {String} \n+ */\n+ state: null,\n+\n+ /** \n+ * APIProperty: style \n+ * {Object} \n+ */\n+ style: null,\n \n /**\n- * Property: points\n- * List of points use to calculate the kinetic initial values.\n+ * APIProperty: url\n+ * {String} If this property is set it will be taken into account by\n+ * {} when upadting or deleting the feature.\n */\n- points: undefined,\n+ url: null,\n \n /**\n- * Property: timerId\n- * ID of the timer.\n+ * Property: renderIntent\n+ * {String} rendering intent currently being used\n */\n- timerId: undefined,\n+ renderIntent: \"default\",\n \n /**\n- * Constructor: OpenLayers.Kinetic\n+ * APIProperty: modified\n+ * {Object} An object with the originals of the geometry and attributes of\n+ * the feature, if they were changed. Currently this property is only read\n+ * by , and written by\n+ * , which sets the geometry property.\n+ * Applications can set the originals of modified attributes in the\n+ * attributes property. Note that applications have to check if this\n+ * object and the attributes property is already created before using it.\n+ * After a change made with ModifyFeature, this object could look like\n+ *\n+ * (code)\n+ * {\n+ * geometry: >Object\n+ * }\n+ * (end)\n+ *\n+ * When an application has made changes to feature attributes, it could\n+ * have set the attributes to something like this:\n+ *\n+ * (code)\n+ * {\n+ * attributes: {\n+ * myAttribute: \"original\"\n+ * }\n+ * }\n+ * (end)\n *\n+ * Note that only checks for truthy values in\n+ * *modified.geometry* and the attribute names in *modified.attributes*,\n+ * but it is recommended to set the original values (and not just true) as\n+ * attribute value, so applications could use this information to undo\n+ * changes.\n+ */\n+ modified: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Feature.Vector\n+ * Create a vector feature. \n+ * \n * Parameters:\n- * options - {Object}\n+ * geometry - {} The geometry that this feature\n+ * represents.\n+ * attributes - {Object} An optional object that will be mapped to the\n+ * property. \n+ * style - {Object} An optional style object.\n */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n+ initialize: function(geometry, attributes, style) {\n+ OpenLayers.Feature.prototype.initialize.apply(this,\n+ [null, null, attributes]);\n+ this.lonlat = null;\n+ this.geometry = geometry ? geometry : null;\n+ this.state = null;\n+ this.attributes = {};\n+ if (attributes) {\n+ this.attributes = OpenLayers.Util.extend(this.attributes,\n+ attributes);\n+ }\n+ this.style = style ? style : null;\n },\n \n- /**\n- * Method: begin\n- * Begins the dragging.\n+ /** \n+ * Method: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- begin: function() {\n- OpenLayers.Animation.stop(this.timerId);\n- this.timerId = undefined;\n- this.points = [];\n+ destroy: function() {\n+ if (this.layer) {\n+ this.layer.removeFeatures(this);\n+ this.layer = null;\n+ }\n+\n+ this.geometry = null;\n+ this.modified = null;\n+ OpenLayers.Feature.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: update\n- * Updates during the dragging.\n+ * Method: clone\n+ * Create a clone of this vector feature. Does not set any non-standard\n+ * properties.\n *\n- * Parameters:\n- * xy - {} The new position.\n+ * Returns:\n+ * {} An exact clone of this vector feature.\n */\n- update: function(xy) {\n- this.points.unshift({\n- xy: xy,\n- tick: new Date().getTime()\n- });\n- if (this.points.length > this.nbPoints) {\n- this.points.pop();\n- }\n+ clone: function() {\n+ return new OpenLayers.Feature.Vector(\n+ this.geometry ? this.geometry.clone() : null,\n+ this.attributes,\n+ this.style);\n },\n \n /**\n- * Method: end\n- * Ends the dragging, start the kinetic.\n+ * Method: onScreen\n+ * Determine whether the feature is within the map viewport. This method\n+ * tests for an intersection between the geometry and the viewport\n+ * bounds. If a more effecient but less precise geometry bounds\n+ * intersection is desired, call the method with the boundsOnly\n+ * parameter true.\n *\n * Parameters:\n- * xy - {} The last position.\n- *\n+ * boundsOnly - {Boolean} Only test whether a feature's bounds intersects\n+ * the viewport bounds. Default is false. If false, the feature's\n+ * geometry must intersect the viewport for onScreen to return true.\n+ * \n * Returns:\n- * {Object} An object with two properties: \"speed\", and \"theta\". The\n- * \"speed\" and \"theta\" values are to be passed to the move \n- * function when starting the animation.\n+ * {Boolean} The feature is currently visible on screen (optionally\n+ * based on its bounds if boundsOnly is true).\n */\n- end: function(xy) {\n- var last, now = new Date().getTime();\n- for (var i = 0, l = this.points.length, point; i < l; i++) {\n- point = this.points[i];\n- if (now - point.tick > this.delay) {\n- break;\n+ onScreen: function(boundsOnly) {\n+ var onScreen = false;\n+ if (this.layer && this.layer.map) {\n+ var screenBounds = this.layer.map.getExtent();\n+ if (boundsOnly) {\n+ var featureBounds = this.geometry.getBounds();\n+ onScreen = screenBounds.intersectsBounds(featureBounds);\n+ } else {\n+ var screenPoly = screenBounds.toGeometry();\n+ onScreen = screenPoly.intersects(this.geometry);\n }\n- last = point;\n- }\n- if (!last) {\n- return;\n- }\n- var time = new Date().getTime() - last.tick;\n- var dist = Math.sqrt(Math.pow(xy.x - last.xy.x, 2) +\n- Math.pow(xy.y - last.xy.y, 2));\n- var speed = dist / time;\n- if (speed == 0 || speed < this.threshold) {\n- return;\n }\n- var theta = Math.asin((xy.y - last.xy.y) / dist);\n- if (last.xy.x <= xy.x) {\n- theta = Math.PI - theta;\n+ return onScreen;\n+ },\n+\n+ /**\n+ * Method: getVisibility\n+ * Determine whether the feature is displayed or not. It may not displayed\n+ * because:\n+ * - its style display property is set to 'none',\n+ * - it doesn't belong to any layer,\n+ * - the styleMap creates a symbolizer with display property set to 'none'\n+ * for it,\n+ * - the layer which it belongs to is not visible.\n+ * \n+ * Returns:\n+ * {Boolean} The feature is currently displayed.\n+ */\n+ getVisibility: function() {\n+ return !(this.style && this.style.display == 'none' ||\n+ !this.layer ||\n+ this.layer && this.layer.styleMap &&\n+ this.layer.styleMap.createSymbolizer(this, this.renderIntent).display == 'none' ||\n+ this.layer && !this.layer.getVisibility());\n+ },\n+\n+ /**\n+ * Method: createMarker\n+ * HACK - we need to decide if all vector features should be able to\n+ * create markers\n+ * \n+ * Returns:\n+ * {} For now just returns null\n+ */\n+ createMarker: function() {\n+ return null;\n+ },\n+\n+ /**\n+ * Method: destroyMarker\n+ * HACK - we need to decide if all vector features should be able to\n+ * delete markers\n+ * \n+ * If user overrides the createMarker() function, s/he should be able\n+ * to also specify an alternative function for destroying it\n+ */\n+ destroyMarker: function() {\n+ // pass\n+ },\n+\n+ /**\n+ * Method: createPopup\n+ * HACK - we need to decide if all vector features should be able to\n+ * create popups\n+ * \n+ * Returns:\n+ * {} For now just returns null\n+ */\n+ createPopup: function() {\n+ return null;\n+ },\n+\n+ /**\n+ * Method: atPoint\n+ * Determins whether the feature intersects with the specified location.\n+ * \n+ * Parameters: \n+ * lonlat - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n+ * toleranceLon - {float} Optional tolerance in Geometric Coords\n+ * toleranceLat - {float} Optional tolerance in Geographic Coords\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the feature is at the specified location\n+ */\n+ atPoint: function(lonlat, toleranceLon, toleranceLat) {\n+ var atPoint = false;\n+ if (this.geometry) {\n+ atPoint = this.geometry.atPoint(lonlat, toleranceLon,\n+ toleranceLat);\n }\n- return {\n- speed: speed,\n- theta: theta\n- };\n+ return atPoint;\n+ },\n+\n+ /**\n+ * Method: destroyPopup\n+ * HACK - we need to decide if all vector features should be able to\n+ * delete popups\n+ */\n+ destroyPopup: function() {\n+ // pass\n },\n \n /**\n * Method: move\n- * Launch the kinetic move pan.\n+ * Moves the feature and redraws it at its new location\n *\n * Parameters:\n- * info - {Object} An object with two properties, \"speed\", and \"theta\".\n- * These values are those returned from the \"end\" call.\n- * callback - {Function} Function called on every step of the animation,\n- * receives x, y (values to pan), end (is the last point).\n+ * location - { or } the\n+ * location to which to move the feature.\n */\n- move: function(info, callback) {\n- var v0 = info.speed;\n- var fx = Math.cos(info.theta);\n- var fy = -Math.sin(info.theta);\n-\n- var initialTime = new Date().getTime();\n+ move: function(location) {\n \n- var lastX = 0;\n- var lastY = 0;\n+ if (!this.layer || !this.geometry.move) {\n+ //do nothing if no layer or immoveable geometry\n+ return undefined;\n+ }\n \n- var timerCallback = function() {\n- if (this.timerId == null) {\n- return;\n- }\n+ var pixel;\n+ if (location.CLASS_NAME == \"OpenLayers.LonLat\") {\n+ pixel = this.layer.getViewPortPxFromLonLat(location);\n+ } else {\n+ pixel = location;\n+ }\n \n- var t = new Date().getTime() - initialTime;\n+ var lastPixel = this.layer.getViewPortPxFromLonLat(this.geometry.getBounds().getCenterLonLat());\n+ var res = this.layer.map.getResolution();\n+ this.geometry.move(res * (pixel.x - lastPixel.x),\n+ res * (lastPixel.y - pixel.y));\n+ this.layer.drawFeature(this);\n+ return lastPixel;\n+ },\n \n- var p = (-this.deceleration * Math.pow(t, 2)) / 2.0 + v0 * t;\n- var x = p * fx;\n- var y = p * fy;\n+ /**\n+ * Method: toState\n+ * Sets the new state\n+ *\n+ * Parameters:\n+ * state - {String} \n+ */\n+ toState: function(state) {\n+ if (state == OpenLayers.State.UPDATE) {\n+ switch (this.state) {\n+ case OpenLayers.State.UNKNOWN:\n+ case OpenLayers.State.DELETE:\n+ this.state = state;\n+ break;\n+ case OpenLayers.State.UPDATE:\n+ case OpenLayers.State.INSERT:\n+ break;\n+ }\n+ } else if (state == OpenLayers.State.INSERT) {\n+ switch (this.state) {\n+ case OpenLayers.State.UNKNOWN:\n+ break;\n+ default:\n+ this.state = state;\n+ break;\n+ }\n+ } else if (state == OpenLayers.State.DELETE) {\n+ switch (this.state) {\n+ case OpenLayers.State.INSERT:\n+ // the feature should be destroyed\n+ break;\n+ case OpenLayers.State.DELETE:\n+ break;\n+ case OpenLayers.State.UNKNOWN:\n+ case OpenLayers.State.UPDATE:\n+ this.state = state;\n+ break;\n+ }\n+ } else if (state == OpenLayers.State.UNKNOWN) {\n+ this.state = state;\n+ }\n+ },\n \n- var args = {};\n- args.end = false;\n- var v = -this.deceleration * t + v0;\n+ CLASS_NAME: \"OpenLayers.Feature.Vector\"\n+});\n \n- if (v <= 0) {\n- OpenLayers.Animation.stop(this.timerId);\n- this.timerId = null;\n- args.end = true;\n- }\n \n- args.x = x - lastX;\n- args.y = y - lastY;\n- lastX = x;\n- lastY = y;\n- callback(args.x, args.y, args.end);\n- };\n+/**\n+ * Constant: OpenLayers.Feature.Vector.style\n+ * OpenLayers features can have a number of style attributes. The 'default' \n+ * style will typically be used if no other style is specified. These\n+ * styles correspond for the most part, to the styling properties defined\n+ * by the SVG standard. \n+ * Information on fill properties: http://www.w3.org/TR/SVG/painting.html#FillProperties\n+ * Information on stroke properties: http://www.w3.org/TR/SVG/painting.html#StrokeProperties\n+ *\n+ * Symbolizer properties:\n+ * fill - {Boolean} Set to false if no fill is desired.\n+ * fillColor - {String} Hex fill color. Default is \"#ee9900\".\n+ * fillOpacity - {Number} Fill opacity (0-1). Default is 0.4 \n+ * stroke - {Boolean} Set to false if no stroke is desired.\n+ * strokeColor - {String} Hex stroke color. Default is \"#ee9900\".\n+ * strokeOpacity - {Number} Stroke opacity (0-1). Default is 1.\n+ * strokeWidth - {Number} Pixel stroke width. Default is 1.\n+ * strokeLinecap - {String} Stroke cap type. Default is \"round\". [butt | round | square]\n+ * strokeDashstyle - {String} Stroke dash style. Default is \"solid\". [dot | dash | dashdot | longdash | longdashdot | solid]\n+ * graphic - {Boolean} Set to false if no graphic is desired.\n+ * pointRadius - {Number} Pixel point radius. Default is 6.\n+ * pointerEvents - {String} Default is \"visiblePainted\".\n+ * cursor - {String} Default is \"\".\n+ * externalGraphic - {String} Url to an external graphic that will be used for rendering points.\n+ * graphicWidth - {Number} Pixel width for sizing an external graphic.\n+ * graphicHeight - {Number} Pixel height for sizing an external graphic.\n+ * graphicOpacity - {Number} Opacity (0-1) for an external graphic.\n+ * graphicXOffset - {Number} Pixel offset along the positive x axis for displacing an external graphic.\n+ * graphicYOffset - {Number} Pixel offset along the positive y axis for displacing an external graphic.\n+ * rotation - {Number} For point symbolizers, this is the rotation of a graphic in the clockwise direction about its center point (or any point off center as specified by graphicXOffset and graphicYOffset).\n+ * graphicZIndex - {Number} The integer z-index value to use in rendering.\n+ * graphicName - {String} Named graphic to use when rendering points. Supported values include \"circle\" (default),\n+ * \"square\", \"star\", \"x\", \"cross\", \"triangle\".\n+ * graphicTitle - {String} Tooltip when hovering over a feature. *deprecated*, use title instead\n+ * title - {String} Tooltip when hovering over a feature. Not supported by the canvas renderer.\n+ * backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.\n+ * backgroundGraphicZIndex - {Number} The integer z-index value to use in rendering the background graphic.\n+ * backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.\n+ * backgroundYOffset - {Number} The y offset (in pixels) for the background graphic.\n+ * backgroundHeight - {Number} The height of the background graphic. If not provided, the graphicHeight will be used.\n+ * backgroundWidth - {Number} The width of the background width. If not provided, the graphicWidth will be used.\n+ * label - {String} The text for an optional label. For browsers that use the canvas renderer, this requires either\n+ * fillText or mozDrawText to be available.\n+ * labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string\n+ * composed of two characters. The first character is for the horizontal alignment, the second for the vertical\n+ * alignment. Valid values for horizontal alignment: \"l\"=left, \"c\"=center, \"r\"=right. Valid values for vertical\n+ * alignment: \"t\"=top, \"m\"=middle, \"b\"=bottom. Example values: \"lt\", \"cm\", \"rb\". Default is \"cm\".\n+ * labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer.\n+ * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.\n+ * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.\n+ * Default is false.\n+ * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.\n+ * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the SVG renderers.\n+ * labelOutlineOpacity - {Number} The opacity (0-1) of the label outline. Default is fontOpacity. Only supported by the canvas & SVG renderers.\n+ * fontColor - {String} The font color for the label, to be provided like CSS.\n+ * fontOpacity - {Number} Opacity (0-1) for the label\n+ * fontFamily - {String} The font family for the label, to be provided like in CSS.\n+ * fontSize - {String} The font size for the label, to be provided like in CSS.\n+ * fontStyle - {String} The font style for the label, to be provided like in CSS.\n+ * fontWeight - {String} The font weight for the label, to be provided like in CSS.\n+ * display - {String} Symbolizers will have no effect if display is set to \"none\". All other values have no effect.\n+ */\n+OpenLayers.Feature.Vector.style = {\n+ 'default': {\n+ fillColor: \"#ee9900\",\n+ fillOpacity: 0.4,\n+ hoverFillColor: \"white\",\n+ hoverFillOpacity: 0.8,\n+ strokeColor: \"#ee9900\",\n+ strokeOpacity: 1,\n+ strokeWidth: 1,\n+ strokeLinecap: \"round\",\n+ strokeDashstyle: \"solid\",\n+ hoverStrokeColor: \"red\",\n+ hoverStrokeOpacity: 1,\n+ hoverStrokeWidth: 0.2,\n+ pointRadius: 6,\n+ hoverPointRadius: 1,\n+ hoverPointUnit: \"%\",\n+ pointerEvents: \"visiblePainted\",\n+ cursor: \"inherit\",\n+ fontColor: \"#000000\",\n+ labelAlign: \"cm\",\n+ labelOutlineColor: \"white\",\n+ labelOutlineWidth: 3\n+ },\n+ 'select': {\n+ fillColor: \"blue\",\n+ fillOpacity: 0.4,\n+ hoverFillColor: \"white\",\n+ hoverFillOpacity: 0.8,\n+ strokeColor: \"blue\",\n+ strokeOpacity: 1,\n+ strokeWidth: 2,\n+ strokeLinecap: \"round\",\n+ strokeDashstyle: \"solid\",\n+ hoverStrokeColor: \"red\",\n+ hoverStrokeOpacity: 1,\n+ hoverStrokeWidth: 0.2,\n+ pointRadius: 6,\n+ hoverPointRadius: 1,\n+ hoverPointUnit: \"%\",\n+ pointerEvents: \"visiblePainted\",\n+ cursor: \"pointer\",\n+ fontColor: \"#000000\",\n+ labelAlign: \"cm\",\n+ labelOutlineColor: \"white\",\n+ labelOutlineWidth: 3\n \n- this.timerId = OpenLayers.Animation.start(\n- OpenLayers.Function.bind(timerCallback, this)\n- );\n },\n+ 'temporary': {\n+ fillColor: \"#66cccc\",\n+ fillOpacity: 0.2,\n+ hoverFillColor: \"white\",\n+ hoverFillOpacity: 0.8,\n+ strokeColor: \"#66cccc\",\n+ strokeOpacity: 1,\n+ strokeLinecap: \"round\",\n+ strokeWidth: 2,\n+ strokeDashstyle: \"solid\",\n+ hoverStrokeColor: \"red\",\n+ hoverStrokeOpacity: 1,\n+ hoverStrokeWidth: 0.2,\n+ pointRadius: 6,\n+ hoverPointRadius: 1,\n+ hoverPointUnit: \"%\",\n+ pointerEvents: \"visiblePainted\",\n+ cursor: \"inherit\",\n+ fontColor: \"#000000\",\n+ labelAlign: \"cm\",\n+ labelOutlineColor: \"white\",\n+ labelOutlineWidth: 3\n \n- CLASS_NAME: \"OpenLayers.Kinetic\"\n-});\n+ },\n+ 'delete': {\n+ display: \"none\"\n+ }\n+};\n /* ======================================================================\n- OpenLayers/Tween.js\n+ OpenLayers/Style.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Animation.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Feature/Vector.js\n */\n \n /**\n- * Namespace: OpenLayers.Tween\n+ * Class: OpenLayers.Style\n+ * This class represents a UserStyle obtained\n+ * from a SLD, containing styling rules.\n */\n-OpenLayers.Tween = OpenLayers.Class({\n+OpenLayers.Style = OpenLayers.Class({\n \n /**\n- * APIProperty: easing\n- * {(Function)} Easing equation used for the animation\n- * Defaultly set to OpenLayers.Easing.Expo.easeOut\n+ * Property: id\n+ * {String} A unique id for this session.\n */\n- easing: null,\n+ id: null,\n \n /**\n- * APIProperty: begin\n- * {Object} Values to start the animation with\n+ * APIProperty: name\n+ * {String}\n */\n- begin: null,\n+ name: null,\n \n /**\n- * APIProperty: finish\n- * {Object} Values to finish the animation with\n+ * Property: title\n+ * {String} Title of this style (set if included in SLD)\n */\n- finish: null,\n+ title: null,\n \n /**\n- * APIProperty: duration\n- * {int} duration of the tween (number of steps)\n+ * Property: description\n+ * {String} Description of this style (set if abstract is included in SLD)\n */\n- duration: null,\n+ description: null,\n \n /**\n- * APIProperty: callbacks\n- * {Object} An object with start, eachStep and done properties whose values\n- * are functions to be call during the animation. They are passed the\n- * current computed value as argument.\n+ * APIProperty: layerName\n+ * {} name of the layer that this style belongs to, usually\n+ * according to the NamedLayer attribute of an SLD document.\n */\n- callbacks: null,\n+ layerName: null,\n \n /**\n- * Property: time\n- * {int} Step counter\n+ * APIProperty: isDefault\n+ * {Boolean}\n */\n- time: null,\n+ isDefault: false,\n+\n+ /** \n+ * Property: rules \n+ * {Array()}\n+ */\n+ rules: null,\n \n /**\n- * APIProperty: minFrameRate\n- * {Number} The minimum framerate for animations in frames per second. After\n- * each step, the time spent in the animation is compared to the calculated\n- * time at this frame rate. If the animation runs longer than the calculated\n- * time, the next step is skipped. Default is 30.\n+ * APIProperty: context\n+ * {Object} An optional object with properties that symbolizers' property\n+ * values should be evaluated against. If no context is specified,\n+ * feature.attributes will be used\n */\n- minFrameRate: null,\n+ context: null,\n \n /**\n- * Property: startTime\n- * {Number} The timestamp of the first execution step. Used for skipping\n- * frames\n+ * Property: defaultStyle\n+ * {Object} hash of style properties to use as default for merging\n+ * rule-based style symbolizers onto. If no rules are defined,\n+ * createSymbolizer will return this style. If is set to\n+ * true, the defaultStyle will only be taken into account if there are\n+ * rules defined.\n */\n- startTime: null,\n+ defaultStyle: null,\n \n /**\n- * Property: animationId\n- * {int} Loop id returned by OpenLayers.Animation.start\n+ * Property: defaultsPerSymbolizer\n+ * {Boolean} If set to true, the will extend the symbolizer\n+ * of every rule. Properties of the will also be used to set\n+ * missing symbolizer properties if the symbolizer has stroke, fill or\n+ * graphic set to true. Default is false.\n */\n- animationId: null,\n+ defaultsPerSymbolizer: false,\n \n /**\n- * Property: playing\n- * {Boolean} Tells if the easing is currently playing\n+ * Property: propertyStyles\n+ * {Hash of Boolean} cache of style properties that need to be parsed for\n+ * propertyNames. Property names are keys, values won't be used.\n */\n- playing: false,\n+ propertyStyles: null,\n+\n \n /** \n- * Constructor: OpenLayers.Tween\n- * Creates a Tween.\n+ * Constructor: OpenLayers.Style\n+ * Creates a UserStyle.\n *\n * Parameters:\n- * easing - {(Function)} easing function method to use\n+ * style - {Object} Optional hash of style properties that will be\n+ * used as default style for this style object. This style\n+ * applies if no rules are specified. Symbolizers defined in\n+ * rules will extend this default style.\n+ * options - {Object} An optional object with properties to set on the\n+ * style.\n+ *\n+ * Valid options:\n+ * rules - {Array()} List of rules to be added to the\n+ * style.\n+ * \n+ * Returns:\n+ * {}\n */\n- initialize: function(easing) {\n- this.easing = (easing) ? easing : OpenLayers.Easing.Expo.easeOut;\n+ initialize: function(style, options) {\n+\n+ OpenLayers.Util.extend(this, options);\n+ this.rules = [];\n+ if (options && options.rules) {\n+ this.addRules(options.rules);\n+ }\n+\n+ // use the default style from OpenLayers.Feature.Vector if no style\n+ // was given in the constructor\n+ this.setDefaultStyle(style ||\n+ OpenLayers.Feature.Vector.style[\"default\"]);\n+\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n },\n \n- /**\n- * APIMethod: start\n- * Plays the Tween, and calls the callback method on each step\n- * \n- * Parameters:\n- * begin - {Object} values to start the animation with\n- * finish - {Object} values to finish the animation with\n- * duration - {int} duration of the tween (number of steps)\n- * options - {Object} hash of options (callbacks (start, eachStep, done),\n- * minFrameRate)\n+ /** \n+ * APIMethod: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- start: function(begin, finish, duration, options) {\n- this.playing = true;\n- this.begin = begin;\n- this.finish = finish;\n- this.duration = duration;\n- this.callbacks = options.callbacks;\n- this.minFrameRate = options.minFrameRate || 30;\n- this.time = 0;\n- this.startTime = new Date().getTime();\n- OpenLayers.Animation.stop(this.animationId);\n- this.animationId = null;\n- if (this.callbacks && this.callbacks.start) {\n- this.callbacks.start.call(this, this.begin);\n+ destroy: function() {\n+ for (var i = 0, len = this.rules.length; i < len; i++) {\n+ this.rules[i].destroy();\n+ this.rules[i] = null;\n }\n- this.animationId = OpenLayers.Animation.start(\n- OpenLayers.Function.bind(this.play, this)\n- );\n+ this.rules = null;\n+ this.defaultStyle = null;\n },\n \n /**\n- * APIMethod: stop\n- * Stops the Tween, and calls the done callback\n- * Doesn't do anything if animation is already finished\n+ * Method: createSymbolizer\n+ * creates a style by applying all feature-dependent rules to the base\n+ * style.\n+ * \n+ * Parameters:\n+ * feature - {} feature to evaluate rules for\n+ * \n+ * Returns:\n+ * {Object} symbolizer hash\n */\n- stop: function() {\n- if (!this.playing) {\n- return;\n+ createSymbolizer: function(feature) {\n+ var style = this.defaultsPerSymbolizer ? {} : this.createLiterals(\n+ OpenLayers.Util.extend({}, this.defaultStyle), feature);\n+\n+ var rules = this.rules;\n+\n+ var rule, context;\n+ var elseRules = [];\n+ var appliedRules = false;\n+ for (var i = 0, len = rules.length; i < len; i++) {\n+ rule = rules[i];\n+ // does the rule apply?\n+ var applies = rule.evaluate(feature);\n+\n+ if (applies) {\n+ if (rule instanceof OpenLayers.Rule && rule.elseFilter) {\n+ elseRules.push(rule);\n+ } else {\n+ appliedRules = true;\n+ this.applySymbolizer(rule, style, feature);\n+ }\n+ }\n }\n \n- if (this.callbacks && this.callbacks.done) {\n- this.callbacks.done.call(this, this.finish);\n+ // if no other rules apply, apply the rules with else filters\n+ if (appliedRules == false && elseRules.length > 0) {\n+ appliedRules = true;\n+ for (var i = 0, len = elseRules.length; i < len; i++) {\n+ this.applySymbolizer(elseRules[i], style, feature);\n+ }\n }\n- OpenLayers.Animation.stop(this.animationId);\n- this.animationId = null;\n- this.playing = false;\n+\n+ // don't display if there were rules but none applied\n+ if (rules.length > 0 && appliedRules == false) {\n+ style.display = \"none\";\n+ }\n+\n+ if (style.label != null && typeof style.label !== \"string\") {\n+ style.label = String(style.label);\n+ }\n+\n+ return style;\n },\n \n /**\n- * Method: play\n- * Calls the appropriate easing method\n+ * Method: applySymbolizer\n+ *\n+ * Parameters:\n+ * rule - {}\n+ * style - {Object}\n+ * feature - {}\n+ *\n+ * Returns:\n+ * {Object} A style with new symbolizer applied.\n */\n- play: function() {\n- var value = {};\n- for (var i in this.begin) {\n- var b = this.begin[i];\n- var f = this.finish[i];\n- if (b == null || f == null || isNaN(b) || isNaN(f)) {\n- throw new TypeError('invalid value for Tween');\n- }\n+ applySymbolizer: function(rule, style, feature) {\n+ var symbolizerPrefix = feature.geometry ?\n+ this.getSymbolizerPrefix(feature.geometry) :\n+ OpenLayers.Style.SYMBOLIZER_PREFIXES[0];\n \n- var c = f - b;\n- value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);\n- }\n- this.time++;\n+ var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;\n \n- if (this.callbacks && this.callbacks.eachStep) {\n- // skip frames if frame rate drops below threshold\n- if ((new Date().getTime() - this.startTime) / this.time <= 1000 / this.minFrameRate) {\n- this.callbacks.eachStep.call(this, value);\n+ if (this.defaultsPerSymbolizer === true) {\n+ var defaults = this.defaultStyle;\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ pointRadius: defaults.pointRadius\n+ });\n+ if (symbolizer.stroke === true || symbolizer.graphic === true) {\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ strokeWidth: defaults.strokeWidth,\n+ strokeColor: defaults.strokeColor,\n+ strokeOpacity: defaults.strokeOpacity,\n+ strokeDashstyle: defaults.strokeDashstyle,\n+ strokeLinecap: defaults.strokeLinecap\n+ });\n+ }\n+ if (symbolizer.fill === true || symbolizer.graphic === true) {\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ fillColor: defaults.fillColor,\n+ fillOpacity: defaults.fillOpacity\n+ });\n+ }\n+ if (symbolizer.graphic === true) {\n+ OpenLayers.Util.applyDefaults(symbolizer, {\n+ pointRadius: this.defaultStyle.pointRadius,\n+ externalGraphic: this.defaultStyle.externalGraphic,\n+ graphicName: this.defaultStyle.graphicName,\n+ graphicOpacity: this.defaultStyle.graphicOpacity,\n+ graphicWidth: this.defaultStyle.graphicWidth,\n+ graphicHeight: this.defaultStyle.graphicHeight,\n+ graphicXOffset: this.defaultStyle.graphicXOffset,\n+ graphicYOffset: this.defaultStyle.graphicYOffset\n+ });\n }\n }\n \n- if (this.time > this.duration) {\n- this.stop();\n- }\n+ // merge the style with the current style\n+ return this.createLiterals(\n+ OpenLayers.Util.extend(style, symbolizer), feature);\n },\n \n /**\n- * Create empty functions for all easing methods.\n+ * Method: createLiterals\n+ * creates literals for all style properties that have an entry in\n+ * .\n+ * \n+ * Parameters:\n+ * style - {Object} style to create literals for. Will be modified\n+ * inline.\n+ * feature - {Object}\n+ * \n+ * Returns:\n+ * {Object} the modified style\n */\n- CLASS_NAME: \"OpenLayers.Tween\"\n-});\n+ createLiterals: function(style, feature) {\n+ var context = OpenLayers.Util.extend({}, feature.attributes || feature.data);\n+ OpenLayers.Util.extend(context, this.context);\n+\n+ for (var i in this.propertyStyles) {\n+ style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);\n+ }\n+ return style;\n+ },\n \n-/**\n- * Namespace: OpenLayers.Easing\n- * \n- * Credits:\n- * Easing Equations by Robert Penner, \n- */\n-OpenLayers.Easing = {\n /**\n- * Create empty functions for all easing methods.\n+ * Method: findPropertyStyles\n+ * Looks into all rules for this style and the defaultStyle to collect\n+ * all the style hash property names containing ${...} strings that have\n+ * to be replaced using the createLiteral method before returning them.\n+ * \n+ * Returns:\n+ * {Object} hash of property names that need createLiteral parsing. The\n+ * name of the property is the key, and the value is true;\n */\n- CLASS_NAME: \"OpenLayers.Easing\"\n-};\n+ findPropertyStyles: function() {\n+ var propertyStyles = {};\n \n-/**\n- * Namespace: OpenLayers.Easing.Linear\n- */\n-OpenLayers.Easing.Linear = {\n+ // check the default style\n+ var style = this.defaultStyle;\n+ this.addPropertyStyles(propertyStyles, style);\n+\n+ // walk through all rules to check for properties in their symbolizer\n+ var rules = this.rules;\n+ var symbolizer, value;\n+ for (var i = 0, len = rules.length; i < len; i++) {\n+ symbolizer = rules[i].symbolizer;\n+ for (var key in symbolizer) {\n+ value = symbolizer[key];\n+ if (typeof value == \"object\") {\n+ // symbolizer key is \"Point\", \"Line\" or \"Polygon\"\n+ this.addPropertyStyles(propertyStyles, value);\n+ } else {\n+ // symbolizer is a hash of style properties\n+ this.addPropertyStyles(propertyStyles, symbolizer);\n+ break;\n+ }\n+ }\n+ }\n+ return propertyStyles;\n+ },\n \n /**\n- * Function: easeIn\n+ * Method: addPropertyStyles\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n+ * propertyStyles - {Object} hash to add new property styles to. Will be\n+ * modified inline\n+ * symbolizer - {Object} search this symbolizer for property styles\n+ * \n * Returns:\n- * {Float}\n+ * {Object} propertyStyles hash\n */\n- easeIn: function(t, b, c, d) {\n- return c * t / d + b;\n+ addPropertyStyles: function(propertyStyles, symbolizer) {\n+ var property;\n+ for (var key in symbolizer) {\n+ property = symbolizer[key];\n+ if (typeof property == \"string\" &&\n+ property.match(/\\$\\{\\w+\\}/)) {\n+ propertyStyles[key] = true;\n+ }\n+ }\n+ return propertyStyles;\n },\n \n /**\n- * Function: easeOut\n+ * APIMethod: addRules\n+ * Adds rules to this style.\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n+ * rules - {Array()}\n */\n- easeOut: function(t, b, c, d) {\n- return c * t / d + b;\n+ addRules: function(rules) {\n+ Array.prototype.push.apply(this.rules, rules);\n+ this.propertyStyles = this.findPropertyStyles();\n },\n \n /**\n- * Function: easeInOut\n+ * APIMethod: setDefaultStyle\n+ * Sets the default style for this style object.\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n+ * style - {Object} Hash of style properties\n+ */\n+ setDefaultStyle: function(style) {\n+ this.defaultStyle = style;\n+ this.propertyStyles = this.findPropertyStyles();\n+ },\n+\n+ /**\n+ * Method: getSymbolizerPrefix\n+ * Returns the correct symbolizer prefix according to the\n+ * geometry type of the passed geometry\n+ * \n+ * Parameters:\n+ * geometry - {}\n+ * \n * Returns:\n- * {Float}\n+ * {String} key of the according symbolizer\n */\n- easeInOut: function(t, b, c, d) {\n- return c * t / d + b;\n+ getSymbolizerPrefix: function(geometry) {\n+ var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;\n+ for (var i = 0, len = prefixes.length; i < len; i++) {\n+ if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {\n+ return prefixes[i];\n+ }\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Easing.Linear\"\n+ /**\n+ * APIMethod: clone\n+ * Clones this style.\n+ * \n+ * Returns:\n+ * {} Clone of this style.\n+ */\n+ clone: function() {\n+ var options = OpenLayers.Util.extend({}, this);\n+ // clone rules\n+ if (this.rules) {\n+ options.rules = [];\n+ for (var i = 0, len = this.rules.length; i < len; ++i) {\n+ options.rules.push(this.rules[i].clone());\n+ }\n+ }\n+ // clone context\n+ options.context = this.context && OpenLayers.Util.extend({}, this.context);\n+ //clone default style\n+ var defaultStyle = OpenLayers.Util.extend({}, this.defaultStyle);\n+ return new OpenLayers.Style(defaultStyle, options);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Style\"\n+});\n+\n+\n+/**\n+ * Function: createLiteral\n+ * converts a style value holding a combination of PropertyName and Literal\n+ * into a Literal, taking the property values from the passed features.\n+ * \n+ * Parameters:\n+ * value - {String} value to parse. If this string contains a construct like\n+ * \"foo ${bar}\", then \"foo \" will be taken as literal, and \"${bar}\"\n+ * will be replaced by the value of the \"bar\" attribute of the passed\n+ * feature.\n+ * context - {Object} context to take attribute values from\n+ * feature - {} optional feature to pass to\n+ * for evaluating functions in the\n+ * context.\n+ * property - {String} optional, name of the property for which the literal is\n+ * being created for evaluating functions in the context.\n+ * \n+ * Returns:\n+ * {String} the parsed value. In the example of the value parameter above, the\n+ * result would be \"foo valueOfBar\", assuming that the passed feature has an\n+ * attribute named \"bar\" with the value \"valueOfBar\".\n+ */\n+OpenLayers.Style.createLiteral = function(value, context, feature, property) {\n+ if (typeof value == \"string\" && value.indexOf(\"${\") != -1) {\n+ value = OpenLayers.String.format(value, context, [feature, property]);\n+ value = (isNaN(value) || !value) ? value : parseFloat(value);\n+ }\n+ return value;\n };\n \n /**\n- * Namespace: OpenLayers.Easing.Expo\n+ * Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES\n+ * {Array} prefixes of the sld symbolizers. These are the\n+ * same as the main geometry types\n */\n-OpenLayers.Easing.Expo = {\n+OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text',\n+ 'Raster'\n+];\n+/* ======================================================================\n+ OpenLayers/StyleMap.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Style.js\n+ * @requires OpenLayers/Feature/Vector.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.StyleMap\n+ */\n+OpenLayers.StyleMap = OpenLayers.Class({\n \n /**\n- * Function: easeIn\n+ * Property: styles\n+ * {Object} Hash of {}, keyed by names of well known\n+ * rendering intents (e.g. \"default\", \"temporary\", \"select\", \"delete\").\n+ */\n+ styles: null,\n+\n+ /**\n+ * Property: extendDefault\n+ * {Boolean} if true, every render intent will extend the symbolizers\n+ * specified for the \"default\" intent at rendering time. Otherwise, every\n+ * rendering intent will be treated as a completely independent style.\n+ */\n+ extendDefault: true,\n+\n+ /**\n+ * Constructor: OpenLayers.StyleMap\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n+ * style - {Object} Optional. Either a style hash, or a style object, or\n+ * a hash of style objects (style hashes) keyed by rendering\n+ * intent. If just one style hash or style object is passed,\n+ * this will be used for all known render intents (default,\n+ * select, temporary)\n+ * options - {Object} optional hash of additional options for this\n+ * instance\n */\n- easeIn: function(t, b, c, d) {\n- return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;\n+ initialize: function(style, options) {\n+ this.styles = {\n+ \"default\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"default\"]),\n+ \"select\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"select\"]),\n+ \"temporary\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"temporary\"]),\n+ \"delete\": new OpenLayers.Style(\n+ OpenLayers.Feature.Vector.style[\"delete\"])\n+ };\n+\n+ // take whatever the user passed as style parameter and convert it\n+ // into parts of stylemap.\n+ if (style instanceof OpenLayers.Style) {\n+ // user passed a style object\n+ this.styles[\"default\"] = style;\n+ this.styles[\"select\"] = style;\n+ this.styles[\"temporary\"] = style;\n+ this.styles[\"delete\"] = style;\n+ } else if (typeof style == \"object\") {\n+ for (var key in style) {\n+ if (style[key] instanceof OpenLayers.Style) {\n+ // user passed a hash of style objects\n+ this.styles[key] = style[key];\n+ } else if (typeof style[key] == \"object\") {\n+ // user passsed a hash of style hashes\n+ this.styles[key] = new OpenLayers.Style(style[key]);\n+ } else {\n+ // user passed a style hash (i.e. symbolizer)\n+ this.styles[\"default\"] = new OpenLayers.Style(style);\n+ this.styles[\"select\"] = new OpenLayers.Style(style);\n+ this.styles[\"temporary\"] = new OpenLayers.Style(style);\n+ this.styles[\"delete\"] = new OpenLayers.Style(style);\n+ break;\n+ }\n+ }\n+ }\n+ OpenLayers.Util.extend(this, options);\n },\n \n /**\n- * Function: easeOut\n+ * Method: destroy\n+ */\n+ destroy: function() {\n+ for (var key in this.styles) {\n+ this.styles[key].destroy();\n+ }\n+ this.styles = null;\n+ },\n+\n+ /**\n+ * Method: createSymbolizer\n+ * Creates the symbolizer for a feature for a render intent.\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n+ * feature - {} The feature to evaluate the rules\n+ * of the intended style against.\n+ * intent - {String} The intent determines the symbolizer that will be\n+ * used to draw the feature. Well known intents are \"default\"\n+ * (for just drawing the features), \"select\" (for selected\n+ * features) and \"temporary\" (for drawing features).\n+ * \n * Returns:\n- * {Float}\n+ * {Object} symbolizer hash\n */\n- easeOut: function(t, b, c, d) {\n- return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;\n+ createSymbolizer: function(feature, intent) {\n+ if (!feature) {\n+ feature = new OpenLayers.Feature.Vector();\n+ }\n+ if (!this.styles[intent]) {\n+ intent = \"default\";\n+ }\n+ feature.renderIntent = intent;\n+ var defaultSymbolizer = {};\n+ if (this.extendDefault && intent != \"default\") {\n+ defaultSymbolizer = this.styles[\"default\"].createSymbolizer(feature);\n+ }\n+ return OpenLayers.Util.extend(defaultSymbolizer,\n+ this.styles[intent].createSymbolizer(feature));\n },\n \n /**\n- * Function: easeInOut\n+ * Method: addUniqueValueRules\n+ * Convenience method to create comparison rules for unique values of a\n+ * property. The rules will be added to the style object for a specified\n+ * rendering intent. This method is a shortcut for creating something like\n+ * the \"unique value legends\" familiar from well known desktop GIS systems\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n- * Returns:\n- * {Float}\n+ * renderIntent - {String} rendering intent to add the rules to\n+ * property - {String} values of feature attributes to create the\n+ * rules for\n+ * symbolizers - {Object} Hash of symbolizers, keyed by the desired\n+ * property values \n+ * context - {Object} An optional object with properties that\n+ * symbolizers' property values should be evaluated\n+ * against. If no context is specified, feature.attributes\n+ * will be used\n */\n- easeInOut: function(t, b, c, d) {\n- if (t == 0) return b;\n- if (t == d) return b + c;\n- if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;\n- return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;\n+ addUniqueValueRules: function(renderIntent, property, symbolizers, context) {\n+ var rules = [];\n+ for (var value in symbolizers) {\n+ rules.push(new OpenLayers.Rule({\n+ symbolizer: symbolizers[value],\n+ context: context,\n+ filter: new OpenLayers.Filter.Comparison({\n+ type: OpenLayers.Filter.Comparison.EQUAL_TO,\n+ property: property,\n+ value: value\n+ })\n+ }));\n+ }\n+ this.styles[renderIntent].addRules(rules);\n },\n \n- CLASS_NAME: \"OpenLayers.Easing.Expo\"\n-};\n+ CLASS_NAME: \"OpenLayers.StyleMap\"\n+});\n+/* ======================================================================\n+ OpenLayers/Tile.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n \n /**\n- * Namespace: OpenLayers.Easing.Quad\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n */\n-OpenLayers.Easing.Quad = {\n+\n+/**\n+ * Class: OpenLayers.Tile \n+ * This is a class designed to designate a single tile, however\n+ * it is explicitly designed to do relatively little. Tiles store \n+ * information about themselves -- such as the URL that they are related\n+ * to, and their size - but do not add themselves to the layer div \n+ * automatically, for example. Create a new tile with the \n+ * constructor, or a subclass. \n+ * \n+ * TBD 3.0 - remove reference to url in above paragraph\n+ * \n+ */\n+OpenLayers.Tile = OpenLayers.Class({\n \n /**\n- * Function: easeIn\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the tile.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * tile.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Supported event types:\n+ * beforedraw - Triggered before the tile is drawn. Used to defer\n+ * drawing to an animation queue. To defer drawing, listeners need\n+ * to return false, which will abort drawing. The queue handler needs\n+ * to call (true) to actually draw the tile.\n+ * loadstart - Triggered when tile loading starts.\n+ * loadend - Triggered when tile loading ends.\n+ * loaderror - Triggered before the loadend event (i.e. when the tile is\n+ * still hidden) if the tile could not be loaded.\n+ * reload - Triggered when an already loading tile is reloaded.\n+ * unload - Triggered before a tile is unloaded.\n+ */\n+ events: null,\n+\n+ /**\n+ * APIProperty: eventListeners\n+ * {Object} If set as an option at construction, the eventListeners\n+ * object will be registered with . Object\n+ * structure must be a listeners object as shown in the example for\n+ * the events.on method.\n+ *\n+ * This options can be set in the ``tileOptions`` option from\n+ * . For example, to be notified of the\n+ * ``loadend`` event of each tiles:\n+ * (code)\n+ * new OpenLayers.Layer.OSM('osm', 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', {\n+ * tileOptions: {\n+ * eventListeners: {\n+ * 'loadend': function(evt) {\n+ * // do something on loadend\n+ * }\n+ * }\n+ * }\n+ * });\n+ * (end)\n+ */\n+ eventListeners: null,\n+\n+ /**\n+ * Property: id \n+ * {String} null\n+ */\n+ id: null,\n+\n+ /** \n+ * Property: layer \n+ * {} layer the tile is attached to \n+ */\n+ layer: null,\n+\n+ /**\n+ * Property: url\n+ * {String} url of the request.\n+ *\n+ * TBD 3.0 \n+ * Deprecated. The base tile class does not need an url. This should be \n+ * handled in subclasses. Does not belong here.\n+ */\n+ url: null,\n+\n+ /** \n+ * APIProperty: bounds \n+ * {} null\n+ */\n+ bounds: null,\n+\n+ /** \n+ * Property: size \n+ * {} null\n+ */\n+ size: null,\n+\n+ /** \n+ * Property: position \n+ * {} Top Left pixel of the tile\n+ */\n+ position: null,\n+\n+ /**\n+ * Property: isLoading\n+ * {Boolean} Is the tile loading?\n+ */\n+ isLoading: false,\n+\n+ /** TBD 3.0 -- remove 'url' from the list of parameters to the constructor.\n+ * there is no need for the base tile class to have a url.\n+ */\n+\n+ /** \n+ * Constructor: OpenLayers.Tile\n+ * Constructor for a new instance.\n * \n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n+ * layer - {} layer that the tile will go in.\n+ * position - {}\n+ * bounds - {}\n+ * url - {}\n+ * size - {}\n+ * options - {Object}\n+ */\n+ initialize: function(layer, position, bounds, url, size, options) {\n+ this.layer = layer;\n+ this.position = position.clone();\n+ this.setBounds(bounds);\n+ this.url = url;\n+ if (size) {\n+ this.size = size.clone();\n+ }\n+\n+ //give the tile a unique id based on its BBOX.\n+ this.id = OpenLayers.Util.createUniqueID(\"Tile_\");\n+\n+ OpenLayers.Util.extend(this, options);\n+\n+ this.events = new OpenLayers.Events(this);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n+ }\n+ },\n+\n+ /**\n+ * Method: unload\n+ * Call immediately before destroying if you are listening to tile\n+ * events, so that counters are properly handled if tile is still\n+ * loading at destroy-time. Will only fire an event if the tile is\n+ * still loading.\n+ */\n+ unload: function() {\n+ if (this.isLoading) {\n+ this.isLoading = false;\n+ this.events.triggerEvent(\"unload\");\n+ }\n+ },\n+\n+ /** \n+ * APIMethod: destroy\n+ * Nullify references to prevent circular references and memory leaks.\n+ */\n+ destroy: function() {\n+ this.layer = null;\n+ this.bounds = null;\n+ this.size = null;\n+ this.position = null;\n+\n+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n+ }\n+ this.events.destroy();\n+ this.eventListeners = null;\n+ this.events = null;\n+ },\n+\n+ /**\n+ * Method: draw\n+ * Clear whatever is currently in the tile, then return whether or not \n+ * it should actually be re-drawn. This is an example implementation\n+ * that can be overridden by subclasses. The minimum thing to do here\n+ * is to call and return the result from .\n *\n+ * Parameters:\n+ * force - {Boolean} If true, the tile will not be cleared and no beforedraw\n+ * event will be fired. This is used for drawing tiles asynchronously\n+ * after drawing has been cancelled by returning false from a beforedraw\n+ * listener.\n+ * \n * Returns:\n- * {Float}\n+ * {Boolean} Whether or not the tile should actually be drawn. Returns null\n+ * if a beforedraw listener returned false.\n */\n- easeIn: function(t, b, c, d) {\n- return c * (t /= d) * t + b;\n+ draw: function(force) {\n+ if (!force) {\n+ //clear tile's contents and mark as not drawn\n+ this.clear();\n+ }\n+ var draw = this.shouldDraw();\n+ if (draw && !force && this.events.triggerEvent(\"beforedraw\") === false) {\n+ draw = null;\n+ }\n+ return draw;\n },\n \n /**\n- * Function: easeOut\n+ * Method: shouldDraw\n+ * Return whether or not the tile should actually be (re-)drawn. The only\n+ * case where we *wouldn't* want to draw the tile is if the tile is outside\n+ * its layer's maxExtent\n * \n- * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n- *\n * Returns:\n- * {Float}\n+ * {Boolean} Whether or not the tile should actually be drawn.\n */\n- easeOut: function(t, b, c, d) {\n- return -c * (t /= d) * (t - 2) + b;\n+ shouldDraw: function() {\n+ var withinMaxExtent = false,\n+ maxExtent = this.layer.maxExtent;\n+ if (maxExtent) {\n+ var map = this.layer.map;\n+ var worldBounds = map.baseLayer.wrapDateLine && map.getMaxExtent();\n+ if (this.bounds.intersectsBounds(maxExtent, {\n+ inclusive: false,\n+ worldBounds: worldBounds\n+ })) {\n+ withinMaxExtent = true;\n+ }\n+ }\n+\n+ return withinMaxExtent || this.layer.displayOutsideMaxExtent;\n },\n \n /**\n- * Function: easeInOut\n- * \n+ * Method: setBounds\n+ * Sets the bounds on this instance\n+ *\n * Parameters:\n- * t - {Float} time\n- * b - {Float} beginning position\n- * c - {Float} total change\n- * d - {Float} duration of the transition\n+ * bounds {}\n+ */\n+ setBounds: function(bounds) {\n+ bounds = bounds.clone();\n+ if (this.layer.map.baseLayer.wrapDateLine) {\n+ var worldExtent = this.layer.map.getMaxExtent(),\n+ tolerance = this.layer.map.getResolution();\n+ bounds = bounds.wrapDateLine(worldExtent, {\n+ leftTolerance: tolerance,\n+ rightTolerance: tolerance\n+ });\n+ }\n+ this.bounds = bounds;\n+ },\n+\n+ /** \n+ * Method: moveTo\n+ * Reposition the tile.\n *\n- * Returns:\n- * {Float}\n+ * Parameters:\n+ * bounds - {}\n+ * position - {}\n+ * redraw - {Boolean} Call draw method on tile after moving.\n+ * Default is true\n */\n- easeInOut: function(t, b, c, d) {\n- if ((t /= d / 2) < 1) return c / 2 * t * t + b;\n- return -c / 2 * ((--t) * (t - 2) - 1) + b;\n+ moveTo: function(bounds, position, redraw) {\n+ if (redraw == null) {\n+ redraw = true;\n+ }\n+\n+ this.setBounds(bounds);\n+ this.position = position.clone();\n+ if (redraw) {\n+ this.draw();\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Easing.Quad\"\n-};\n+ /** \n+ * Method: clear\n+ * Clear the tile of any bounds/position-related data so that it can \n+ * be reused in a new location.\n+ */\n+ clear: function(draw) {\n+ // to be extended by subclasses\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Tile\"\n+});\n /* ======================================================================\n OpenLayers/Events.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -6402,14 +7262,1549 @@\n \n OpenLayers.Event.observe(element, 'MSPointerUp', cb);\n },\n \n CLASS_NAME: \"OpenLayers.Events\"\n });\n /* ======================================================================\n+ OpenLayers/Request/XMLHttpRequest.js\n+ ====================================================================== */\n+\n+// XMLHttpRequest.js Copyright (C) 2010 Sergey Ilinsky (http://www.ilinsky.com)\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+/**\n+ * @requires OpenLayers/Request.js\n+ */\n+\n+(function() {\n+\n+ // Save reference to earlier defined object implementation (if any)\n+ var oXMLHttpRequest = window.XMLHttpRequest;\n+\n+ // Define on browser type\n+ var bGecko = !!window.controllers,\n+ bIE = window.document.all && !window.opera,\n+ bIE7 = bIE && window.navigator.userAgent.match(/MSIE 7.0/);\n+\n+ // Enables \"XMLHttpRequest()\" call next to \"new XMLHttpReques()\"\n+ function fXMLHttpRequest() {\n+ this._object = oXMLHttpRequest && !bIE7 ? new oXMLHttpRequest : new window.ActiveXObject(\"Microsoft.XMLHTTP\");\n+ this._listeners = [];\n+ };\n+\n+ // Constructor\n+ function cXMLHttpRequest() {\n+ return new fXMLHttpRequest;\n+ };\n+ cXMLHttpRequest.prototype = fXMLHttpRequest.prototype;\n+\n+ // BUGFIX: Firefox with Firebug installed would break pages if not executed\n+ if (bGecko && oXMLHttpRequest.wrapped)\n+ cXMLHttpRequest.wrapped = oXMLHttpRequest.wrapped;\n+\n+ // Constants\n+ cXMLHttpRequest.UNSENT = 0;\n+ cXMLHttpRequest.OPENED = 1;\n+ cXMLHttpRequest.HEADERS_RECEIVED = 2;\n+ cXMLHttpRequest.LOADING = 3;\n+ cXMLHttpRequest.DONE = 4;\n+\n+ // Public Properties\n+ cXMLHttpRequest.prototype.readyState = cXMLHttpRequest.UNSENT;\n+ cXMLHttpRequest.prototype.responseText = '';\n+ cXMLHttpRequest.prototype.responseXML = null;\n+ cXMLHttpRequest.prototype.status = 0;\n+ cXMLHttpRequest.prototype.statusText = '';\n+\n+ // Priority proposal\n+ cXMLHttpRequest.prototype.priority = \"NORMAL\";\n+\n+ // Instance-level Events Handlers\n+ cXMLHttpRequest.prototype.onreadystatechange = null;\n+\n+ // Class-level Events Handlers\n+ cXMLHttpRequest.onreadystatechange = null;\n+ cXMLHttpRequest.onopen = null;\n+ cXMLHttpRequest.onsend = null;\n+ cXMLHttpRequest.onabort = null;\n+\n+ // Public Methods\n+ cXMLHttpRequest.prototype.open = function(sMethod, sUrl, bAsync, sUser, sPassword) {\n+ // Delete headers, required when object is reused\n+ delete this._headers;\n+\n+ // When bAsync parameter value is omitted, use true as default\n+ if (arguments.length < 3)\n+ bAsync = true;\n+\n+ // Save async parameter for fixing Gecko bug with missing readystatechange in synchronous requests\n+ this._async = bAsync;\n+\n+ // Set the onreadystatechange handler\n+ var oRequest = this,\n+ nState = this.readyState,\n+ fOnUnload;\n+\n+ // BUGFIX: IE - memory leak on page unload (inter-page leak)\n+ if (bIE && bAsync) {\n+ fOnUnload = function() {\n+ if (nState != cXMLHttpRequest.DONE) {\n+ fCleanTransport(oRequest);\n+ // Safe to abort here since onreadystatechange handler removed\n+ oRequest.abort();\n+ }\n+ };\n+ window.attachEvent(\"onunload\", fOnUnload);\n+ }\n+\n+ // Add method sniffer\n+ if (cXMLHttpRequest.onopen)\n+ cXMLHttpRequest.onopen.apply(this, arguments);\n+\n+ if (arguments.length > 4)\n+ this._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n+ else\n+ if (arguments.length > 3)\n+ this._object.open(sMethod, sUrl, bAsync, sUser);\n+ else\n+ this._object.open(sMethod, sUrl, bAsync);\n+\n+ this.readyState = cXMLHttpRequest.OPENED;\n+ fReadyStateChange(this);\n+\n+ this._object.onreadystatechange = function() {\n+ if (bGecko && !bAsync)\n+ return;\n+\n+ // Synchronize state\n+ oRequest.readyState = oRequest._object.readyState;\n+\n+ //\n+ fSynchronizeValues(oRequest);\n+\n+ // BUGFIX: Firefox fires unnecessary DONE when aborting\n+ if (oRequest._aborted) {\n+ // Reset readyState to UNSENT\n+ oRequest.readyState = cXMLHttpRequest.UNSENT;\n+\n+ // Return now\n+ return;\n+ }\n+\n+ if (oRequest.readyState == cXMLHttpRequest.DONE) {\n+ // Free up queue\n+ delete oRequest._data;\n+ /* if (bAsync)\n+ fQueue_remove(oRequest);*/\n+ //\n+ fCleanTransport(oRequest);\n+ // Uncomment this block if you need a fix for IE cache\n+ /*\n+ // BUGFIX: IE - cache issue\n+ if (!oRequest._object.getResponseHeader(\"Date\")) {\n+ // Save object to cache\n+ oRequest._cached = oRequest._object;\n+\n+ // Instantiate a new transport object\n+ cXMLHttpRequest.call(oRequest);\n+\n+ // Re-send request\n+ if (sUser) {\n+ if (sPassword)\n+ oRequest._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n+ else\n+ oRequest._object.open(sMethod, sUrl, bAsync, sUser);\n+ }\n+ else\n+ oRequest._object.open(sMethod, sUrl, bAsync);\n+ oRequest._object.setRequestHeader(\"If-Modified-Since\", oRequest._cached.getResponseHeader(\"Last-Modified\") || new window.Date(0));\n+ // Copy headers set\n+ if (oRequest._headers)\n+ for (var sHeader in oRequest._headers)\n+ if (typeof oRequest._headers[sHeader] == \"string\") // Some frameworks prototype objects with functions\n+ oRequest._object.setRequestHeader(sHeader, oRequest._headers[sHeader]);\n+\n+ oRequest._object.onreadystatechange = function() {\n+ // Synchronize state\n+ oRequest.readyState = oRequest._object.readyState;\n+\n+ if (oRequest._aborted) {\n+ //\n+ oRequest.readyState = cXMLHttpRequest.UNSENT;\n+\n+ // Return\n+ return;\n+ }\n+\n+ if (oRequest.readyState == cXMLHttpRequest.DONE) {\n+ // Clean Object\n+ fCleanTransport(oRequest);\n+\n+ // get cached request\n+ if (oRequest.status == 304)\n+ oRequest._object = oRequest._cached;\n+\n+ //\n+ delete oRequest._cached;\n+\n+ //\n+ fSynchronizeValues(oRequest);\n+\n+ //\n+ fReadyStateChange(oRequest);\n+\n+ // BUGFIX: IE - memory leak in interrupted\n+ if (bIE && bAsync)\n+ window.detachEvent(\"onunload\", fOnUnload);\n+ }\n+ };\n+ oRequest._object.send(null);\n+\n+ // Return now - wait until re-sent request is finished\n+ return;\n+ };\n+ */\n+ // BUGFIX: IE - memory leak in interrupted\n+ if (bIE && bAsync)\n+ window.detachEvent(\"onunload\", fOnUnload);\n+ }\n+\n+ // BUGFIX: Some browsers (Internet Explorer, Gecko) fire OPEN readystate twice\n+ if (nState != oRequest.readyState)\n+ fReadyStateChange(oRequest);\n+\n+ nState = oRequest.readyState;\n+ }\n+ };\n+\n+ function fXMLHttpRequest_send(oRequest) {\n+ oRequest._object.send(oRequest._data);\n+\n+ // BUGFIX: Gecko - missing readystatechange calls in synchronous requests\n+ if (bGecko && !oRequest._async) {\n+ oRequest.readyState = cXMLHttpRequest.OPENED;\n+\n+ // Synchronize state\n+ fSynchronizeValues(oRequest);\n+\n+ // Simulate missing states\n+ while (oRequest.readyState < cXMLHttpRequest.DONE) {\n+ oRequest.readyState++;\n+ fReadyStateChange(oRequest);\n+ // Check if we are aborted\n+ if (oRequest._aborted)\n+ return;\n+ }\n+ }\n+ };\n+ cXMLHttpRequest.prototype.send = function(vData) {\n+ // Add method sniffer\n+ if (cXMLHttpRequest.onsend)\n+ cXMLHttpRequest.onsend.apply(this, arguments);\n+\n+ if (!arguments.length)\n+ vData = null;\n+\n+ // BUGFIX: Safari - fails sending documents created/modified dynamically, so an explicit serialization required\n+ // BUGFIX: IE - rewrites any custom mime-type to \"text/xml\" in case an XMLNode is sent\n+ // BUGFIX: Gecko - fails sending Element (this is up to the implementation either to standard)\n+ if (vData && vData.nodeType) {\n+ vData = window.XMLSerializer ? new window.XMLSerializer().serializeToString(vData) : vData.xml;\n+ if (!this._headers[\"Content-Type\"])\n+ this._object.setRequestHeader(\"Content-Type\", \"application/xml\");\n+ }\n+\n+ this._data = vData;\n+ /*\n+ // Add to queue\n+ if (this._async)\n+ fQueue_add(this);\n+ else*/\n+ fXMLHttpRequest_send(this);\n+ };\n+ cXMLHttpRequest.prototype.abort = function() {\n+ // Add method sniffer\n+ if (cXMLHttpRequest.onabort)\n+ cXMLHttpRequest.onabort.apply(this, arguments);\n+\n+ // BUGFIX: Gecko - unnecessary DONE when aborting\n+ if (this.readyState > cXMLHttpRequest.UNSENT)\n+ this._aborted = true;\n+\n+ this._object.abort();\n+\n+ // BUGFIX: IE - memory leak\n+ fCleanTransport(this);\n+\n+ this.readyState = cXMLHttpRequest.UNSENT;\n+\n+ delete this._data;\n+ /* if (this._async)\n+ fQueue_remove(this);*/\n+ };\n+ cXMLHttpRequest.prototype.getAllResponseHeaders = function() {\n+ return this._object.getAllResponseHeaders();\n+ };\n+ cXMLHttpRequest.prototype.getResponseHeader = function(sName) {\n+ return this._object.getResponseHeader(sName);\n+ };\n+ cXMLHttpRequest.prototype.setRequestHeader = function(sName, sValue) {\n+ // BUGFIX: IE - cache issue\n+ if (!this._headers)\n+ this._headers = {};\n+ this._headers[sName] = sValue;\n+\n+ return this._object.setRequestHeader(sName, sValue);\n+ };\n+\n+ // EventTarget interface implementation\n+ cXMLHttpRequest.prototype.addEventListener = function(sName, fHandler, bUseCapture) {\n+ for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n+ if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n+ return;\n+ // Add listener\n+ this._listeners.push([sName, fHandler, bUseCapture]);\n+ };\n+\n+ cXMLHttpRequest.prototype.removeEventListener = function(sName, fHandler, bUseCapture) {\n+ for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n+ if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n+ break;\n+ // Remove listener\n+ if (oListener)\n+ this._listeners.splice(nIndex, 1);\n+ };\n+\n+ cXMLHttpRequest.prototype.dispatchEvent = function(oEvent) {\n+ var oEventPseudo = {\n+ 'type': oEvent.type,\n+ 'target': this,\n+ 'currentTarget': this,\n+ 'eventPhase': 2,\n+ 'bubbles': oEvent.bubbles,\n+ 'cancelable': oEvent.cancelable,\n+ 'timeStamp': oEvent.timeStamp,\n+ 'stopPropagation': function() {}, // There is no flow\n+ 'preventDefault': function() {}, // There is no default action\n+ 'initEvent': function() {} // Original event object should be initialized\n+ };\n+\n+ // Execute onreadystatechange\n+ if (oEventPseudo.type == \"readystatechange\" && this.onreadystatechange)\n+ (this.onreadystatechange.handleEvent || this.onreadystatechange).apply(this, [oEventPseudo]);\n+\n+ // Execute listeners\n+ for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n+ if (oListener[0] == oEventPseudo.type && !oListener[2])\n+ (oListener[1].handleEvent || oListener[1]).apply(this, [oEventPseudo]);\n+ };\n+\n+ //\n+ cXMLHttpRequest.prototype.toString = function() {\n+ return '[' + \"object\" + ' ' + \"XMLHttpRequest\" + ']';\n+ };\n+\n+ cXMLHttpRequest.toString = function() {\n+ return '[' + \"XMLHttpRequest\" + ']';\n+ };\n+\n+ // Helper function\n+ function fReadyStateChange(oRequest) {\n+ // Sniffing code\n+ if (cXMLHttpRequest.onreadystatechange)\n+ cXMLHttpRequest.onreadystatechange.apply(oRequest);\n+\n+ // Fake event\n+ oRequest.dispatchEvent({\n+ 'type': \"readystatechange\",\n+ 'bubbles': false,\n+ 'cancelable': false,\n+ 'timeStamp': new Date + 0\n+ });\n+ };\n+\n+ function fGetDocument(oRequest) {\n+ var oDocument = oRequest.responseXML,\n+ sResponse = oRequest.responseText;\n+ // Try parsing responseText\n+ if (bIE && sResponse && oDocument && !oDocument.documentElement && oRequest.getResponseHeader(\"Content-Type\").match(/[^\\/]+\\/[^\\+]+\\+xml/)) {\n+ oDocument = new window.ActiveXObject(\"Microsoft.XMLDOM\");\n+ oDocument.async = false;\n+ oDocument.validateOnParse = false;\n+ oDocument.loadXML(sResponse);\n+ }\n+ // Check if there is no error in document\n+ if (oDocument)\n+ if ((bIE && oDocument.parseError != 0) || !oDocument.documentElement || (oDocument.documentElement && oDocument.documentElement.tagName == \"parsererror\"))\n+ return null;\n+ return oDocument;\n+ };\n+\n+ function fSynchronizeValues(oRequest) {\n+ try {\n+ oRequest.responseText = oRequest._object.responseText;\n+ } catch (e) {}\n+ try {\n+ oRequest.responseXML = fGetDocument(oRequest._object);\n+ } catch (e) {}\n+ try {\n+ oRequest.status = oRequest._object.status;\n+ } catch (e) {}\n+ try {\n+ oRequest.statusText = oRequest._object.statusText;\n+ } catch (e) {}\n+ };\n+\n+ function fCleanTransport(oRequest) {\n+ // BUGFIX: IE - memory leak (on-page leak)\n+ oRequest._object.onreadystatechange = new window.Function;\n+ };\n+ /*\n+ // Queue manager\n+ var oQueuePending = {\"CRITICAL\":[],\"HIGH\":[],\"NORMAL\":[],\"LOW\":[],\"LOWEST\":[]},\n+ aQueueRunning = [];\n+ function fQueue_add(oRequest) {\n+ oQueuePending[oRequest.priority in oQueuePending ? oRequest.priority : \"NORMAL\"].push(oRequest);\n+ //\n+ setTimeout(fQueue_process);\n+ };\n+\n+ function fQueue_remove(oRequest) {\n+ for (var nIndex = 0, bFound = false; nIndex < aQueueRunning.length; nIndex++)\n+ if (bFound)\n+ aQueueRunning[nIndex - 1] = aQueueRunning[nIndex];\n+ else\n+ if (aQueueRunning[nIndex] == oRequest)\n+ bFound = true;\n+ if (bFound)\n+ aQueueRunning.length--;\n+ //\n+ setTimeout(fQueue_process);\n+ };\n+\n+ function fQueue_process() {\n+ if (aQueueRunning.length < 6) {\n+ for (var sPriority in oQueuePending) {\n+ if (oQueuePending[sPriority].length) {\n+ var oRequest = oQueuePending[sPriority][0];\n+ oQueuePending[sPriority] = oQueuePending[sPriority].slice(1);\n+ //\n+ aQueueRunning.push(oRequest);\n+ // Send request\n+ fXMLHttpRequest_send(oRequest);\n+ break;\n+ }\n+ }\n+ }\n+ };\n+ */\n+ // Internet Explorer 5.0 (missing apply)\n+ if (!window.Function.prototype.apply) {\n+ window.Function.prototype.apply = function(oRequest, oArguments) {\n+ if (!oArguments)\n+ oArguments = [];\n+ oRequest.__func = this;\n+ oRequest.__func(oArguments[0], oArguments[1], oArguments[2], oArguments[3], oArguments[4]);\n+ delete oRequest.__func;\n+ };\n+ };\n+\n+ // Register new object with window\n+ /**\n+ * Class: OpenLayers.Request.XMLHttpRequest\n+ * Standard-compliant (W3C) cross-browser implementation of the\n+ * XMLHttpRequest object. From\n+ * http://code.google.com/p/xmlhttprequest/.\n+ */\n+ if (!OpenLayers.Request) {\n+ /**\n+ * This allows for OpenLayers/Request.js to be included\n+ * before or after this script.\n+ */\n+ OpenLayers.Request = {};\n+ }\n+ OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;\n+})();\n+/* ======================================================================\n+ OpenLayers/Request.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Request/XMLHttpRequest.js\n+ */\n+\n+/**\n+ * TODO: deprecate me\n+ * Use OpenLayers.Request.proxy instead.\n+ */\n+OpenLayers.ProxyHost = \"\";\n+\n+/**\n+ * Namespace: OpenLayers.Request\n+ * The OpenLayers.Request namespace contains convenience methods for working\n+ * with XMLHttpRequests. These methods work with a cross-browser\n+ * W3C compliant class.\n+ */\n+if (!OpenLayers.Request) {\n+ /**\n+ * This allows for OpenLayers/Request/XMLHttpRequest.js to be included\n+ * before or after this script.\n+ */\n+ OpenLayers.Request = {};\n+}\n+OpenLayers.Util.extend(OpenLayers.Request, {\n+\n+ /**\n+ * Constant: DEFAULT_CONFIG\n+ * {Object} Default configuration for all requests.\n+ */\n+ DEFAULT_CONFIG: {\n+ method: \"GET\",\n+ url: window.location.href,\n+ async: true,\n+ user: undefined,\n+ password: undefined,\n+ params: null,\n+ proxy: OpenLayers.ProxyHost,\n+ headers: {},\n+ data: null,\n+ callback: function() {},\n+ success: null,\n+ failure: null,\n+ scope: null\n+ },\n+\n+ /**\n+ * Constant: URL_SPLIT_REGEX\n+ */\n+ URL_SPLIT_REGEX: /([^:]*:)\\/\\/([^:]*:?[^@]*@)?([^:\\/\\?]*):?([^\\/\\?]*)/,\n+\n+ /**\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the {} object.\n+ *\n+ * All event listeners will receive an event object with three properties:\n+ * request - {} The request object.\n+ * config - {Object} The config object sent to the specific request method.\n+ * requestUrl - {String} The request url.\n+ * \n+ * Supported event types:\n+ * complete - Triggered when we have a response from the request, if a\n+ * listener returns false, no further response processing will take\n+ * place.\n+ * success - Triggered when the HTTP response has a success code (200-299).\n+ * failure - Triggered when the HTTP response does not have a success code.\n+ */\n+ events: new OpenLayers.Events(this),\n+\n+ /**\n+ * Method: makeSameOrigin\n+ * Using the specified proxy, returns a same origin url of the provided url.\n+ *\n+ * Parameters:\n+ * url - {String} An arbitrary url\n+ * proxy {String|Function} The proxy to use to make the provided url a\n+ * same origin url.\n+ *\n+ * Returns\n+ * {String} the same origin url. If no proxy is provided, the returned url\n+ * will be the same as the provided url.\n+ */\n+ makeSameOrigin: function(url, proxy) {\n+ var sameOrigin = url.indexOf(\"http\") !== 0;\n+ var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);\n+ if (urlParts) {\n+ var location = window.location;\n+ sameOrigin =\n+ urlParts[1] == location.protocol &&\n+ urlParts[3] == location.hostname;\n+ var uPort = urlParts[4],\n+ lPort = location.port;\n+ if (uPort != 80 && uPort != \"\" || lPort != \"80\" && lPort != \"\") {\n+ sameOrigin = sameOrigin && uPort == lPort;\n+ }\n+ }\n+ if (!sameOrigin) {\n+ if (proxy) {\n+ if (typeof proxy == \"function\") {\n+ url = proxy(url);\n+ } else {\n+ url = proxy + encodeURIComponent(url);\n+ }\n+ }\n+ }\n+ return url;\n+ },\n+\n+ /**\n+ * APIMethod: issue\n+ * Create a new XMLHttpRequest object, open it, set any headers, bind\n+ * a callback to done state, and send any data. It is recommended that\n+ * you use one , , , , , or .\n+ * This method is only documented to provide detail on the configuration\n+ * options available to all request methods.\n+ *\n+ * Parameters:\n+ * config - {Object} Object containing properties for configuring the\n+ * request. Allowed configuration properties are described below.\n+ * This object is modified and should not be reused.\n+ *\n+ * Allowed config properties:\n+ * method - {String} One of GET, POST, PUT, DELETE, HEAD, or\n+ * OPTIONS. Default is GET.\n+ * url - {String} URL for the request.\n+ * async - {Boolean} Open an asynchronous request. Default is true.\n+ * user - {String} User for relevant authentication scheme. Set\n+ * to null to clear current user.\n+ * password - {String} Password for relevant authentication scheme.\n+ * Set to null to clear current password.\n+ * proxy - {String} Optional proxy. Defaults to\n+ * .\n+ * params - {Object} Any key:value pairs to be appended to the\n+ * url as a query string. Assumes url doesn't already include a query\n+ * string or hash. Typically, this is only appropriate for \n+ * requests where the query string will be appended to the url.\n+ * Parameter values that are arrays will be\n+ * concatenated with a comma (note that this goes against form-encoding)\n+ * as is done with .\n+ * headers - {Object} Object with header:value pairs to be set on\n+ * the request.\n+ * data - {String | Document} Optional data to send with the request.\n+ * Typically, this is only used with and requests.\n+ * Make sure to provide the appropriate \"Content-Type\" header for your\n+ * data. For and requests, the content type defaults to\n+ * \"application-xml\". If your data is a different content type, or\n+ * if you are using a different HTTP method, set the \"Content-Type\"\n+ * header to match your data type.\n+ * callback - {Function} Function to call when request is done.\n+ * To determine if the request failed, check request.status (200\n+ * indicates success).\n+ * success - {Function} Optional function to call if request status is in\n+ * the 200s. This will be called in addition to callback above and\n+ * would typically only be used as an alternative.\n+ * failure - {Function} Optional function to call if request status is not\n+ * in the 200s. This will be called in addition to callback above and\n+ * would typically only be used as an alternative.\n+ * scope - {Object} If callback is a public method on some object,\n+ * set the scope to that object.\n+ *\n+ * Returns:\n+ * {XMLHttpRequest} Request object. To abort the request before a response\n+ * is received, call abort() on the request object.\n+ */\n+ issue: function(config) {\n+ // apply default config - proxy host may have changed\n+ var defaultConfig = OpenLayers.Util.extend(\n+ this.DEFAULT_CONFIG, {\n+ proxy: OpenLayers.ProxyHost\n+ }\n+ );\n+ config = config || {};\n+ config.headers = config.headers || {};\n+ config = OpenLayers.Util.applyDefaults(config, defaultConfig);\n+ config.headers = OpenLayers.Util.applyDefaults(config.headers, defaultConfig.headers);\n+ // Always set the \"X-Requested-With\" header to signal that this request\n+ // was issued through the XHR-object. Since header keys are case \n+ // insensitive and we want to allow overriding of the \"X-Requested-With\"\n+ // header through the user we cannot use applyDefaults, but have to \n+ // check manually whether we were called with a \"X-Requested-With\"\n+ // header.\n+ var customRequestedWithHeader = false,\n+ headerKey;\n+ for (headerKey in config.headers) {\n+ if (config.headers.hasOwnProperty(headerKey)) {\n+ if (headerKey.toLowerCase() === 'x-requested-with') {\n+ customRequestedWithHeader = true;\n+ }\n+ }\n+ }\n+ if (customRequestedWithHeader === false) {\n+ // we did not have a custom \"X-Requested-With\" header\n+ config.headers['X-Requested-With'] = 'XMLHttpRequest';\n+ }\n+\n+ // create request, open, and set headers\n+ var request = new OpenLayers.Request.XMLHttpRequest();\n+ var url = OpenLayers.Util.urlAppend(config.url,\n+ OpenLayers.Util.getParameterString(config.params || {}));\n+ url = OpenLayers.Request.makeSameOrigin(url, config.proxy);\n+ request.open(\n+ config.method, url, config.async, config.user, config.password\n+ );\n+ for (var header in config.headers) {\n+ request.setRequestHeader(header, config.headers[header]);\n+ }\n+\n+ var events = this.events;\n+\n+ // we want to execute runCallbacks with \"this\" as the\n+ // execution scope\n+ var self = this;\n+\n+ request.onreadystatechange = function() {\n+ if (request.readyState == OpenLayers.Request.XMLHttpRequest.DONE) {\n+ var proceed = events.triggerEvent(\n+ \"complete\", {\n+ request: request,\n+ config: config,\n+ requestUrl: url\n+ }\n+ );\n+ if (proceed !== false) {\n+ self.runCallbacks({\n+ request: request,\n+ config: config,\n+ requestUrl: url\n+ });\n+ }\n+ }\n+ };\n+\n+ // send request (optionally with data) and return\n+ // call in a timeout for asynchronous requests so the return is\n+ // available before readyState == 4 for cached docs\n+ if (config.async === false) {\n+ request.send(config.data);\n+ } else {\n+ window.setTimeout(function() {\n+ if (request.readyState !== 0) { // W3C: 0-UNSENT\n+ request.send(config.data);\n+ }\n+ }, 0);\n+ }\n+ return request;\n+ },\n+\n+ /**\n+ * Method: runCallbacks\n+ * Calls the complete, success and failure callbacks. Application\n+ * can listen to the \"complete\" event, have the listener \n+ * display a confirm window and always return false, and\n+ * execute OpenLayers.Request.runCallbacks if the user\n+ * hits \"yes\" in the confirm window.\n+ *\n+ * Parameters:\n+ * options - {Object} Hash containing request, config and requestUrl keys\n+ */\n+ runCallbacks: function(options) {\n+ var request = options.request;\n+ var config = options.config;\n+\n+ // bind callbacks to readyState 4 (done)\n+ var complete = (config.scope) ?\n+ OpenLayers.Function.bind(config.callback, config.scope) :\n+ config.callback;\n+\n+ // optional success callback\n+ var success;\n+ if (config.success) {\n+ success = (config.scope) ?\n+ OpenLayers.Function.bind(config.success, config.scope) :\n+ config.success;\n+ }\n+\n+ // optional failure callback\n+ var failure;\n+ if (config.failure) {\n+ failure = (config.scope) ?\n+ OpenLayers.Function.bind(config.failure, config.scope) :\n+ config.failure;\n+ }\n+\n+ if (OpenLayers.Util.createUrlObject(config.url).protocol == \"file:\" &&\n+ request.responseText) {\n+ request.status = 200;\n+ }\n+ complete(request);\n+\n+ if (!request.status || (request.status >= 200 && request.status < 300)) {\n+ this.events.triggerEvent(\"success\", options);\n+ if (success) {\n+ success(request);\n+ }\n+ }\n+ if (request.status && (request.status < 200 || request.status >= 300)) {\n+ this.events.triggerEvent(\"failure\", options);\n+ if (failure) {\n+ failure(request);\n+ }\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: GET\n+ * Send an HTTP GET request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to GET.\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n+ */\n+ GET: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"GET\"\n+ });\n+ return OpenLayers.Request.issue(config);\n+ },\n+\n+ /**\n+ * APIMethod: POST\n+ * Send a POST request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to POST and \"Content-Type\" header set to \"application/xml\".\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties. The\n+ * default \"Content-Type\" header will be set to \"application-xml\" if\n+ * none is provided. This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n+ */\n+ POST: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"POST\"\n+ });\n+ // set content type to application/xml if it isn't already set\n+ config.headers = config.headers ? config.headers : {};\n+ if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n+ config.headers[\"Content-Type\"] = \"application/xml\";\n+ }\n+ return OpenLayers.Request.issue(config);\n+ },\n+\n+ /**\n+ * APIMethod: PUT\n+ * Send an HTTP PUT request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to PUT and \"Content-Type\" header set to \"application/xml\".\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties. The\n+ * default \"Content-Type\" header will be set to \"application-xml\" if\n+ * none is provided. This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n+ */\n+ PUT: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"PUT\"\n+ });\n+ // set content type to application/xml if it isn't already set\n+ config.headers = config.headers ? config.headers : {};\n+ if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n+ config.headers[\"Content-Type\"] = \"application/xml\";\n+ }\n+ return OpenLayers.Request.issue(config);\n+ },\n+\n+ /**\n+ * APIMethod: DELETE\n+ * Send an HTTP DELETE request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to DELETE.\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n+ */\n+ DELETE: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"DELETE\"\n+ });\n+ return OpenLayers.Request.issue(config);\n+ },\n+\n+ /**\n+ * APIMethod: HEAD\n+ * Send an HTTP HEAD request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to HEAD.\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n+ */\n+ HEAD: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"HEAD\"\n+ });\n+ return OpenLayers.Request.issue(config);\n+ },\n+\n+ /**\n+ * APIMethod: OPTIONS\n+ * Send an HTTP OPTIONS request. Additional configuration properties are\n+ * documented in the method, with the method property set\n+ * to OPTIONS.\n+ *\n+ * Parameters:\n+ * config - {Object} Object with properties for configuring the request.\n+ * See the method for documentation of allowed properties.\n+ * This object is modified and should not be reused.\n+ * \n+ * Returns:\n+ * {XMLHttpRequest} Request object.\n+ */\n+ OPTIONS: function(config) {\n+ config = OpenLayers.Util.extend(config, {\n+ method: \"OPTIONS\"\n+ });\n+ return OpenLayers.Request.issue(config);\n+ }\n+\n+});\n+/* ======================================================================\n+ OpenLayers/Util/vendorPrefix.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n+\n+OpenLayers.Util = OpenLayers.Util || {};\n+/**\n+ * Namespace: OpenLayers.Util.vendorPrefix\n+ * A collection of utility functions to detect vendor prefixed features\n+ */\n+OpenLayers.Util.vendorPrefix = (function() {\n+ \"use strict\";\n+\n+ var VENDOR_PREFIXES = [\"\", \"O\", \"ms\", \"Moz\", \"Webkit\"],\n+ divStyle = document.createElement(\"div\").style,\n+ cssCache = {},\n+ jsCache = {};\n+\n+\n+ /**\n+ * Function: domToCss\n+ * Converts a upper camel case DOM style property name to a CSS property\n+ * i.e. transformOrigin -> transform-origin\n+ * or WebkitTransformOrigin -> -webkit-transform-origin\n+ *\n+ * Parameters:\n+ * prefixedDom - {String} The property to convert\n+ *\n+ * Returns:\n+ * {String} The CSS property\n+ */\n+ function domToCss(prefixedDom) {\n+ if (!prefixedDom) {\n+ return null;\n+ }\n+ return prefixedDom.\n+ replace(/([A-Z])/g, function(c) {\n+ return \"-\" + c.toLowerCase();\n+ }).\n+ replace(/^ms-/, \"-ms-\");\n+ }\n+\n+ /**\n+ * APIMethod: css\n+ * Detect which property is used for a CSS property\n+ *\n+ * Parameters:\n+ * property - {String} The standard (unprefixed) CSS property name\n+ *\n+ * Returns:\n+ * {String} The standard CSS property, prefixed property or null if not\n+ * supported\n+ */\n+ function css(property) {\n+ if (cssCache[property] === undefined) {\n+ var domProperty = property.\n+ replace(/(-[\\s\\S])/g, function(c) {\n+ return c.charAt(1).toUpperCase();\n+ });\n+ var prefixedDom = style(domProperty);\n+ cssCache[property] = domToCss(prefixedDom);\n+ }\n+ return cssCache[property];\n+ }\n+\n+ /**\n+ * APIMethod: js\n+ * Detect which property is used for a JS property/method\n+ *\n+ * Parameters:\n+ * obj - {Object} The object to test on\n+ * property - {String} The standard (unprefixed) JS property name\n+ *\n+ * Returns:\n+ * {String} The standard JS property, prefixed property or null if not\n+ * supported\n+ */\n+ function js(obj, property) {\n+ if (jsCache[property] === undefined) {\n+ var tmpProp,\n+ i = 0,\n+ l = VENDOR_PREFIXES.length,\n+ prefix,\n+ isStyleObj = (typeof obj.cssText !== \"undefined\");\n+\n+ jsCache[property] = null;\n+ for (; i < l; i++) {\n+ prefix = VENDOR_PREFIXES[i];\n+ if (prefix) {\n+ if (!isStyleObj) {\n+ // js prefix should be lower-case, while style\n+ // properties have upper case on first character\n+ prefix = prefix.toLowerCase();\n+ }\n+ tmpProp = prefix + property.charAt(0).toUpperCase() + property.slice(1);\n+ } else {\n+ tmpProp = property;\n+ }\n+\n+ if (obj[tmpProp] !== undefined) {\n+ jsCache[property] = tmpProp;\n+ break;\n+ }\n+ }\n+ }\n+ return jsCache[property];\n+ }\n+\n+ /**\n+ * APIMethod: style\n+ * Detect which property is used for a DOM style property\n+ *\n+ * Parameters:\n+ * property - {String} The standard (unprefixed) style property name\n+ *\n+ * Returns:\n+ * {String} The standard style property, prefixed property or null if not\n+ * supported\n+ */\n+ function style(property) {\n+ return js(divStyle, property);\n+ }\n+\n+ return {\n+ css: css,\n+ js: js,\n+ style: style,\n+\n+ // used for testing\n+ cssCache: cssCache,\n+ jsCache: jsCache\n+ };\n+}());\n+/* ======================================================================\n+ OpenLayers/Animation.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ * @requires OpenLayers/Util/vendorPrefix.js\n+ */\n+\n+/**\n+ * Namespace: OpenLayers.Animation\n+ * A collection of utility functions for executing methods that repaint a \n+ * portion of the browser window. These methods take advantage of the\n+ * browser's scheduled repaints where requestAnimationFrame is available.\n+ */\n+OpenLayers.Animation = (function(window) {\n+\n+ /**\n+ * Property: isNative\n+ * {Boolean} true if a native requestAnimationFrame function is available\n+ */\n+ var requestAnimationFrame = OpenLayers.Util.vendorPrefix.js(window, \"requestAnimationFrame\");\n+ var isNative = !!(requestAnimationFrame);\n+\n+ /**\n+ * Function: requestFrame\n+ * Schedule a function to be called at the next available animation frame.\n+ * Uses the native method where available. Where requestAnimationFrame is\n+ * not available, setTimeout will be called with a 16ms delay.\n+ *\n+ * Parameters:\n+ * callback - {Function} The function to be called at the next animation frame.\n+ * element - {DOMElement} Optional element that visually bounds the animation.\n+ */\n+ var requestFrame = (function() {\n+ var request = window[requestAnimationFrame] ||\n+ function(callback, element) {\n+ window.setTimeout(callback, 16);\n+ };\n+ // bind to window to avoid illegal invocation of native function\n+ return function(callback, element) {\n+ request.apply(window, [callback, element]);\n+ };\n+ })();\n+\n+ // private variables for animation loops\n+ var counter = 0;\n+ var loops = {};\n+\n+ /**\n+ * Function: start\n+ * Executes a method with in series for some \n+ * duration.\n+ *\n+ * Parameters:\n+ * callback - {Function} The function to be called at the next animation frame.\n+ * duration - {Number} Optional duration for the loop. If not provided, the\n+ * animation loop will execute indefinitely.\n+ * element - {DOMElement} Optional element that visually bounds the animation.\n+ *\n+ * Returns:\n+ * {Number} Identifier for the animation loop. Used to stop animations with\n+ * .\n+ */\n+ function start(callback, duration, element) {\n+ duration = duration > 0 ? duration : Number.POSITIVE_INFINITY;\n+ var id = ++counter;\n+ var start = +new Date;\n+ loops[id] = function() {\n+ if (loops[id] && +new Date - start <= duration) {\n+ callback();\n+ if (loops[id]) {\n+ requestFrame(loops[id], element);\n+ }\n+ } else {\n+ delete loops[id];\n+ }\n+ };\n+ requestFrame(loops[id], element);\n+ return id;\n+ }\n+\n+ /**\n+ * Function: stop\n+ * Terminates an animation loop started with .\n+ *\n+ * Parameters:\n+ * id - {Number} Identifier returned from .\n+ */\n+ function stop(id) {\n+ delete loops[id];\n+ }\n+\n+ return {\n+ isNative: isNative,\n+ requestFrame: requestFrame,\n+ start: start,\n+ stop: stop\n+ };\n+\n+})(window);\n+/* ======================================================================\n+ OpenLayers/Tween.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Animation.js\n+ */\n+\n+/**\n+ * Namespace: OpenLayers.Tween\n+ */\n+OpenLayers.Tween = OpenLayers.Class({\n+\n+ /**\n+ * APIProperty: easing\n+ * {(Function)} Easing equation used for the animation\n+ * Defaultly set to OpenLayers.Easing.Expo.easeOut\n+ */\n+ easing: null,\n+\n+ /**\n+ * APIProperty: begin\n+ * {Object} Values to start the animation with\n+ */\n+ begin: null,\n+\n+ /**\n+ * APIProperty: finish\n+ * {Object} Values to finish the animation with\n+ */\n+ finish: null,\n+\n+ /**\n+ * APIProperty: duration\n+ * {int} duration of the tween (number of steps)\n+ */\n+ duration: null,\n+\n+ /**\n+ * APIProperty: callbacks\n+ * {Object} An object with start, eachStep and done properties whose values\n+ * are functions to be call during the animation. They are passed the\n+ * current computed value as argument.\n+ */\n+ callbacks: null,\n+\n+ /**\n+ * Property: time\n+ * {int} Step counter\n+ */\n+ time: null,\n+\n+ /**\n+ * APIProperty: minFrameRate\n+ * {Number} The minimum framerate for animations in frames per second. After\n+ * each step, the time spent in the animation is compared to the calculated\n+ * time at this frame rate. If the animation runs longer than the calculated\n+ * time, the next step is skipped. Default is 30.\n+ */\n+ minFrameRate: null,\n+\n+ /**\n+ * Property: startTime\n+ * {Number} The timestamp of the first execution step. Used for skipping\n+ * frames\n+ */\n+ startTime: null,\n+\n+ /**\n+ * Property: animationId\n+ * {int} Loop id returned by OpenLayers.Animation.start\n+ */\n+ animationId: null,\n+\n+ /**\n+ * Property: playing\n+ * {Boolean} Tells if the easing is currently playing\n+ */\n+ playing: false,\n+\n+ /** \n+ * Constructor: OpenLayers.Tween\n+ * Creates a Tween.\n+ *\n+ * Parameters:\n+ * easing - {(Function)} easing function method to use\n+ */\n+ initialize: function(easing) {\n+ this.easing = (easing) ? easing : OpenLayers.Easing.Expo.easeOut;\n+ },\n+\n+ /**\n+ * APIMethod: start\n+ * Plays the Tween, and calls the callback method on each step\n+ * \n+ * Parameters:\n+ * begin - {Object} values to start the animation with\n+ * finish - {Object} values to finish the animation with\n+ * duration - {int} duration of the tween (number of steps)\n+ * options - {Object} hash of options (callbacks (start, eachStep, done),\n+ * minFrameRate)\n+ */\n+ start: function(begin, finish, duration, options) {\n+ this.playing = true;\n+ this.begin = begin;\n+ this.finish = finish;\n+ this.duration = duration;\n+ this.callbacks = options.callbacks;\n+ this.minFrameRate = options.minFrameRate || 30;\n+ this.time = 0;\n+ this.startTime = new Date().getTime();\n+ OpenLayers.Animation.stop(this.animationId);\n+ this.animationId = null;\n+ if (this.callbacks && this.callbacks.start) {\n+ this.callbacks.start.call(this, this.begin);\n+ }\n+ this.animationId = OpenLayers.Animation.start(\n+ OpenLayers.Function.bind(this.play, this)\n+ );\n+ },\n+\n+ /**\n+ * APIMethod: stop\n+ * Stops the Tween, and calls the done callback\n+ * Doesn't do anything if animation is already finished\n+ */\n+ stop: function() {\n+ if (!this.playing) {\n+ return;\n+ }\n+\n+ if (this.callbacks && this.callbacks.done) {\n+ this.callbacks.done.call(this, this.finish);\n+ }\n+ OpenLayers.Animation.stop(this.animationId);\n+ this.animationId = null;\n+ this.playing = false;\n+ },\n+\n+ /**\n+ * Method: play\n+ * Calls the appropriate easing method\n+ */\n+ play: function() {\n+ var value = {};\n+ for (var i in this.begin) {\n+ var b = this.begin[i];\n+ var f = this.finish[i];\n+ if (b == null || f == null || isNaN(b) || isNaN(f)) {\n+ throw new TypeError('invalid value for Tween');\n+ }\n+\n+ var c = f - b;\n+ value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);\n+ }\n+ this.time++;\n+\n+ if (this.callbacks && this.callbacks.eachStep) {\n+ // skip frames if frame rate drops below threshold\n+ if ((new Date().getTime() - this.startTime) / this.time <= 1000 / this.minFrameRate) {\n+ this.callbacks.eachStep.call(this, value);\n+ }\n+ }\n+\n+ if (this.time > this.duration) {\n+ this.stop();\n+ }\n+ },\n+\n+ /**\n+ * Create empty functions for all easing methods.\n+ */\n+ CLASS_NAME: \"OpenLayers.Tween\"\n+});\n+\n+/**\n+ * Namespace: OpenLayers.Easing\n+ * \n+ * Credits:\n+ * Easing Equations by Robert Penner, \n+ */\n+OpenLayers.Easing = {\n+ /**\n+ * Create empty functions for all easing methods.\n+ */\n+ CLASS_NAME: \"OpenLayers.Easing\"\n+};\n+\n+/**\n+ * Namespace: OpenLayers.Easing.Linear\n+ */\n+OpenLayers.Easing.Linear = {\n+\n+ /**\n+ * Function: easeIn\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeIn: function(t, b, c, d) {\n+ return c * t / d + b;\n+ },\n+\n+ /**\n+ * Function: easeOut\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeOut: function(t, b, c, d) {\n+ return c * t / d + b;\n+ },\n+\n+ /**\n+ * Function: easeInOut\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeInOut: function(t, b, c, d) {\n+ return c * t / d + b;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Easing.Linear\"\n+};\n+\n+/**\n+ * Namespace: OpenLayers.Easing.Expo\n+ */\n+OpenLayers.Easing.Expo = {\n+\n+ /**\n+ * Function: easeIn\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeIn: function(t, b, c, d) {\n+ return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;\n+ },\n+\n+ /**\n+ * Function: easeOut\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeOut: function(t, b, c, d) {\n+ return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;\n+ },\n+\n+ /**\n+ * Function: easeInOut\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeInOut: function(t, b, c, d) {\n+ if (t == 0) return b;\n+ if (t == d) return b + c;\n+ if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;\n+ return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Easing.Expo\"\n+};\n+\n+/**\n+ * Namespace: OpenLayers.Easing.Quad\n+ */\n+OpenLayers.Easing.Quad = {\n+\n+ /**\n+ * Function: easeIn\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeIn: function(t, b, c, d) {\n+ return c * (t /= d) * t + b;\n+ },\n+\n+ /**\n+ * Function: easeOut\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeOut: function(t, b, c, d) {\n+ return -c * (t /= d) * (t - 2) + b;\n+ },\n+\n+ /**\n+ * Function: easeInOut\n+ * \n+ * Parameters:\n+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n+ *\n+ * Returns:\n+ * {Float}\n+ */\n+ easeInOut: function(t, b, c, d) {\n+ if ((t /= d / 2) < 1) return c / 2 * t * t + b;\n+ return -c / 2 * ((--t) * (t - 2) - 1) + b;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Easing.Quad\"\n+};\n+/* ======================================================================\n OpenLayers/Projection.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -9645,1311 +12040,1396 @@\n OpenLayers.Map.TILE_WIDTH = 256;\n /**\n * Constant: TILE_HEIGHT\n * {Integer} 256 Default tile height (unless otherwise specified)\n */\n OpenLayers.Map.TILE_HEIGHT = 256;\n /* ======================================================================\n- OpenLayers/Request/XMLHttpRequest.js\n+ OpenLayers/Layer.js\n ====================================================================== */\n \n-// XMLHttpRequest.js Copyright (C) 2010 Sergey Ilinsky (http://www.ilinsky.com)\n-//\n-// Licensed under the Apache License, Version 2.0 (the \"License\");\n-// you may not use this file except in compliance with the License.\n-// You may obtain a copy of the License at\n-//\n-// http://www.apache.org/licenses/LICENSE-2.0\n-//\n-// Unless required by applicable law or agreed to in writing, software\n-// distributed under the License is distributed on an \"AS IS\" BASIS,\n-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n-// See the License for the specific language governing permissions and\n-// limitations under the License.\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n \n /**\n- * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Map.js\n+ * @requires OpenLayers/Projection.js\n */\n \n-(function() {\n+/**\n+ * Class: OpenLayers.Layer\n+ */\n+OpenLayers.Layer = OpenLayers.Class({\n \n- // Save reference to earlier defined object implementation (if any)\n- var oXMLHttpRequest = window.XMLHttpRequest;\n+ /**\n+ * APIProperty: id\n+ * {String}\n+ */\n+ id: null,\n \n- // Define on browser type\n- var bGecko = !!window.controllers,\n- bIE = window.document.all && !window.opera,\n- bIE7 = bIE && window.navigator.userAgent.match(/MSIE 7.0/);\n+ /** \n+ * APIProperty: name\n+ * {String}\n+ */\n+ name: null,\n \n- // Enables \"XMLHttpRequest()\" call next to \"new XMLHttpReques()\"\n- function fXMLHttpRequest() {\n- this._object = oXMLHttpRequest && !bIE7 ? new oXMLHttpRequest : new window.ActiveXObject(\"Microsoft.XMLHTTP\");\n- this._listeners = [];\n- };\n+ /** \n+ * APIProperty: div\n+ * {DOMElement}\n+ */\n+ div: null,\n \n- // Constructor\n- function cXMLHttpRequest() {\n- return new fXMLHttpRequest;\n- };\n- cXMLHttpRequest.prototype = fXMLHttpRequest.prototype;\n+ /**\n+ * APIProperty: opacity\n+ * {Float} The layer's opacity. Float number between 0.0 and 1.0. Default\n+ * is 1.\n+ */\n+ opacity: 1,\n \n- // BUGFIX: Firefox with Firebug installed would break pages if not executed\n- if (bGecko && oXMLHttpRequest.wrapped)\n- cXMLHttpRequest.wrapped = oXMLHttpRequest.wrapped;\n+ /**\n+ * APIProperty: alwaysInRange\n+ * {Boolean} If a layer's display should not be scale-based, this should \n+ * be set to true. This will cause the layer, as an overlay, to always \n+ * be 'active', by always returning true from the calculateInRange() \n+ * function. \n+ * \n+ * If not explicitly specified for a layer, its value will be \n+ * determined on startup in initResolutions() based on whether or not \n+ * any scale-specific properties have been set as options on the \n+ * layer. If no scale-specific options have been set on the layer, we \n+ * assume that it should always be in range.\n+ * \n+ * See #987 for more info.\n+ */\n+ alwaysInRange: null,\n \n- // Constants\n- cXMLHttpRequest.UNSENT = 0;\n- cXMLHttpRequest.OPENED = 1;\n- cXMLHttpRequest.HEADERS_RECEIVED = 2;\n- cXMLHttpRequest.LOADING = 3;\n- cXMLHttpRequest.DONE = 4;\n+ /**\n+ * Constant: RESOLUTION_PROPERTIES\n+ * {Array} The properties that are used for calculating resolutions\n+ * information.\n+ */\n+ RESOLUTION_PROPERTIES: [\n+ 'scales', 'resolutions',\n+ 'maxScale', 'minScale',\n+ 'maxResolution', 'minResolution',\n+ 'numZoomLevels', 'maxZoomLevel'\n+ ],\n \n- // Public Properties\n- cXMLHttpRequest.prototype.readyState = cXMLHttpRequest.UNSENT;\n- cXMLHttpRequest.prototype.responseText = '';\n- cXMLHttpRequest.prototype.responseXML = null;\n- cXMLHttpRequest.prototype.status = 0;\n- cXMLHttpRequest.prototype.statusText = '';\n+ /**\n+ * APIProperty: events\n+ * {}\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * layer.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Listeners will be called with a reference to an event object. The\n+ * properties of this event depends on exactly what happened.\n+ *\n+ * All event objects have at least the following properties:\n+ * object - {Object} A reference to layer.events.object.\n+ * element - {DOMElement} A reference to layer.events.element.\n+ *\n+ * Supported map event types:\n+ * loadstart - Triggered when layer loading starts. When using a Vector \n+ * layer with a Fixed or BBOX strategy, the event object includes \n+ * a *filter* property holding the OpenLayers.Filter used when \n+ * calling read on the protocol.\n+ * loadend - Triggered when layer loading ends. When using a Vector layer\n+ * with a Fixed or BBOX strategy, the event object includes a \n+ * *response* property holding an OpenLayers.Protocol.Response object.\n+ * visibilitychanged - Triggered when the layer's visibility property is\n+ * changed, e.g. by turning the layer on or off in the layer switcher.\n+ * Note that the actual visibility of the layer can also change if it\n+ * gets out of range (see ). If you also want to catch\n+ * these cases, register for the map's 'changelayer' event instead.\n+ * move - Triggered when layer moves (triggered with every mousemove\n+ * during a drag).\n+ * moveend - Triggered when layer is done moving, object passed as\n+ * argument has a zoomChanged boolean property which tells that the\n+ * zoom has changed.\n+ * added - Triggered after the layer is added to a map. Listeners will\n+ * receive an object with a *map* property referencing the map and a\n+ * *layer* property referencing the layer.\n+ * removed - Triggered after the layer is removed from the map. Listeners\n+ * will receive an object with a *map* property referencing the map and\n+ * a *layer* property referencing the layer.\n+ */\n+ events: null,\n \n- // Priority proposal\n- cXMLHttpRequest.prototype.priority = \"NORMAL\";\n+ /**\n+ * APIProperty: map\n+ * {} This variable is set when the layer is added to \n+ * the map, via the accessor function setMap().\n+ */\n+ map: null,\n \n- // Instance-level Events Handlers\n- cXMLHttpRequest.prototype.onreadystatechange = null;\n+ /**\n+ * APIProperty: isBaseLayer\n+ * {Boolean} Whether or not the layer is a base layer. This should be set \n+ * individually by all subclasses. Default is false\n+ */\n+ isBaseLayer: false,\n \n- // Class-level Events Handlers\n- cXMLHttpRequest.onreadystatechange = null;\n- cXMLHttpRequest.onopen = null;\n- cXMLHttpRequest.onsend = null;\n- cXMLHttpRequest.onabort = null;\n+ /**\n+ * Property: alpha\n+ * {Boolean} The layer's images have an alpha channel. Default is false.\n+ */\n+ alpha: false,\n \n- // Public Methods\n- cXMLHttpRequest.prototype.open = function(sMethod, sUrl, bAsync, sUser, sPassword) {\n- // Delete headers, required when object is reused\n- delete this._headers;\n+ /** \n+ * APIProperty: displayInLayerSwitcher\n+ * {Boolean} Display the layer's name in the layer switcher. Default is\n+ * true.\n+ */\n+ displayInLayerSwitcher: true,\n \n- // When bAsync parameter value is omitted, use true as default\n- if (arguments.length < 3)\n- bAsync = true;\n+ /**\n+ * APIProperty: visibility\n+ * {Boolean} The layer should be displayed in the map. Default is true.\n+ */\n+ visibility: true,\n \n- // Save async parameter for fixing Gecko bug with missing readystatechange in synchronous requests\n- this._async = bAsync;\n+ /**\n+ * APIProperty: attribution\n+ * {String} Attribution string, displayed when an \n+ * has been added to the map.\n+ */\n+ attribution: null,\n \n- // Set the onreadystatechange handler\n- var oRequest = this,\n- nState = this.readyState,\n- fOnUnload;\n+ /** \n+ * Property: inRange\n+ * {Boolean} The current map resolution is within the layer's min/max \n+ * range. This is set in whenever the zoom \n+ * changes.\n+ */\n+ inRange: false,\n \n- // BUGFIX: IE - memory leak on page unload (inter-page leak)\n- if (bIE && bAsync) {\n- fOnUnload = function() {\n- if (nState != cXMLHttpRequest.DONE) {\n- fCleanTransport(oRequest);\n- // Safe to abort here since onreadystatechange handler removed\n- oRequest.abort();\n- }\n- };\n- window.attachEvent(\"onunload\", fOnUnload);\n- }\n+ /**\n+ * Propery: imageSize\n+ * {} For layers with a gutter, the image is larger than \n+ * the tile by twice the gutter in each dimension.\n+ */\n+ imageSize: null,\n \n- // Add method sniffer\n- if (cXMLHttpRequest.onopen)\n- cXMLHttpRequest.onopen.apply(this, arguments);\n+ // OPTIONS\n \n- if (arguments.length > 4)\n- this._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n- else\n- if (arguments.length > 3)\n- this._object.open(sMethod, sUrl, bAsync, sUser);\n- else\n- this._object.open(sMethod, sUrl, bAsync);\n+ /** \n+ * Property: options\n+ * {Object} An optional object whose properties will be set on the layer.\n+ * Any of the layer properties can be set as a property of the options\n+ * object and sent to the constructor when the layer is created.\n+ */\n+ options: null,\n \n- this.readyState = cXMLHttpRequest.OPENED;\n- fReadyStateChange(this);\n+ /**\n+ * APIProperty: eventListeners\n+ * {Object} If set as an option at construction, the eventListeners\n+ * object will be registered with . Object\n+ * structure must be a listeners object as shown in the example for\n+ * the events.on method.\n+ */\n+ eventListeners: null,\n \n- this._object.onreadystatechange = function() {\n- if (bGecko && !bAsync)\n- return;\n+ /**\n+ * APIProperty: gutter\n+ * {Integer} Determines the width (in pixels) of the gutter around image\n+ * tiles to ignore. By setting this property to a non-zero value,\n+ * images will be requested that are wider and taller than the tile\n+ * size by a value of 2 x gutter. This allows artifacts of rendering\n+ * at tile edges to be ignored. Set a gutter value that is equal to\n+ * half the size of the widest symbol that needs to be displayed.\n+ * Defaults to zero. Non-tiled layers always have zero gutter.\n+ */\n+ gutter: 0,\n \n- // Synchronize state\n- oRequest.readyState = oRequest._object.readyState;\n+ /**\n+ * APIProperty: projection\n+ * {} or {} Specifies the projection of the layer.\n+ * Can be set in the layer options. If not specified in the layer options,\n+ * it is set to the default projection specified in the map,\n+ * when the layer is added to the map.\n+ * Projection along with default maxExtent and resolutions\n+ * are set automatically with commercial baselayers in EPSG:3857,\n+ * such as Google, Bing and OpenStreetMap, and do not need to be specified.\n+ * Otherwise, if specifying projection, also set maxExtent,\n+ * maxResolution or resolutions as appropriate.\n+ * When using vector layers with strategies, layer projection should be set\n+ * to the projection of the source data if that is different from the map default.\n+ * \n+ * Can be either a string or an object;\n+ * if a string is passed, will be converted to an object when\n+ * the layer is added to the map.\n+ * \n+ */\n+ projection: null,\n \n- //\n- fSynchronizeValues(oRequest);\n+ /**\n+ * APIProperty: units\n+ * {String} The layer map units. Defaults to null. Possible values\n+ * are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'.\n+ * Normally taken from the projection.\n+ * Only required if both map and layers do not define a projection,\n+ * or if they define a projection which does not define units.\n+ */\n+ units: null,\n \n- // BUGFIX: Firefox fires unnecessary DONE when aborting\n- if (oRequest._aborted) {\n- // Reset readyState to UNSENT\n- oRequest.readyState = cXMLHttpRequest.UNSENT;\n+ /**\n+ * APIProperty: scales\n+ * {Array} An array of map scales in descending order. The values in the\n+ * array correspond to the map scale denominator. Note that these\n+ * values only make sense if the display (monitor) resolution of the\n+ * client is correctly guessed by whomever is configuring the\n+ * application. In addition, the units property must also be set.\n+ * Use instead wherever possible.\n+ */\n+ scales: null,\n \n- // Return now\n- return;\n- }\n+ /**\n+ * APIProperty: resolutions\n+ * {Array} A list of map resolutions (map units per pixel) in descending\n+ * order. If this is not set in the layer constructor, it will be set\n+ * based on other resolution related properties (maxExtent,\n+ * maxResolution, maxScale, etc.).\n+ */\n+ resolutions: null,\n \n- if (oRequest.readyState == cXMLHttpRequest.DONE) {\n- // Free up queue\n- delete oRequest._data;\n- /* if (bAsync)\n- fQueue_remove(oRequest);*/\n- //\n- fCleanTransport(oRequest);\n- // Uncomment this block if you need a fix for IE cache\n- /*\n- // BUGFIX: IE - cache issue\n- if (!oRequest._object.getResponseHeader(\"Date\")) {\n- // Save object to cache\n- oRequest._cached = oRequest._object;\n+ /**\n+ * APIProperty: maxExtent\n+ * {|Array} If provided as an array, the array\n+ * should consist of four values (left, bottom, right, top).\n+ * The maximum extent for the layer. Defaults to null.\n+ * \n+ * The center of these bounds will not stray outside\n+ * of the viewport extent during panning. In addition, if\n+ * is set to false, data will not be\n+ * requested that falls completely outside of these bounds.\n+ */\n+ maxExtent: null,\n \n- // Instantiate a new transport object\n- cXMLHttpRequest.call(oRequest);\n+ /**\n+ * APIProperty: minExtent\n+ * {|Array} If provided as an array, the array\n+ * should consist of four values (left, bottom, right, top).\n+ * The minimum extent for the layer. Defaults to null.\n+ */\n+ minExtent: null,\n \n- // Re-send request\n- if (sUser) {\n- if (sPassword)\n- oRequest._object.open(sMethod, sUrl, bAsync, sUser, sPassword);\n- else\n- oRequest._object.open(sMethod, sUrl, bAsync, sUser);\n- }\n- else\n- oRequest._object.open(sMethod, sUrl, bAsync);\n- oRequest._object.setRequestHeader(\"If-Modified-Since\", oRequest._cached.getResponseHeader(\"Last-Modified\") || new window.Date(0));\n- // Copy headers set\n- if (oRequest._headers)\n- for (var sHeader in oRequest._headers)\n- if (typeof oRequest._headers[sHeader] == \"string\") // Some frameworks prototype objects with functions\n- oRequest._object.setRequestHeader(sHeader, oRequest._headers[sHeader]);\n-\n- oRequest._object.onreadystatechange = function() {\n- // Synchronize state\n- oRequest.readyState = oRequest._object.readyState;\n-\n- if (oRequest._aborted) {\n- //\n- oRequest.readyState = cXMLHttpRequest.UNSENT;\n+ /**\n+ * APIProperty: maxResolution\n+ * {Float} Default max is 360 deg / 256 px, which corresponds to\n+ * zoom level 0 on gmaps. Specify a different value in the layer \n+ * options if you are not using the default \n+ * and displaying the whole world.\n+ */\n+ maxResolution: null,\n \n- // Return\n- return;\n- }\n+ /**\n+ * APIProperty: minResolution\n+ * {Float}\n+ */\n+ minResolution: null,\n \n- if (oRequest.readyState == cXMLHttpRequest.DONE) {\n- // Clean Object\n- fCleanTransport(oRequest);\n+ /**\n+ * APIProperty: numZoomLevels\n+ * {Integer}\n+ */\n+ numZoomLevels: null,\n \n- // get cached request\n- if (oRequest.status == 304)\n- oRequest._object = oRequest._cached;\n+ /**\n+ * APIProperty: minScale\n+ * {Float}\n+ */\n+ minScale: null,\n \n- //\n- delete oRequest._cached;\n+ /**\n+ * APIProperty: maxScale\n+ * {Float}\n+ */\n+ maxScale: null,\n \n- //\n- fSynchronizeValues(oRequest);\n+ /**\n+ * APIProperty: displayOutsideMaxExtent\n+ * {Boolean} Request map tiles that are completely outside of the max \n+ * extent for this layer. Defaults to false.\n+ */\n+ displayOutsideMaxExtent: false,\n \n- //\n- fReadyStateChange(oRequest);\n+ /**\n+ * APIProperty: wrapDateLine\n+ * {Boolean} Wraps the world at the international dateline, so the map can\n+ * be panned infinitely in longitudinal direction. Only use this on the\n+ * base layer, and only if the layer's maxExtent equals the world bounds.\n+ * #487 for more info. \n+ */\n+ wrapDateLine: false,\n \n- // BUGFIX: IE - memory leak in interrupted\n- if (bIE && bAsync)\n- window.detachEvent(\"onunload\", fOnUnload);\n- }\n- };\n- oRequest._object.send(null);\n+ /**\n+ * Property: metadata\n+ * {Object} This object can be used to store additional information on a\n+ * layer object.\n+ */\n+ metadata: null,\n \n- // Return now - wait until re-sent request is finished\n- return;\n- };\n- */\n- // BUGFIX: IE - memory leak in interrupted\n- if (bIE && bAsync)\n- window.detachEvent(\"onunload\", fOnUnload);\n- }\n+ /**\n+ * Constructor: OpenLayers.Layer\n+ *\n+ * Parameters:\n+ * name - {String} The layer name\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n+ */\n+ initialize: function(name, options) {\n \n- // BUGFIX: Some browsers (Internet Explorer, Gecko) fire OPEN readystate twice\n- if (nState != oRequest.readyState)\n- fReadyStateChange(oRequest);\n+ this.metadata = {};\n \n- nState = oRequest.readyState;\n+ options = OpenLayers.Util.extend({}, options);\n+ // make sure we respect alwaysInRange if set on the prototype\n+ if (this.alwaysInRange != null) {\n+ options.alwaysInRange = this.alwaysInRange;\n }\n- };\n+ this.addOptions(options);\n \n- function fXMLHttpRequest_send(oRequest) {\n- oRequest._object.send(oRequest._data);\n+ this.name = name;\n \n- // BUGFIX: Gecko - missing readystatechange calls in synchronous requests\n- if (bGecko && !oRequest._async) {\n- oRequest.readyState = cXMLHttpRequest.OPENED;\n+ if (this.id == null) {\n \n- // Synchronize state\n- fSynchronizeValues(oRequest);\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n \n- // Simulate missing states\n- while (oRequest.readyState < cXMLHttpRequest.DONE) {\n- oRequest.readyState++;\n- fReadyStateChange(oRequest);\n- // Check if we are aborted\n- if (oRequest._aborted)\n- return;\n- }\n- }\n- };\n- cXMLHttpRequest.prototype.send = function(vData) {\n- // Add method sniffer\n- if (cXMLHttpRequest.onsend)\n- cXMLHttpRequest.onsend.apply(this, arguments);\n+ this.div = OpenLayers.Util.createDiv(this.id);\n+ this.div.style.width = \"100%\";\n+ this.div.style.height = \"100%\";\n+ this.div.dir = \"ltr\";\n \n- if (!arguments.length)\n- vData = null;\n+ this.events = new OpenLayers.Events(this, this.div);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n+ }\n \n- // BUGFIX: Safari - fails sending documents created/modified dynamically, so an explicit serialization required\n- // BUGFIX: IE - rewrites any custom mime-type to \"text/xml\" in case an XMLNode is sent\n- // BUGFIX: Gecko - fails sending Element (this is up to the implementation either to standard)\n- if (vData && vData.nodeType) {\n- vData = window.XMLSerializer ? new window.XMLSerializer().serializeToString(vData) : vData.xml;\n- if (!this._headers[\"Content-Type\"])\n- this._object.setRequestHeader(\"Content-Type\", \"application/xml\");\n }\n+ },\n \n- this._data = vData;\n- /*\n- // Add to queue\n- if (this._async)\n- fQueue_add(this);\n- else*/\n- fXMLHttpRequest_send(this);\n- };\n- cXMLHttpRequest.prototype.abort = function() {\n- // Add method sniffer\n- if (cXMLHttpRequest.onabort)\n- cXMLHttpRequest.onabort.apply(this, arguments);\n-\n- // BUGFIX: Gecko - unnecessary DONE when aborting\n- if (this.readyState > cXMLHttpRequest.UNSENT)\n- this._aborted = true;\n-\n- this._object.abort();\n-\n- // BUGFIX: IE - memory leak\n- fCleanTransport(this);\n-\n- this.readyState = cXMLHttpRequest.UNSENT;\n-\n- delete this._data;\n- /* if (this._async)\n- fQueue_remove(this);*/\n- };\n- cXMLHttpRequest.prototype.getAllResponseHeaders = function() {\n- return this._object.getAllResponseHeaders();\n- };\n- cXMLHttpRequest.prototype.getResponseHeader = function(sName) {\n- return this._object.getResponseHeader(sName);\n- };\n- cXMLHttpRequest.prototype.setRequestHeader = function(sName, sValue) {\n- // BUGFIX: IE - cache issue\n- if (!this._headers)\n- this._headers = {};\n- this._headers[sName] = sValue;\n-\n- return this._object.setRequestHeader(sName, sValue);\n- };\n-\n- // EventTarget interface implementation\n- cXMLHttpRequest.prototype.addEventListener = function(sName, fHandler, bUseCapture) {\n- for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n- if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n- return;\n- // Add listener\n- this._listeners.push([sName, fHandler, bUseCapture]);\n- };\n-\n- cXMLHttpRequest.prototype.removeEventListener = function(sName, fHandler, bUseCapture) {\n- for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n- if (oListener[0] == sName && oListener[1] == fHandler && oListener[2] == bUseCapture)\n- break;\n- // Remove listener\n- if (oListener)\n- this._listeners.splice(nIndex, 1);\n- };\n-\n- cXMLHttpRequest.prototype.dispatchEvent = function(oEvent) {\n- var oEventPseudo = {\n- 'type': oEvent.type,\n- 'target': this,\n- 'currentTarget': this,\n- 'eventPhase': 2,\n- 'bubbles': oEvent.bubbles,\n- 'cancelable': oEvent.cancelable,\n- 'timeStamp': oEvent.timeStamp,\n- 'stopPropagation': function() {}, // There is no flow\n- 'preventDefault': function() {}, // There is no default action\n- 'initEvent': function() {} // Original event object should be initialized\n- };\n-\n- // Execute onreadystatechange\n- if (oEventPseudo.type == \"readystatechange\" && this.onreadystatechange)\n- (this.onreadystatechange.handleEvent || this.onreadystatechange).apply(this, [oEventPseudo]);\n-\n- // Execute listeners\n- for (var nIndex = 0, oListener; oListener = this._listeners[nIndex]; nIndex++)\n- if (oListener[0] == oEventPseudo.type && !oListener[2])\n- (oListener[1].handleEvent || oListener[1]).apply(this, [oEventPseudo]);\n- };\n-\n- //\n- cXMLHttpRequest.prototype.toString = function() {\n- return '[' + \"object\" + ' ' + \"XMLHttpRequest\" + ']';\n- };\n-\n- cXMLHttpRequest.toString = function() {\n- return '[' + \"XMLHttpRequest\" + ']';\n- };\n-\n- // Helper function\n- function fReadyStateChange(oRequest) {\n- // Sniffing code\n- if (cXMLHttpRequest.onreadystatechange)\n- cXMLHttpRequest.onreadystatechange.apply(oRequest);\n-\n- // Fake event\n- oRequest.dispatchEvent({\n- 'type': \"readystatechange\",\n- 'bubbles': false,\n- 'cancelable': false,\n- 'timeStamp': new Date + 0\n- });\n- };\n-\n- function fGetDocument(oRequest) {\n- var oDocument = oRequest.responseXML,\n- sResponse = oRequest.responseText;\n- // Try parsing responseText\n- if (bIE && sResponse && oDocument && !oDocument.documentElement && oRequest.getResponseHeader(\"Content-Type\").match(/[^\\/]+\\/[^\\+]+\\+xml/)) {\n- oDocument = new window.ActiveXObject(\"Microsoft.XMLDOM\");\n- oDocument.async = false;\n- oDocument.validateOnParse = false;\n- oDocument.loadXML(sResponse);\n+ /**\n+ * Method: destroy\n+ * Destroy is a destructor: this is to alleviate cyclic references which\n+ * the Javascript garbage cleaner can not take care of on its own.\n+ *\n+ * Parameters:\n+ * setNewBaseLayer - {Boolean} Set a new base layer when this layer has\n+ * been destroyed. Default is true.\n+ */\n+ destroy: function(setNewBaseLayer) {\n+ if (setNewBaseLayer == null) {\n+ setNewBaseLayer = true;\n }\n- // Check if there is no error in document\n- if (oDocument)\n- if ((bIE && oDocument.parseError != 0) || !oDocument.documentElement || (oDocument.documentElement && oDocument.documentElement.tagName == \"parsererror\"))\n- return null;\n- return oDocument;\n- };\n-\n- function fSynchronizeValues(oRequest) {\n- try {\n- oRequest.responseText = oRequest._object.responseText;\n- } catch (e) {}\n- try {\n- oRequest.responseXML = fGetDocument(oRequest._object);\n- } catch (e) {}\n- try {\n- oRequest.status = oRequest._object.status;\n- } catch (e) {}\n- try {\n- oRequest.statusText = oRequest._object.statusText;\n- } catch (e) {}\n- };\n-\n- function fCleanTransport(oRequest) {\n- // BUGFIX: IE - memory leak (on-page leak)\n- oRequest._object.onreadystatechange = new window.Function;\n- };\n- /*\n- // Queue manager\n- var oQueuePending = {\"CRITICAL\":[],\"HIGH\":[],\"NORMAL\":[],\"LOW\":[],\"LOWEST\":[]},\n- aQueueRunning = [];\n- function fQueue_add(oRequest) {\n- oQueuePending[oRequest.priority in oQueuePending ? oRequest.priority : \"NORMAL\"].push(oRequest);\n- //\n- setTimeout(fQueue_process);\n- };\n-\n- function fQueue_remove(oRequest) {\n- for (var nIndex = 0, bFound = false; nIndex < aQueueRunning.length; nIndex++)\n- if (bFound)\n- aQueueRunning[nIndex - 1] = aQueueRunning[nIndex];\n- else\n- if (aQueueRunning[nIndex] == oRequest)\n- bFound = true;\n- if (bFound)\n- aQueueRunning.length--;\n- //\n- setTimeout(fQueue_process);\n- };\n+ if (this.map != null) {\n+ this.map.removeLayer(this, setNewBaseLayer);\n+ }\n+ this.projection = null;\n+ this.map = null;\n+ this.name = null;\n+ this.div = null;\n+ this.options = null;\n \n- function fQueue_process() {\n- if (aQueueRunning.length < 6) {\n- for (var sPriority in oQueuePending) {\n- if (oQueuePending[sPriority].length) {\n- var oRequest = oQueuePending[sPriority][0];\n- oQueuePending[sPriority] = oQueuePending[sPriority].slice(1);\n- //\n- aQueueRunning.push(oRequest);\n- // Send request\n- fXMLHttpRequest_send(oRequest);\n- break;\n- }\n- }\n+ if (this.events) {\n+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n }\n- };\n- */\n- // Internet Explorer 5.0 (missing apply)\n- if (!window.Function.prototype.apply) {\n- window.Function.prototype.apply = function(oRequest, oArguments) {\n- if (!oArguments)\n- oArguments = [];\n- oRequest.__func = this;\n- oRequest.__func(oArguments[0], oArguments[1], oArguments[2], oArguments[3], oArguments[4]);\n- delete oRequest.__func;\n- };\n- };\n+ this.events.destroy();\n+ }\n+ this.eventListeners = null;\n+ this.events = null;\n+ },\n \n- // Register new object with window\n /**\n- * Class: OpenLayers.Request.XMLHttpRequest\n- * Standard-compliant (W3C) cross-browser implementation of the\n- * XMLHttpRequest object. From\n- * http://code.google.com/p/xmlhttprequest/.\n+ * Method: clone\n+ *\n+ * Parameters:\n+ * obj - {} The layer to be cloned\n+ *\n+ * Returns:\n+ * {} An exact clone of this \n */\n- if (!OpenLayers.Request) {\n- /**\n- * This allows for OpenLayers/Request.js to be included\n- * before or after this script.\n- */\n- OpenLayers.Request = {};\n- }\n- OpenLayers.Request.XMLHttpRequest = cXMLHttpRequest;\n-})();\n-/* ======================================================================\n- OpenLayers/Request.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ clone: function(obj) {\n \n-/**\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Request/XMLHttpRequest.js\n- */\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer(this.name, this.getOptions());\n+ }\n \n-/**\n- * TODO: deprecate me\n- * Use OpenLayers.Request.proxy instead.\n- */\n-OpenLayers.ProxyHost = \"\";\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(obj, this);\n \n-/**\n- * Namespace: OpenLayers.Request\n- * The OpenLayers.Request namespace contains convenience methods for working\n- * with XMLHttpRequests. These methods work with a cross-browser\n- * W3C compliant class.\n- */\n-if (!OpenLayers.Request) {\n- /**\n- * This allows for OpenLayers/Request/XMLHttpRequest.js to be included\n- * before or after this script.\n- */\n- OpenLayers.Request = {};\n-}\n-OpenLayers.Util.extend(OpenLayers.Request, {\n+ // a cloned layer should never have its map property set\n+ // because it has not been added to a map yet. \n+ obj.map = null;\n \n- /**\n- * Constant: DEFAULT_CONFIG\n- * {Object} Default configuration for all requests.\n- */\n- DEFAULT_CONFIG: {\n- method: \"GET\",\n- url: window.location.href,\n- async: true,\n- user: undefined,\n- password: undefined,\n- params: null,\n- proxy: OpenLayers.ProxyHost,\n- headers: {},\n- data: null,\n- callback: function() {},\n- success: null,\n- failure: null,\n- scope: null\n+ return obj;\n },\n \n /**\n- * Constant: URL_SPLIT_REGEX\n- */\n- URL_SPLIT_REGEX: /([^:]*:)\\/\\/([^:]*:?[^@]*@)?([^:\\/\\?]*):?([^\\/\\?]*)/,\n-\n- /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the {} object.\n- *\n- * All event listeners will receive an event object with three properties:\n- * request - {} The request object.\n- * config - {Object} The config object sent to the specific request method.\n- * requestUrl - {String} The request url.\n+ * Method: getOptions\n+ * Extracts an object from the layer with the properties that were set as\n+ * options, but updates them with the values currently set on the\n+ * instance.\n * \n- * Supported event types:\n- * complete - Triggered when we have a response from the request, if a\n- * listener returns false, no further response processing will take\n- * place.\n- * success - Triggered when the HTTP response has a success code (200-299).\n- * failure - Triggered when the HTTP response does not have a success code.\n+ * Returns:\n+ * {Object} the of the layer, representing the current state.\n */\n- events: new OpenLayers.Events(this),\n+ getOptions: function() {\n+ var options = {};\n+ for (var o in this.options) {\n+ options[o] = this[o];\n+ }\n+ return options;\n+ },\n \n- /**\n- * Method: makeSameOrigin\n- * Using the specified proxy, returns a same origin url of the provided url.\n+ /** \n+ * APIMethod: setName\n+ * Sets the new layer name for this layer. Can trigger a changelayer event\n+ * on the map.\n *\n * Parameters:\n- * url - {String} An arbitrary url\n- * proxy {String|Function} The proxy to use to make the provided url a\n- * same origin url.\n- *\n- * Returns\n- * {String} the same origin url. If no proxy is provided, the returned url\n- * will be the same as the provided url.\n+ * newName - {String} The new name.\n */\n- makeSameOrigin: function(url, proxy) {\n- var sameOrigin = url.indexOf(\"http\") !== 0;\n- var urlParts = !sameOrigin && url.match(this.URL_SPLIT_REGEX);\n- if (urlParts) {\n- var location = window.location;\n- sameOrigin =\n- urlParts[1] == location.protocol &&\n- urlParts[3] == location.hostname;\n- var uPort = urlParts[4],\n- lPort = location.port;\n- if (uPort != 80 && uPort != \"\" || lPort != \"80\" && lPort != \"\") {\n- sameOrigin = sameOrigin && uPort == lPort;\n- }\n- }\n- if (!sameOrigin) {\n- if (proxy) {\n- if (typeof proxy == \"function\") {\n- url = proxy(url);\n- } else {\n- url = proxy + encodeURIComponent(url);\n- }\n+ setName: function(newName) {\n+ if (newName != this.name) {\n+ this.name = newName;\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"name\"\n+ });\n }\n }\n- return url;\n },\n \n /**\n- * APIMethod: issue\n- * Create a new XMLHttpRequest object, open it, set any headers, bind\n- * a callback to done state, and send any data. It is recommended that\n- * you use one , , , , , or .\n- * This method is only documented to provide detail on the configuration\n- * options available to all request methods.\n- *\n+ * APIMethod: addOptions\n+ * \n * Parameters:\n- * config - {Object} Object containing properties for configuring the\n- * request. Allowed configuration properties are described below.\n- * This object is modified and should not be reused.\n- *\n- * Allowed config properties:\n- * method - {String} One of GET, POST, PUT, DELETE, HEAD, or\n- * OPTIONS. Default is GET.\n- * url - {String} URL for the request.\n- * async - {Boolean} Open an asynchronous request. Default is true.\n- * user - {String} User for relevant authentication scheme. Set\n- * to null to clear current user.\n- * password - {String} Password for relevant authentication scheme.\n- * Set to null to clear current password.\n- * proxy - {String} Optional proxy. Defaults to\n- * .\n- * params - {Object} Any key:value pairs to be appended to the\n- * url as a query string. Assumes url doesn't already include a query\n- * string or hash. Typically, this is only appropriate for \n- * requests where the query string will be appended to the url.\n- * Parameter values that are arrays will be\n- * concatenated with a comma (note that this goes against form-encoding)\n- * as is done with .\n- * headers - {Object} Object with header:value pairs to be set on\n- * the request.\n- * data - {String | Document} Optional data to send with the request.\n- * Typically, this is only used with and requests.\n- * Make sure to provide the appropriate \"Content-Type\" header for your\n- * data. For and requests, the content type defaults to\n- * \"application-xml\". If your data is a different content type, or\n- * if you are using a different HTTP method, set the \"Content-Type\"\n- * header to match your data type.\n- * callback - {Function} Function to call when request is done.\n- * To determine if the request failed, check request.status (200\n- * indicates success).\n- * success - {Function} Optional function to call if request status is in\n- * the 200s. This will be called in addition to callback above and\n- * would typically only be used as an alternative.\n- * failure - {Function} Optional function to call if request status is not\n- * in the 200s. This will be called in addition to callback above and\n- * would typically only be used as an alternative.\n- * scope - {Object} If callback is a public method on some object,\n- * set the scope to that object.\n- *\n- * Returns:\n- * {XMLHttpRequest} Request object. To abort the request before a response\n- * is received, call abort() on the request object.\n+ * newOptions - {Object}\n+ * reinitialize - {Boolean} If set to true, and if resolution options of the\n+ * current baseLayer were changed, the map will be recentered to make\n+ * sure that it is displayed with a valid resolution, and a\n+ * changebaselayer event will be triggered.\n */\n- issue: function(config) {\n- // apply default config - proxy host may have changed\n- var defaultConfig = OpenLayers.Util.extend(\n- this.DEFAULT_CONFIG, {\n- proxy: OpenLayers.ProxyHost\n+ addOptions: function(newOptions, reinitialize) {\n+\n+ if (this.options == null) {\n+ this.options = {};\n+ }\n+\n+ if (newOptions) {\n+ // make sure this.projection references a projection object\n+ if (typeof newOptions.projection == \"string\") {\n+ newOptions.projection = new OpenLayers.Projection(newOptions.projection);\n }\n- );\n- config = config || {};\n- config.headers = config.headers || {};\n- config = OpenLayers.Util.applyDefaults(config, defaultConfig);\n- config.headers = OpenLayers.Util.applyDefaults(config.headers, defaultConfig.headers);\n- // Always set the \"X-Requested-With\" header to signal that this request\n- // was issued through the XHR-object. Since header keys are case \n- // insensitive and we want to allow overriding of the \"X-Requested-With\"\n- // header through the user we cannot use applyDefaults, but have to \n- // check manually whether we were called with a \"X-Requested-With\"\n- // header.\n- var customRequestedWithHeader = false,\n- headerKey;\n- for (headerKey in config.headers) {\n- if (config.headers.hasOwnProperty(headerKey)) {\n- if (headerKey.toLowerCase() === 'x-requested-with') {\n- customRequestedWithHeader = true;\n- }\n+ if (newOptions.projection) {\n+ // get maxResolution, units and maxExtent from projection defaults if\n+ // they are not defined already\n+ OpenLayers.Util.applyDefaults(newOptions,\n+ OpenLayers.Projection.defaults[newOptions.projection.getCode()]);\n+ }\n+ // allow array for extents\n+ if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {\n+ newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);\n+ }\n+ if (newOptions.minExtent && !(newOptions.minExtent instanceof OpenLayers.Bounds)) {\n+ newOptions.minExtent = new OpenLayers.Bounds(newOptions.minExtent);\n }\n- }\n- if (customRequestedWithHeader === false) {\n- // we did not have a custom \"X-Requested-With\" header\n- config.headers['X-Requested-With'] = 'XMLHttpRequest';\n }\n \n- // create request, open, and set headers\n- var request = new OpenLayers.Request.XMLHttpRequest();\n- var url = OpenLayers.Util.urlAppend(config.url,\n- OpenLayers.Util.getParameterString(config.params || {}));\n- url = OpenLayers.Request.makeSameOrigin(url, config.proxy);\n- request.open(\n- config.method, url, config.async, config.user, config.password\n- );\n- for (var header in config.headers) {\n- request.setRequestHeader(header, config.headers[header]);\n- }\n+ // update our copy for clone\n+ OpenLayers.Util.extend(this.options, newOptions);\n \n- var events = this.events;\n+ // add new options to this\n+ OpenLayers.Util.extend(this, newOptions);\n \n- // we want to execute runCallbacks with \"this\" as the\n- // execution scope\n- var self = this;\n+ // get the units from the projection, if we have a projection\n+ // and it it has units\n+ if (this.projection && this.projection.getUnits()) {\n+ this.units = this.projection.getUnits();\n+ }\n \n- request.onreadystatechange = function() {\n- if (request.readyState == OpenLayers.Request.XMLHttpRequest.DONE) {\n- var proceed = events.triggerEvent(\n- \"complete\", {\n- request: request,\n- config: config,\n- requestUrl: url\n+ // re-initialize resolutions if necessary, i.e. if any of the\n+ // properties of the \"properties\" array defined below is set\n+ // in the new options\n+ if (this.map) {\n+ // store current resolution so we can try to restore it later\n+ var resolution = this.map.getResolution();\n+ var properties = this.RESOLUTION_PROPERTIES.concat(\n+ [\"projection\", \"units\", \"minExtent\", \"maxExtent\"]\n+ );\n+ for (var o in newOptions) {\n+ if (newOptions.hasOwnProperty(o) &&\n+ OpenLayers.Util.indexOf(properties, o) >= 0) {\n+\n+ this.initResolutions();\n+ if (reinitialize && this.map.baseLayer === this) {\n+ // update map position, and restore previous resolution\n+ this.map.setCenter(this.map.getCenter(),\n+ this.map.getZoomForResolution(resolution),\n+ false, true\n+ );\n+ // trigger a changebaselayer event to make sure that\n+ // all controls (especially\n+ // OpenLayers.Control.PanZoomBar) get notified of the\n+ // new options\n+ this.map.events.triggerEvent(\"changebaselayer\", {\n+ layer: this\n+ });\n }\n- );\n- if (proceed !== false) {\n- self.runCallbacks({\n- request: request,\n- config: config,\n- requestUrl: url\n- });\n+ break;\n }\n }\n- };\n-\n- // send request (optionally with data) and return\n- // call in a timeout for asynchronous requests so the return is\n- // available before readyState == 4 for cached docs\n- if (config.async === false) {\n- request.send(config.data);\n- } else {\n- window.setTimeout(function() {\n- if (request.readyState !== 0) { // W3C: 0-UNSENT\n- request.send(config.data);\n- }\n- }, 0);\n }\n- return request;\n },\n \n /**\n- * Method: runCallbacks\n- * Calls the complete, success and failure callbacks. Application\n- * can listen to the \"complete\" event, have the listener \n- * display a confirm window and always return false, and\n- * execute OpenLayers.Request.runCallbacks if the user\n- * hits \"yes\" in the confirm window.\n- *\n- * Parameters:\n- * options - {Object} Hash containing request, config and requestUrl keys\n+ * APIMethod: onMapResize\n+ * This function can be implemented by subclasses\n */\n- runCallbacks: function(options) {\n- var request = options.request;\n- var config = options.config;\n-\n- // bind callbacks to readyState 4 (done)\n- var complete = (config.scope) ?\n- OpenLayers.Function.bind(config.callback, config.scope) :\n- config.callback;\n+ onMapResize: function() {\n+ //this function can be implemented by subclasses \n+ },\n \n- // optional success callback\n- var success;\n- if (config.success) {\n- success = (config.scope) ?\n- OpenLayers.Function.bind(config.success, config.scope) :\n- config.success;\n- }\n+ /**\n+ * APIMethod: redraw\n+ * Redraws the layer. Returns true if the layer was redrawn, false if not.\n+ *\n+ * Returns:\n+ * {Boolean} The layer was redrawn.\n+ */\n+ redraw: function() {\n+ var redrawn = false;\n+ if (this.map) {\n \n- // optional failure callback\n- var failure;\n- if (config.failure) {\n- failure = (config.scope) ?\n- OpenLayers.Function.bind(config.failure, config.scope) :\n- config.failure;\n- }\n+ // min/max Range may have changed\n+ this.inRange = this.calculateInRange();\n \n- if (OpenLayers.Util.createUrlObject(config.url).protocol == \"file:\" &&\n- request.responseText) {\n- request.status = 200;\n- }\n- complete(request);\n+ // map's center might not yet be set\n+ var extent = this.getExtent();\n \n- if (!request.status || (request.status >= 200 && request.status < 300)) {\n- this.events.triggerEvent(\"success\", options);\n- if (success) {\n- success(request);\n- }\n- }\n- if (request.status && (request.status < 200 || request.status >= 300)) {\n- this.events.triggerEvent(\"failure\", options);\n- if (failure) {\n- failure(request);\n+ if (extent && this.inRange && this.visibility) {\n+ var zoomChanged = true;\n+ this.moveTo(extent, zoomChanged, false);\n+ this.events.triggerEvent(\"moveend\", {\n+ \"zoomChanged\": zoomChanged\n+ });\n+ redrawn = true;\n }\n }\n+ return redrawn;\n },\n \n /**\n- * APIMethod: GET\n- * Send an HTTP GET request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to GET.\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * Method: moveTo\n * \n- * Returns:\n- * {XMLHttpRequest} Request object.\n+ * Parameters:\n+ * bounds - {}\n+ * zoomChanged - {Boolean} Tells when zoom has changed, as layers have to\n+ * do some init work in that case.\n+ * dragging - {Boolean}\n */\n- GET: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"GET\"\n- });\n- return OpenLayers.Request.issue(config);\n+ moveTo: function(bounds, zoomChanged, dragging) {\n+ var display = this.visibility;\n+ if (!this.isBaseLayer) {\n+ display = display && this.inRange;\n+ }\n+ this.display(display);\n },\n \n /**\n- * APIMethod: POST\n- * Send a POST request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to POST and \"Content-Type\" header set to \"application/xml\".\n+ * Method: moveByPx\n+ * Move the layer based on pixel vector. To be implemented by subclasses.\n *\n * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties. The\n- * default \"Content-Type\" header will be set to \"application-xml\" if\n- * none is provided. This object is modified and should not be reused.\n+ * dx - {Number} The x coord of the displacement vector.\n+ * dy - {Number} The y coord of the displacement vector.\n+ */\n+ moveByPx: function(dx, dy) {},\n+\n+ /**\n+ * Method: setMap\n+ * Set the map property for the layer. This is done through an accessor\n+ * so that subclasses can override this and take special action once \n+ * they have their map variable set. \n * \n- * Returns:\n- * {XMLHttpRequest} Request object.\n+ * Here we take care to bring over any of the necessary default \n+ * properties from the map. \n+ * \n+ * Parameters:\n+ * map - {}\n */\n- POST: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"POST\"\n- });\n- // set content type to application/xml if it isn't already set\n- config.headers = config.headers ? config.headers : {};\n- if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n- config.headers[\"Content-Type\"] = \"application/xml\";\n+ setMap: function(map) {\n+ if (this.map == null) {\n+\n+ this.map = map;\n+\n+ // grab some essential layer data from the map if it hasn't already\n+ // been set\n+ this.maxExtent = this.maxExtent || this.map.maxExtent;\n+ this.minExtent = this.minExtent || this.map.minExtent;\n+\n+ this.projection = this.projection || this.map.projection;\n+ if (typeof this.projection == \"string\") {\n+ this.projection = new OpenLayers.Projection(this.projection);\n+ }\n+\n+ // Check the projection to see if we can get units -- if not, refer\n+ // to properties.\n+ this.units = this.projection.getUnits() ||\n+ this.units || this.map.units;\n+\n+ this.initResolutions();\n+\n+ if (!this.isBaseLayer) {\n+ this.inRange = this.calculateInRange();\n+ var show = ((this.visibility) && (this.inRange));\n+ this.div.style.display = show ? \"\" : \"none\";\n+ }\n+\n+ // deal with gutters\n+ this.setTileSize();\n }\n- return OpenLayers.Request.issue(config);\n },\n \n /**\n- * APIMethod: PUT\n- * Send an HTTP PUT request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to PUT and \"Content-Type\" header set to \"application/xml\".\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties. The\n- * default \"Content-Type\" header will be set to \"application-xml\" if\n- * none is provided. This object is modified and should not be reused.\n+ * Method: afterAdd\n+ * Called at the end of the map.addLayer sequence. At this point, the map\n+ * will have a base layer. To be overridden by subclasses.\n+ */\n+ afterAdd: function() {},\n+\n+ /**\n+ * APIMethod: removeMap\n+ * Just as setMap() allows each layer the possibility to take a \n+ * personalized action on being added to the map, removeMap() allows\n+ * each layer to take a personalized action on being removed from it. \n+ * For now, this will be mostly unused, except for the EventPane layer,\n+ * which needs this hook so that it can remove the special invisible\n+ * pane. \n * \n- * Returns:\n- * {XMLHttpRequest} Request object.\n+ * Parameters:\n+ * map - {}\n */\n- PUT: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"PUT\"\n- });\n- // set content type to application/xml if it isn't already set\n- config.headers = config.headers ? config.headers : {};\n- if (!(\"CONTENT-TYPE\" in OpenLayers.Util.upperCaseObject(config.headers))) {\n- config.headers[\"Content-Type\"] = \"application/xml\";\n- }\n- return OpenLayers.Request.issue(config);\n+ removeMap: function(map) {\n+ //to be overridden by subclasses\n },\n \n /**\n- * APIMethod: DELETE\n- * Send an HTTP DELETE request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to DELETE.\n+ * APIMethod: getImageSize\n *\n * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * bounds - {} optional tile bounds, can be used\n+ * by subclasses that have to deal with different tile sizes at the\n+ * layer extent edges (e.g. Zoomify)\n * \n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {} The size that the image should be, taking into \n+ * account gutters.\n */\n- DELETE: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"DELETE\"\n- });\n- return OpenLayers.Request.issue(config);\n+ getImageSize: function(bounds) {\n+ return (this.imageSize || this.tileSize);\n },\n \n /**\n- * APIMethod: HEAD\n- * Send an HTTP HEAD request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to HEAD.\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * APIMethod: setTileSize\n+ * Set the tile size based on the map size. This also sets layer.imageSize\n+ * or use by Tile.Image.\n * \n- * Returns:\n- * {XMLHttpRequest} Request object.\n+ * Parameters:\n+ * size - {}\n */\n- HEAD: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"HEAD\"\n- });\n- return OpenLayers.Request.issue(config);\n+ setTileSize: function(size) {\n+ var tileSize = (size) ? size :\n+ ((this.tileSize) ? this.tileSize :\n+ this.map.getTileSize());\n+ this.tileSize = tileSize;\n+ if (this.gutter) {\n+ // layers with gutters need non-null tile sizes\n+ //if(tileSize == null) {\n+ // OpenLayers.console.error(\"Error in layer.setMap() for \" +\n+ // this.name + \": layers with \" +\n+ // \"gutters need non-null tile sizes\");\n+ //}\n+ this.imageSize = new OpenLayers.Size(tileSize.w + (2 * this.gutter),\n+ tileSize.h + (2 * this.gutter));\n+ }\n },\n \n /**\n- * APIMethod: OPTIONS\n- * Send an HTTP OPTIONS request. Additional configuration properties are\n- * documented in the method, with the method property set\n- * to OPTIONS.\n- *\n- * Parameters:\n- * config - {Object} Object with properties for configuring the request.\n- * See the method for documentation of allowed properties.\n- * This object is modified and should not be reused.\n+ * APIMethod: getVisibility\n * \n * Returns:\n- * {XMLHttpRequest} Request object.\n+ * {Boolean} The layer should be displayed (if in range).\n */\n- OPTIONS: function(config) {\n- config = OpenLayers.Util.extend(config, {\n- method: \"OPTIONS\"\n- });\n- return OpenLayers.Request.issue(config);\n- }\n-\n-});\n-/* ======================================================================\n- OpenLayers/Control.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Control\n- * Controls affect the display or behavior of the map. They allow everything\n- * from panning and zooming to displaying a scale indicator. Controls by \n- * default are added to the map they are contained within however it is\n- * possible to add a control to an external div by passing the div in the\n- * options parameter.\n- * \n- * Example:\n- * The following example shows how to add many of the common controls\n- * to a map.\n- * \n- * > var map = new OpenLayers.Map('map', { controls: [] });\n- * >\n- * > map.addControl(new OpenLayers.Control.PanZoomBar());\n- * > map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));\n- * > map.addControl(new OpenLayers.Control.Permalink());\n- * > map.addControl(new OpenLayers.Control.Permalink('permalink'));\n- * > map.addControl(new OpenLayers.Control.MousePosition());\n- * > map.addControl(new OpenLayers.Control.OverviewMap());\n- * > map.addControl(new OpenLayers.Control.KeyboardDefaults());\n- *\n- * The next code fragment is a quick example of how to intercept \n- * shift-mouse click to display the extent of the bounding box\n- * dragged out by the user. Usually controls are not created\n- * in exactly this manner. See the source for a more complete \n- * example:\n- *\n- * > var control = new OpenLayers.Control();\n- * > OpenLayers.Util.extend(control, {\n- * > draw: function () {\n- * > // this Handler.Box will intercept the shift-mousedown\n- * > // before Control.MouseDefault gets to see it\n- * > this.box = new OpenLayers.Handler.Box( control, \n- * > {\"done\": this.notice},\n- * > {keyMask: OpenLayers.Handler.MOD_SHIFT});\n- * > this.box.activate();\n- * > },\n- * >\n- * > notice: function (bounds) {\n- * > OpenLayers.Console.userError(bounds);\n- * > }\n- * > }); \n- * > map.addControl(control);\n- * \n- */\n-OpenLayers.Control = OpenLayers.Class({\n+ getVisibility: function() {\n+ return this.visibility;\n+ },\n \n /** \n- * Property: id \n- * {String} \n+ * APIMethod: setVisibility\n+ * Set the visibility flag for the layer and hide/show & redraw \n+ * accordingly. Fire event unless otherwise specified\n+ * \n+ * Note that visibility is no longer simply whether or not the layer's\n+ * style.display is set to \"block\". Now we store a 'visibility' state \n+ * property on the layer class, this allows us to remember whether or \n+ * not we *desire* for a layer to be visible. In the case where the \n+ * map's resolution is out of the layer's range, this desire may be \n+ * subverted.\n+ * \n+ * Parameters:\n+ * visibility - {Boolean} Whether or not to display the layer (if in range)\n */\n- id: null,\n+ setVisibility: function(visibility) {\n+ if (visibility != this.visibility) {\n+ this.visibility = visibility;\n+ this.display(visibility);\n+ this.redraw();\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"visibility\"\n+ });\n+ }\n+ this.events.triggerEvent(\"visibilitychanged\");\n+ }\n+ },\n \n /** \n- * Property: map \n- * {} this gets set in the addControl() function in\n- * OpenLayers.Map \n+ * APIMethod: display\n+ * Hide or show the Layer. This is designed to be used internally, and \n+ * is not generally the way to enable or disable the layer. For that,\n+ * use the setVisibility function instead..\n+ * \n+ * Parameters:\n+ * display - {Boolean}\n */\n- map: null,\n+ display: function(display) {\n+ if (display != (this.div.style.display != \"none\")) {\n+ this.div.style.display = (display && this.calculateInRange()) ? \"block\" : \"none\";\n+ }\n+ },\n \n- /** \n- * APIProperty: div \n- * {DOMElement} The element that contains the control, if not present the \n- * control is placed inside the map.\n+ /**\n+ * APIMethod: calculateInRange\n+ * \n+ * Returns:\n+ * {Boolean} The layer is displayable at the current map's current\n+ * resolution. Note that if 'alwaysInRange' is true for the layer, \n+ * this function will always return true.\n */\n- div: null,\n+ calculateInRange: function() {\n+ var inRange = false;\n \n- /** \n- * APIProperty: type \n- * {Number} Controls can have a 'type'. The type determines the type of\n- * interactions which are possible with them when they are placed in an\n- * . \n- */\n- type: null,\n+ if (this.alwaysInRange) {\n+ inRange = true;\n+ } else {\n+ if (this.map) {\n+ var resolution = this.map.getResolution();\n+ inRange = ((resolution >= this.minResolution) &&\n+ (resolution <= this.maxResolution));\n+ }\n+ }\n+ return inRange;\n+ },\n \n /** \n- * Property: allowSelection\n- * {Boolean} By default, controls do not allow selection, because\n- * it may interfere with map dragging. If this is true, OpenLayers\n- * will not prevent selection of the control.\n- * Default is false.\n+ * APIMethod: setIsBaseLayer\n+ * \n+ * Parameters:\n+ * isBaseLayer - {Boolean}\n */\n- allowSelection: false,\n+ setIsBaseLayer: function(isBaseLayer) {\n+ if (isBaseLayer != this.isBaseLayer) {\n+ this.isBaseLayer = isBaseLayer;\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changebaselayer\", {\n+ layer: this\n+ });\n+ }\n+ }\n+ },\n+\n+ /********************************************************/\n+ /* */\n+ /* Baselayer Functions */\n+ /* */\n+ /********************************************************/\n \n /** \n- * Property: displayClass \n- * {string} This property is used for CSS related to the drawing of the\n- * Control. \n+ * Method: initResolutions\n+ * This method's responsibility is to set up the 'resolutions' array \n+ * for the layer -- this array is what the layer will use to interface\n+ * between the zoom levels of the map and the resolution display \n+ * of the layer.\n+ * \n+ * The user has several options that determine how the array is set up.\n+ * \n+ * For a detailed explanation, see the following wiki from the \n+ * openlayers.org homepage:\n+ * http://trac.openlayers.org/wiki/SettingZoomLevels\n */\n- displayClass: \"\",\n+ initResolutions: function() {\n \n- /**\n- * APIProperty: title \n- * {string} This property is used for showing a tooltip over the \n- * Control. \n- */\n- title: \"\",\n+ // ok we want resolutions, here's our strategy:\n+ //\n+ // 1. if resolutions are defined in the layer config, use them\n+ // 2. else, if scales are defined in the layer config then derive\n+ // resolutions from these scales\n+ // 3. else, attempt to calculate resolutions from maxResolution,\n+ // minResolution, numZoomLevels, maxZoomLevel set in the\n+ // layer config\n+ // 4. if we still don't have resolutions, and if resolutions\n+ // are defined in the same, use them\n+ // 5. else, if scales are defined in the map then derive\n+ // resolutions from these scales\n+ // 6. else, attempt to calculate resolutions from maxResolution,\n+ // minResolution, numZoomLevels, maxZoomLevel set in the\n+ // map\n+ // 7. hope for the best!\n \n- /**\n- * APIProperty: autoActivate\n- * {Boolean} Activate the control when it is added to a map. Default is\n- * false.\n- */\n- autoActivate: false,\n+ var i, len, p;\n+ var props = {},\n+ alwaysInRange = true;\n \n- /** \n- * APIProperty: active \n- * {Boolean} The control is active (read-only). Use and \n- * to change control state.\n- */\n- active: null,\n+ // get resolution data from layer config\n+ // (we also set alwaysInRange in the layer as appropriate)\n+ for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n+ p = this.RESOLUTION_PROPERTIES[i];\n+ props[p] = this.options[p];\n+ if (alwaysInRange && this.options[p]) {\n+ alwaysInRange = false;\n+ }\n+ }\n+ if (this.options.alwaysInRange == null) {\n+ this.alwaysInRange = alwaysInRange;\n+ }\n \n- /**\n- * Property: handlerOptions\n- * {Object} Used to set non-default properties on the control's handler\n- */\n- handlerOptions: null,\n+ // if we don't have resolutions then attempt to derive them from scales\n+ if (props.resolutions == null) {\n+ props.resolutions = this.resolutionsFromScales(props.scales);\n+ }\n \n- /** \n- * Property: handler \n- * {} null\n- */\n- handler: null,\n+ // if we still don't have resolutions then attempt to calculate them\n+ if (props.resolutions == null) {\n+ props.resolutions = this.calculateResolutions(props);\n+ }\n \n- /**\n- * APIProperty: eventListeners\n- * {Object} If set as an option at construction, the eventListeners\n- * object will be registered with . Object\n- * structure must be a listeners object as shown in the example for\n- * the events.on method.\n- */\n- eventListeners: null,\n+ // if we couldn't calculate resolutions then we look at we have\n+ // in the map\n+ if (props.resolutions == null) {\n+ for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n+ p = this.RESOLUTION_PROPERTIES[i];\n+ props[p] = this.options[p] != null ?\n+ this.options[p] : this.map[p];\n+ }\n+ if (props.resolutions == null) {\n+ props.resolutions = this.resolutionsFromScales(props.scales);\n+ }\n+ if (props.resolutions == null) {\n+ props.resolutions = this.calculateResolutions(props);\n+ }\n+ }\n \n- /** \n- * APIProperty: events\n- * {} Events instance for listeners and triggering\n- * control specific events.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * control.events.register(type, obj, listener);\n- * (end)\n- *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n+ // ok, we new need to set properties in the instance\n+\n+ // get maxResolution from the config if it's defined there\n+ var maxResolution;\n+ if (this.options.maxResolution &&\n+ this.options.maxResolution !== \"auto\") {\n+ maxResolution = this.options.maxResolution;\n+ }\n+ if (this.options.minScale) {\n+ maxResolution = OpenLayers.Util.getResolutionFromScale(\n+ this.options.minScale, this.units);\n+ }\n+\n+ // get minResolution from the config if it's defined there\n+ var minResolution;\n+ if (this.options.minResolution &&\n+ this.options.minResolution !== \"auto\") {\n+ minResolution = this.options.minResolution;\n+ }\n+ if (this.options.maxScale) {\n+ minResolution = OpenLayers.Util.getResolutionFromScale(\n+ this.options.maxScale, this.units);\n+ }\n+\n+ if (props.resolutions) {\n+\n+ //sort resolutions array descendingly\n+ props.resolutions.sort(function(a, b) {\n+ return (b - a);\n+ });\n+\n+ // if we still don't have a maxResolution get it from the\n+ // resolutions array\n+ if (!maxResolution) {\n+ maxResolution = props.resolutions[0];\n+ }\n+\n+ // if we still don't have a minResolution get it from the\n+ // resolutions array\n+ if (!minResolution) {\n+ var lastIdx = props.resolutions.length - 1;\n+ minResolution = props.resolutions[lastIdx];\n+ }\n+ }\n+\n+ this.resolutions = props.resolutions;\n+ if (this.resolutions) {\n+ len = this.resolutions.length;\n+ this.scales = new Array(len);\n+ for (i = 0; i < len; i++) {\n+ this.scales[i] = OpenLayers.Util.getScaleFromResolution(\n+ this.resolutions[i], this.units);\n+ }\n+ this.numZoomLevels = len;\n+ }\n+ this.minResolution = minResolution;\n+ if (minResolution) {\n+ this.maxScale = OpenLayers.Util.getScaleFromResolution(\n+ minResolution, this.units);\n+ }\n+ this.maxResolution = maxResolution;\n+ if (maxResolution) {\n+ this.minScale = OpenLayers.Util.getScaleFromResolution(\n+ maxResolution, this.units);\n+ }\n+ },\n+\n+ /**\n+ * Method: resolutionsFromScales\n+ * Derive resolutions from scales.\n *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to control.events.object (a reference\n- * to the control).\n- * element - {DOMElement} A reference to control.events.element (which\n- * will be null unless documented otherwise).\n+ * Parameters:\n+ * scales - {Array(Number)} Scales\n *\n- * Supported map event types:\n- * activate - Triggered when activated.\n- * deactivate - Triggered when deactivated.\n+ * Returns\n+ * {Array(Number)} Resolutions\n */\n- events: null,\n+ resolutionsFromScales: function(scales) {\n+ if (scales == null) {\n+ return;\n+ }\n+ var resolutions, i, len;\n+ len = scales.length;\n+ resolutions = new Array(len);\n+ for (i = 0; i < len; i++) {\n+ resolutions[i] = OpenLayers.Util.getResolutionFromScale(\n+ scales[i], this.units);\n+ }\n+ return resolutions;\n+ },\n \n /**\n- * Constructor: OpenLayers.Control\n- * Create an OpenLayers Control. The options passed as a parameter\n- * directly extend the control. For example passing the following:\n- * \n- * > var control = new OpenLayers.Control({div: myDiv});\n+ * Method: calculateResolutions\n+ * Calculate resolutions based on the provided properties.\n *\n- * Overrides the default div attribute value of null.\n- * \n * Parameters:\n- * options - {Object} \n+ * props - {Object} Properties\n+ *\n+ * Returns:\n+ * {Array({Number})} Array of resolutions.\n */\n- initialize: function(options) {\n- // We do this before the extend so that instances can override\n- // className in options.\n- this.displayClass =\n- this.CLASS_NAME.replace(\"OpenLayers.\", \"ol\").replace(/\\./g, \"\");\n+ calculateResolutions: function(props) {\n \n- OpenLayers.Util.extend(this, options);\n+ var viewSize, wRes, hRes;\n \n- this.events = new OpenLayers.Events(this);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n+ // determine maxResolution\n+ var maxResolution = props.maxResolution;\n+ if (props.minScale != null) {\n+ maxResolution =\n+ OpenLayers.Util.getResolutionFromScale(props.minScale,\n+ this.units);\n+ } else if (maxResolution == \"auto\" && this.maxExtent != null) {\n+ viewSize = this.map.getSize();\n+ wRes = this.maxExtent.getWidth() / viewSize.w;\n+ hRes = this.maxExtent.getHeight() / viewSize.h;\n+ maxResolution = Math.max(wRes, hRes);\n }\n- if (this.id == null) {\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+\n+ // determine minResolution\n+ var minResolution = props.minResolution;\n+ if (props.maxScale != null) {\n+ minResolution =\n+ OpenLayers.Util.getResolutionFromScale(props.maxScale,\n+ this.units);\n+ } else if (props.minResolution == \"auto\" && this.minExtent != null) {\n+ viewSize = this.map.getSize();\n+ wRes = this.minExtent.getWidth() / viewSize.w;\n+ hRes = this.minExtent.getHeight() / viewSize.h;\n+ minResolution = Math.max(wRes, hRes);\n }\n- },\n \n- /**\n- * Method: destroy\n- * The destroy method is used to perform any clean up before the control\n- * is dereferenced. Typically this is where event listeners are removed\n- * to prevent memory leaks.\n- */\n- destroy: function() {\n- if (this.events) {\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n- }\n- this.events.destroy();\n- this.events = null;\n+ if (typeof maxResolution !== \"number\" &&\n+ typeof minResolution !== \"number\" &&\n+ this.maxExtent != null) {\n+ // maxResolution for default grid sets assumes that at zoom\n+ // level zero, the whole world fits on one tile.\n+ var tileSize = this.map.getTileSize();\n+ maxResolution = Math.max(\n+ this.maxExtent.getWidth() / tileSize.w,\n+ this.maxExtent.getHeight() / tileSize.h\n+ );\n }\n- this.eventListeners = null;\n \n- // eliminate circular references\n- if (this.handler) {\n- this.handler.destroy();\n- this.handler = null;\n+ // determine numZoomLevels\n+ var maxZoomLevel = props.maxZoomLevel;\n+ var numZoomLevels = props.numZoomLevels;\n+ if (typeof minResolution === \"number\" &&\n+ typeof maxResolution === \"number\" && numZoomLevels === undefined) {\n+ var ratio = maxResolution / minResolution;\n+ numZoomLevels = Math.floor(Math.log(ratio) / Math.log(2)) + 1;\n+ } else if (numZoomLevels === undefined && maxZoomLevel != null) {\n+ numZoomLevels = maxZoomLevel + 1;\n }\n- if (this.handlers) {\n- for (var key in this.handlers) {\n- if (this.handlers.hasOwnProperty(key) &&\n- typeof this.handlers[key].destroy == \"function\") {\n- this.handlers[key].destroy();\n- }\n- }\n- this.handlers = null;\n+\n+ // are we able to calculate resolutions?\n+ if (typeof numZoomLevels !== \"number\" || numZoomLevels <= 0 ||\n+ (typeof maxResolution !== \"number\" &&\n+ typeof minResolution !== \"number\")) {\n+ return;\n }\n- if (this.map) {\n- this.map.removeControl(this);\n- this.map = null;\n+\n+ // now we have numZoomLevels and at least one of maxResolution\n+ // or minResolution, we can populate the resolutions array\n+\n+ var resolutions = new Array(numZoomLevels);\n+ var base = 2;\n+ if (typeof minResolution == \"number\" &&\n+ typeof maxResolution == \"number\") {\n+ // if maxResolution and minResolution are set, we calculate\n+ // the base for exponential scaling that starts at\n+ // maxResolution and ends at minResolution in numZoomLevels\n+ // steps.\n+ base = Math.pow(\n+ (maxResolution / minResolution),\n+ (1 / (numZoomLevels - 1))\n+ );\n }\n- this.div = null;\n+\n+ var i;\n+ if (typeof maxResolution === \"number\") {\n+ for (i = 0; i < numZoomLevels; i++) {\n+ resolutions[i] = maxResolution / Math.pow(base, i);\n+ }\n+ } else {\n+ for (i = 0; i < numZoomLevels; i++) {\n+ resolutions[numZoomLevels - 1 - i] =\n+ minResolution * Math.pow(base, i);\n+ }\n+ }\n+\n+ return resolutions;\n+ },\n+\n+ /**\n+ * APIMethod: getResolution\n+ * \n+ * Returns:\n+ * {Float} The currently selected resolution of the map, taken from the\n+ * resolutions array, indexed by current zoom level.\n+ */\n+ getResolution: function() {\n+ var zoom = this.map.getZoom();\n+ return this.getResolutionForZoom(zoom);\n },\n \n /** \n- * Method: setMap\n- * Set the map property for the control. This is done through an accessor\n- * so that subclasses can override this and take special action once \n- * they have their map variable set. \n+ * APIMethod: getExtent\n+ * \n+ * Returns:\n+ * {} A Bounds object which represents the lon/lat \n+ * bounds of the current viewPort.\n+ */\n+ getExtent: function() {\n+ // just use stock map calculateBounds function -- passing no arguments\n+ // means it will user map's current center & resolution\n+ //\n+ return this.map.calculateBounds();\n+ },\n+\n+ /**\n+ * APIMethod: getZoomForExtent\n+ * \n+ * Parameters:\n+ * extent - {}\n+ * closest - {Boolean} Find the zoom level that most closely fits the \n+ * specified bounds. Note that this may result in a zoom that does \n+ * not exactly contain the entire extent.\n+ * Default is false.\n *\n+ * Returns:\n+ * {Integer} The index of the zoomLevel (entry in the resolutions array) \n+ * for the passed-in extent. We do this by calculating the ideal \n+ * resolution for the given extent (based on the map size) and then \n+ * calling getZoomForResolution(), passing along the 'closest'\n+ * parameter.\n+ */\n+ getZoomForExtent: function(extent, closest) {\n+ var viewSize = this.map.getSize();\n+ var idealResolution = Math.max(extent.getWidth() / viewSize.w,\n+ extent.getHeight() / viewSize.h);\n+\n+ return this.getZoomForResolution(idealResolution, closest);\n+ },\n+\n+ /** \n+ * Method: getDataExtent\n+ * Calculates the max extent which includes all of the data for the layer.\n+ * This function is to be implemented by subclasses.\n+ * \n+ * Returns:\n+ * {}\n+ */\n+ getDataExtent: function() {\n+ //to be implemented by subclasses\n+ },\n+\n+ /**\n+ * APIMethod: getResolutionForZoom\n+ * \n * Parameters:\n- * map - {} \n+ * zoom - {Float}\n+ * \n+ * Returns:\n+ * {Float} A suitable resolution for the specified zoom.\n */\n- setMap: function(map) {\n- this.map = map;\n- if (this.handler) {\n- this.handler.setMap(map);\n+ getResolutionForZoom: function(zoom) {\n+ zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));\n+ var resolution;\n+ if (this.map.fractionalZoom) {\n+ var low = Math.floor(zoom);\n+ var high = Math.ceil(zoom);\n+ resolution = this.resolutions[low] -\n+ ((zoom - low) * (this.resolutions[low] - this.resolutions[high]));\n+ } else {\n+ resolution = this.resolutions[Math.round(zoom)];\n }\n+ return resolution;\n },\n \n /**\n- * Method: draw\n- * The draw method is called when the control is ready to be displayed\n- * on the page. If a div has not been created one is created. Controls\n- * with a visual component will almost always want to override this method \n- * to customize the look of control. \n- *\n+ * APIMethod: getZoomForResolution\n+ * \n * Parameters:\n- * px - {} The top-left pixel position of the control\n- * or null.\n- *\n+ * resolution - {Float}\n+ * closest - {Boolean} Find the zoom level that corresponds to the absolute \n+ * closest resolution, which may result in a zoom whose corresponding\n+ * resolution is actually smaller than we would have desired (if this\n+ * is being called from a getZoomForExtent() call, then this means that\n+ * the returned zoom index might not actually contain the entire \n+ * extent specified... but it'll be close).\n+ * Default is false.\n+ * \n * Returns:\n- * {DOMElement} A reference to the DIV DOMElement containing the control\n+ * {Integer} The index of the zoomLevel (entry in the resolutions array) \n+ * that corresponds to the best fit resolution given the passed in \n+ * value and the 'closest' specification.\n */\n- draw: function(px) {\n- if (this.div == null) {\n- this.div = OpenLayers.Util.createDiv(this.id);\n- this.div.className = this.displayClass;\n- if (!this.allowSelection) {\n- this.div.className += \" olControlNoSelect\";\n- this.div.setAttribute(\"unselectable\", \"on\", 0);\n- this.div.onselectstart = OpenLayers.Function.False;\n+ getZoomForResolution: function(resolution, closest) {\n+ var zoom, i, len;\n+ if (this.map.fractionalZoom) {\n+ var lowZoom = 0;\n+ var highZoom = this.resolutions.length - 1;\n+ var highRes = this.resolutions[lowZoom];\n+ var lowRes = this.resolutions[highZoom];\n+ var res;\n+ for (i = 0, len = this.resolutions.length; i < len; ++i) {\n+ res = this.resolutions[i];\n+ if (res >= resolution) {\n+ highRes = res;\n+ lowZoom = i;\n+ }\n+ if (res <= resolution) {\n+ lowRes = res;\n+ highZoom = i;\n+ break;\n+ }\n }\n- if (this.title != \"\") {\n- this.div.title = this.title;\n+ var dRes = highRes - lowRes;\n+ if (dRes > 0) {\n+ zoom = lowZoom + ((highRes - resolution) / dRes);\n+ } else {\n+ zoom = lowZoom;\n }\n+ } else {\n+ var diff;\n+ var minDiff = Number.POSITIVE_INFINITY;\n+ for (i = 0, len = this.resolutions.length; i < len; i++) {\n+ if (closest) {\n+ diff = Math.abs(this.resolutions[i] - resolution);\n+ if (diff > minDiff) {\n+ break;\n+ }\n+ minDiff = diff;\n+ } else {\n+ if (this.resolutions[i] < resolution) {\n+ break;\n+ }\n+ }\n+ }\n+ zoom = Math.max(0, i - 1);\n }\n- if (px != null) {\n- this.position = px.clone();\n- }\n- this.moveTo(this.position);\n- return this.div;\n+ return zoom;\n },\n \n /**\n- * Method: moveTo\n- * Sets the left and top style attributes to the passed in pixel \n- * coordinates.\n- *\n+ * APIMethod: getLonLatFromViewPortPx\n+ * \n * Parameters:\n- * px - {}\n+ * viewPortPx - {|Object} An OpenLayers.Pixel or\n+ * an object with a 'x'\n+ * and 'y' properties.\n+ *\n+ * Returns:\n+ * {} An OpenLayers.LonLat which is the passed-in \n+ * view port , translated into lon/lat by the layer.\n */\n- moveTo: function(px) {\n- if ((px != null) && (this.div != null)) {\n- this.div.style.left = px.x + \"px\";\n- this.div.style.top = px.y + \"px\";\n+ getLonLatFromViewPortPx: function(viewPortPx) {\n+ var lonlat = null;\n+ var map = this.map;\n+ if (viewPortPx != null && map.minPx) {\n+ var res = map.getResolution();\n+ var maxExtent = map.getMaxExtent({\n+ restricted: true\n+ });\n+ var lon = (viewPortPx.x - map.minPx.x) * res + maxExtent.left;\n+ var lat = (map.minPx.y - viewPortPx.y) * res + maxExtent.top;\n+ lonlat = new OpenLayers.LonLat(lon, lat);\n+\n+ if (this.wrapDateLine) {\n+ lonlat = lonlat.wrapDateLine(this.maxExtent);\n+ }\n }\n+ return lonlat;\n },\n \n /**\n- * APIMethod: activate\n- * Explicitly activates a control and it's associated\n- * handler if one has been set. Controls can be\n- * deactivated by calling the deactivate() method.\n+ * APIMethod: getViewPortPxFromLonLat\n+ * Returns a pixel location given a map location. This method will return\n+ * fractional pixel values.\n * \n- * Returns:\n- * {Boolean} True if the control was successfully activated or\n- * false if the control was already active.\n+ * Parameters:\n+ * lonlat - {|Object} An OpenLayers.LonLat or\n+ * an object with a 'lon'\n+ * and 'lat' properties.\n+ *\n+ * Returns: \n+ * {} An which is the passed-in \n+ * lonlat translated into view port pixels.\n */\n- activate: function() {\n- if (this.active) {\n- return false;\n- }\n- if (this.handler) {\n- this.handler.activate();\n- }\n- this.active = true;\n- if (this.map) {\n- OpenLayers.Element.addClass(\n- this.map.viewPortDiv,\n- this.displayClass.replace(/ /g, \"\") + \"Active\"\n+ getViewPortPxFromLonLat: function(lonlat, resolution) {\n+ var px = null;\n+ if (lonlat != null) {\n+ resolution = resolution || this.map.getResolution();\n+ var extent = this.map.calculateBounds(null, resolution);\n+ px = new OpenLayers.Pixel(\n+ (1 / resolution * (lonlat.lon - extent.left)),\n+ (1 / resolution * (extent.top - lonlat.lat))\n );\n }\n- this.events.triggerEvent(\"activate\");\n- return true;\n+ return px;\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivates a control and it's associated handler if any. The exact\n- * effect of this depends on the control itself.\n+ * APIMethod: setOpacity\n+ * Sets the opacity for the entire layer (all images)\n * \n- * Returns:\n- * {Boolean} True if the control was effectively deactivated or false\n- * if the control was already inactive.\n+ * Parameters:\n+ * opacity - {Float}\n */\n- deactivate: function() {\n- if (this.active) {\n- if (this.handler) {\n- this.handler.deactivate();\n+ setOpacity: function(opacity) {\n+ if (opacity != this.opacity) {\n+ this.opacity = opacity;\n+ var childNodes = this.div.childNodes;\n+ for (var i = 0, len = childNodes.length; i < len; ++i) {\n+ var element = childNodes[i].firstChild || childNodes[i];\n+ var lastChild = childNodes[i].lastChild;\n+ //TODO de-uglify this\n+ if (lastChild && lastChild.nodeName.toLowerCase() === \"iframe\") {\n+ element = lastChild.parentNode;\n+ }\n+ OpenLayers.Util.modifyDOMElement(element, null, null, null,\n+ null, null, null, opacity);\n }\n- this.active = false;\n- if (this.map) {\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv,\n- this.displayClass.replace(/ /g, \"\") + \"Active\"\n- );\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"opacity\"\n+ });\n }\n- this.events.triggerEvent(\"deactivate\");\n- return true;\n }\n- return false;\n },\n \n- CLASS_NAME: \"OpenLayers.Control\"\n-});\n+ /**\n+ * Method: getZIndex\n+ * \n+ * Returns: \n+ * {Integer} the z-index of this layer\n+ */\n+ getZIndex: function() {\n+ return this.div.style.zIndex;\n+ },\n \n-/**\n- * Constant: OpenLayers.Control.TYPE_BUTTON\n- */\n-OpenLayers.Control.TYPE_BUTTON = 1;\n+ /**\n+ * Method: setZIndex\n+ * \n+ * Parameters: \n+ * zIndex - {Integer}\n+ */\n+ setZIndex: function(zIndex) {\n+ this.div.style.zIndex = zIndex;\n+ },\n \n-/**\n- * Constant: OpenLayers.Control.TYPE_TOGGLE\n- */\n-OpenLayers.Control.TYPE_TOGGLE = 2;\n+ /**\n+ * Method: adjustBounds\n+ * This function will take a bounds, and if wrapDateLine option is set\n+ * on the layer, it will return a bounds which is wrapped around the \n+ * world. We do not wrap for bounds which *cross* the \n+ * maxExtent.left/right, only bounds which are entirely to the left \n+ * or entirely to the right.\n+ * \n+ * Parameters:\n+ * bounds - {}\n+ */\n+ adjustBounds: function(bounds) {\n \n-/**\n- * Constant: OpenLayers.Control.TYPE_TOOL\n- */\n-OpenLayers.Control.TYPE_TOOL = 3;\n+ if (this.gutter) {\n+ // Adjust the extent of a bounds in map units by the \n+ // layer's gutter in pixels.\n+ var mapGutter = this.gutter * this.map.getResolution();\n+ bounds = new OpenLayers.Bounds(bounds.left - mapGutter,\n+ bounds.bottom - mapGutter,\n+ bounds.right + mapGutter,\n+ bounds.top + mapGutter);\n+ }\n+\n+ if (this.wrapDateLine) {\n+ // wrap around the date line, within the limits of rounding error\n+ var wrappingOptions = {\n+ 'rightTolerance': this.getResolution(),\n+ 'leftTolerance': this.getResolution()\n+ };\n+ bounds = bounds.wrapDateLine(this.maxExtent, wrappingOptions);\n+\n+ }\n+ return bounds;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Layer\"\n+});\n /* ======================================================================\n OpenLayers/Geometry.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -11449,757 +13929,14 @@\n distance: Math.pow(x - x0, 2) + Math.pow(y - y0, 2),\n x: x,\n y: y,\n along: along\n };\n };\n /* ======================================================================\n- OpenLayers/Feature.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Class: OpenLayers.Feature\n- * Features are combinations of geography and attributes. The OpenLayers.Feature\n- * class specifically combines a marker and a lonlat.\n- */\n-OpenLayers.Feature = OpenLayers.Class({\n-\n- /** \n- * Property: layer \n- * {} \n- */\n- layer: null,\n-\n- /** \n- * Property: id \n- * {String} \n- */\n- id: null,\n-\n- /** \n- * Property: lonlat \n- * {} \n- */\n- lonlat: null,\n-\n- /** \n- * Property: data \n- * {Object} \n- */\n- data: null,\n-\n- /** \n- * Property: marker \n- * {} \n- */\n- marker: null,\n-\n- /**\n- * APIProperty: popupClass\n- * {} The class which will be used to instantiate\n- * a new Popup. Default is .\n- */\n- popupClass: null,\n-\n- /** \n- * Property: popup \n- * {} \n- */\n- popup: null,\n-\n- /** \n- * Constructor: OpenLayers.Feature\n- * Constructor for features.\n- *\n- * Parameters:\n- * layer - {} \n- * lonlat - {} \n- * data - {Object} \n- * \n- * Returns:\n- * {}\n- */\n- initialize: function(layer, lonlat, data) {\n- this.layer = layer;\n- this.lonlat = lonlat;\n- this.data = (data != null) ? data : {};\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /** \n- * Method: destroy\n- * nullify references to prevent circular references and memory leaks\n- */\n- destroy: function() {\n-\n- //remove the popup from the map\n- if ((this.layer != null) && (this.layer.map != null)) {\n- if (this.popup != null) {\n- this.layer.map.removePopup(this.popup);\n- }\n- }\n- // remove the marker from the layer\n- if (this.layer != null && this.marker != null) {\n- this.layer.removeMarker(this.marker);\n- }\n-\n- this.layer = null;\n- this.id = null;\n- this.lonlat = null;\n- this.data = null;\n- if (this.marker != null) {\n- this.destroyMarker(this.marker);\n- this.marker = null;\n- }\n- if (this.popup != null) {\n- this.destroyPopup(this.popup);\n- this.popup = null;\n- }\n- },\n-\n- /**\n- * Method: onScreen\n- * \n- * Returns:\n- * {Boolean} Whether or not the feature is currently visible on screen\n- * (based on its 'lonlat' property)\n- */\n- onScreen: function() {\n-\n- var onScreen = false;\n- if ((this.layer != null) && (this.layer.map != null)) {\n- var screenBounds = this.layer.map.getExtent();\n- onScreen = screenBounds.containsLonLat(this.lonlat);\n- }\n- return onScreen;\n- },\n-\n-\n- /**\n- * Method: createMarker\n- * Based on the data associated with the Feature, create and return a marker object.\n- *\n- * Returns: \n- * {} A Marker Object created from the 'lonlat' and 'icon' properties\n- * set in this.data. If no 'lonlat' is set, returns null. If no\n- * 'icon' is set, OpenLayers.Marker() will load the default image.\n- * \n- * Note - this.marker is set to return value\n- * \n- */\n- createMarker: function() {\n-\n- if (this.lonlat != null) {\n- this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);\n- }\n- return this.marker;\n- },\n-\n- /**\n- * Method: destroyMarker\n- * Destroys marker.\n- * If user overrides the createMarker() function, s/he should be able\n- * to also specify an alternative function for destroying it\n- */\n- destroyMarker: function() {\n- this.marker.destroy();\n- },\n-\n- /**\n- * Method: createPopup\n- * Creates a popup object created from the 'lonlat', 'popupSize',\n- * and 'popupContentHTML' properties set in this.data. It uses\n- * this.marker.icon as default anchor. \n- * \n- * If no 'lonlat' is set, returns null. \n- * If no this.marker has been created, no anchor is sent.\n- *\n- * Note - the returned popup object is 'owned' by the feature, so you\n- * cannot use the popup's destroy method to discard the popup.\n- * Instead, you must use the feature's destroyPopup\n- * \n- * Note - this.popup is set to return value\n- * \n- * Parameters: \n- * closeBox - {Boolean} create popup with closebox or not\n- * \n- * Returns:\n- * {} Returns the created popup, which is also set\n- * as 'popup' property of this feature. Will be of whatever type\n- * specified by this feature's 'popupClass' property, but must be\n- * of type .\n- * \n- */\n- createPopup: function(closeBox) {\n-\n- if (this.lonlat != null) {\n- if (!this.popup) {\n- var anchor = (this.marker) ? this.marker.icon : null;\n- var popupClass = this.popupClass ?\n- this.popupClass : OpenLayers.Popup.Anchored;\n- this.popup = new popupClass(this.id + \"_popup\",\n- this.lonlat,\n- this.data.popupSize,\n- this.data.popupContentHTML,\n- anchor,\n- closeBox);\n- }\n- if (this.data.overflow != null) {\n- this.popup.contentDiv.style.overflow = this.data.overflow;\n- }\n-\n- this.popup.feature = this;\n- }\n- return this.popup;\n- },\n-\n-\n- /**\n- * Method: destroyPopup\n- * Destroys the popup created via createPopup.\n- *\n- * As with the marker, if user overrides the createPopup() function, s/he \n- * should also be able to override the destruction\n- */\n- destroyPopup: function() {\n- if (this.popup) {\n- this.popup.feature = null;\n- this.popup.destroy();\n- this.popup = null;\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Feature\"\n-});\n-/* ======================================================================\n- OpenLayers/Feature/Vector.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-// TRASH THIS\n-OpenLayers.State = {\n- /** states */\n- UNKNOWN: 'Unknown',\n- INSERT: 'Insert',\n- UPDATE: 'Update',\n- DELETE: 'Delete'\n-};\n-\n-/**\n- * @requires OpenLayers/Feature.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Class: OpenLayers.Feature.Vector\n- * Vector features use the OpenLayers.Geometry classes as geometry description.\n- * They have an 'attributes' property, which is the data object, and a 'style'\n- * property, the default values of which are defined in the \n- * objects.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Feature.Vector = OpenLayers.Class(OpenLayers.Feature, {\n-\n- /** \n- * Property: fid \n- * {String} \n- */\n- fid: null,\n-\n- /** \n- * APIProperty: geometry \n- * {} \n- */\n- geometry: null,\n-\n- /** \n- * APIProperty: attributes \n- * {Object} This object holds arbitrary, serializable properties that\n- * describe the feature.\n- */\n- attributes: null,\n-\n- /**\n- * Property: bounds\n- * {} The box bounding that feature's geometry, that\n- * property can be set by an object when\n- * deserializing the feature, so in most cases it represents an\n- * information set by the server. \n- */\n- bounds: null,\n-\n- /** \n- * Property: state \n- * {String} \n- */\n- state: null,\n-\n- /** \n- * APIProperty: style \n- * {Object} \n- */\n- style: null,\n-\n- /**\n- * APIProperty: url\n- * {String} If this property is set it will be taken into account by\n- * {} when upadting or deleting the feature.\n- */\n- url: null,\n-\n- /**\n- * Property: renderIntent\n- * {String} rendering intent currently being used\n- */\n- renderIntent: \"default\",\n-\n- /**\n- * APIProperty: modified\n- * {Object} An object with the originals of the geometry and attributes of\n- * the feature, if they were changed. Currently this property is only read\n- * by , and written by\n- * , which sets the geometry property.\n- * Applications can set the originals of modified attributes in the\n- * attributes property. Note that applications have to check if this\n- * object and the attributes property is already created before using it.\n- * After a change made with ModifyFeature, this object could look like\n- *\n- * (code)\n- * {\n- * geometry: >Object\n- * }\n- * (end)\n- *\n- * When an application has made changes to feature attributes, it could\n- * have set the attributes to something like this:\n- *\n- * (code)\n- * {\n- * attributes: {\n- * myAttribute: \"original\"\n- * }\n- * }\n- * (end)\n- *\n- * Note that only checks for truthy values in\n- * *modified.geometry* and the attribute names in *modified.attributes*,\n- * but it is recommended to set the original values (and not just true) as\n- * attribute value, so applications could use this information to undo\n- * changes.\n- */\n- modified: null,\n-\n- /** \n- * Constructor: OpenLayers.Feature.Vector\n- * Create a vector feature. \n- * \n- * Parameters:\n- * geometry - {} The geometry that this feature\n- * represents.\n- * attributes - {Object} An optional object that will be mapped to the\n- * property. \n- * style - {Object} An optional style object.\n- */\n- initialize: function(geometry, attributes, style) {\n- OpenLayers.Feature.prototype.initialize.apply(this,\n- [null, null, attributes]);\n- this.lonlat = null;\n- this.geometry = geometry ? geometry : null;\n- this.state = null;\n- this.attributes = {};\n- if (attributes) {\n- this.attributes = OpenLayers.Util.extend(this.attributes,\n- attributes);\n- }\n- this.style = style ? style : null;\n- },\n-\n- /** \n- * Method: destroy\n- * nullify references to prevent circular references and memory leaks\n- */\n- destroy: function() {\n- if (this.layer) {\n- this.layer.removeFeatures(this);\n- this.layer = null;\n- }\n-\n- this.geometry = null;\n- this.modified = null;\n- OpenLayers.Feature.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: clone\n- * Create a clone of this vector feature. Does not set any non-standard\n- * properties.\n- *\n- * Returns:\n- * {} An exact clone of this vector feature.\n- */\n- clone: function() {\n- return new OpenLayers.Feature.Vector(\n- this.geometry ? this.geometry.clone() : null,\n- this.attributes,\n- this.style);\n- },\n-\n- /**\n- * Method: onScreen\n- * Determine whether the feature is within the map viewport. This method\n- * tests for an intersection between the geometry and the viewport\n- * bounds. If a more effecient but less precise geometry bounds\n- * intersection is desired, call the method with the boundsOnly\n- * parameter true.\n- *\n- * Parameters:\n- * boundsOnly - {Boolean} Only test whether a feature's bounds intersects\n- * the viewport bounds. Default is false. If false, the feature's\n- * geometry must intersect the viewport for onScreen to return true.\n- * \n- * Returns:\n- * {Boolean} The feature is currently visible on screen (optionally\n- * based on its bounds if boundsOnly is true).\n- */\n- onScreen: function(boundsOnly) {\n- var onScreen = false;\n- if (this.layer && this.layer.map) {\n- var screenBounds = this.layer.map.getExtent();\n- if (boundsOnly) {\n- var featureBounds = this.geometry.getBounds();\n- onScreen = screenBounds.intersectsBounds(featureBounds);\n- } else {\n- var screenPoly = screenBounds.toGeometry();\n- onScreen = screenPoly.intersects(this.geometry);\n- }\n- }\n- return onScreen;\n- },\n-\n- /**\n- * Method: getVisibility\n- * Determine whether the feature is displayed or not. It may not displayed\n- * because:\n- * - its style display property is set to 'none',\n- * - it doesn't belong to any layer,\n- * - the styleMap creates a symbolizer with display property set to 'none'\n- * for it,\n- * - the layer which it belongs to is not visible.\n- * \n- * Returns:\n- * {Boolean} The feature is currently displayed.\n- */\n- getVisibility: function() {\n- return !(this.style && this.style.display == 'none' ||\n- !this.layer ||\n- this.layer && this.layer.styleMap &&\n- this.layer.styleMap.createSymbolizer(this, this.renderIntent).display == 'none' ||\n- this.layer && !this.layer.getVisibility());\n- },\n-\n- /**\n- * Method: createMarker\n- * HACK - we need to decide if all vector features should be able to\n- * create markers\n- * \n- * Returns:\n- * {} For now just returns null\n- */\n- createMarker: function() {\n- return null;\n- },\n-\n- /**\n- * Method: destroyMarker\n- * HACK - we need to decide if all vector features should be able to\n- * delete markers\n- * \n- * If user overrides the createMarker() function, s/he should be able\n- * to also specify an alternative function for destroying it\n- */\n- destroyMarker: function() {\n- // pass\n- },\n-\n- /**\n- * Method: createPopup\n- * HACK - we need to decide if all vector features should be able to\n- * create popups\n- * \n- * Returns:\n- * {} For now just returns null\n- */\n- createPopup: function() {\n- return null;\n- },\n-\n- /**\n- * Method: atPoint\n- * Determins whether the feature intersects with the specified location.\n- * \n- * Parameters: \n- * lonlat - {|Object} OpenLayers.LonLat or an\n- * object with a 'lon' and 'lat' properties.\n- * toleranceLon - {float} Optional tolerance in Geometric Coords\n- * toleranceLat - {float} Optional tolerance in Geographic Coords\n- * \n- * Returns:\n- * {Boolean} Whether or not the feature is at the specified location\n- */\n- atPoint: function(lonlat, toleranceLon, toleranceLat) {\n- var atPoint = false;\n- if (this.geometry) {\n- atPoint = this.geometry.atPoint(lonlat, toleranceLon,\n- toleranceLat);\n- }\n- return atPoint;\n- },\n-\n- /**\n- * Method: destroyPopup\n- * HACK - we need to decide if all vector features should be able to\n- * delete popups\n- */\n- destroyPopup: function() {\n- // pass\n- },\n-\n- /**\n- * Method: move\n- * Moves the feature and redraws it at its new location\n- *\n- * Parameters:\n- * location - { or } the\n- * location to which to move the feature.\n- */\n- move: function(location) {\n-\n- if (!this.layer || !this.geometry.move) {\n- //do nothing if no layer or immoveable geometry\n- return undefined;\n- }\n-\n- var pixel;\n- if (location.CLASS_NAME == \"OpenLayers.LonLat\") {\n- pixel = this.layer.getViewPortPxFromLonLat(location);\n- } else {\n- pixel = location;\n- }\n-\n- var lastPixel = this.layer.getViewPortPxFromLonLat(this.geometry.getBounds().getCenterLonLat());\n- var res = this.layer.map.getResolution();\n- this.geometry.move(res * (pixel.x - lastPixel.x),\n- res * (lastPixel.y - pixel.y));\n- this.layer.drawFeature(this);\n- return lastPixel;\n- },\n-\n- /**\n- * Method: toState\n- * Sets the new state\n- *\n- * Parameters:\n- * state - {String} \n- */\n- toState: function(state) {\n- if (state == OpenLayers.State.UPDATE) {\n- switch (this.state) {\n- case OpenLayers.State.UNKNOWN:\n- case OpenLayers.State.DELETE:\n- this.state = state;\n- break;\n- case OpenLayers.State.UPDATE:\n- case OpenLayers.State.INSERT:\n- break;\n- }\n- } else if (state == OpenLayers.State.INSERT) {\n- switch (this.state) {\n- case OpenLayers.State.UNKNOWN:\n- break;\n- default:\n- this.state = state;\n- break;\n- }\n- } else if (state == OpenLayers.State.DELETE) {\n- switch (this.state) {\n- case OpenLayers.State.INSERT:\n- // the feature should be destroyed\n- break;\n- case OpenLayers.State.DELETE:\n- break;\n- case OpenLayers.State.UNKNOWN:\n- case OpenLayers.State.UPDATE:\n- this.state = state;\n- break;\n- }\n- } else if (state == OpenLayers.State.UNKNOWN) {\n- this.state = state;\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Feature.Vector\"\n-});\n-\n-\n-/**\n- * Constant: OpenLayers.Feature.Vector.style\n- * OpenLayers features can have a number of style attributes. The 'default' \n- * style will typically be used if no other style is specified. These\n- * styles correspond for the most part, to the styling properties defined\n- * by the SVG standard. \n- * Information on fill properties: http://www.w3.org/TR/SVG/painting.html#FillProperties\n- * Information on stroke properties: http://www.w3.org/TR/SVG/painting.html#StrokeProperties\n- *\n- * Symbolizer properties:\n- * fill - {Boolean} Set to false if no fill is desired.\n- * fillColor - {String} Hex fill color. Default is \"#ee9900\".\n- * fillOpacity - {Number} Fill opacity (0-1). Default is 0.4 \n- * stroke - {Boolean} Set to false if no stroke is desired.\n- * strokeColor - {String} Hex stroke color. Default is \"#ee9900\".\n- * strokeOpacity - {Number} Stroke opacity (0-1). Default is 1.\n- * strokeWidth - {Number} Pixel stroke width. Default is 1.\n- * strokeLinecap - {String} Stroke cap type. Default is \"round\". [butt | round | square]\n- * strokeDashstyle - {String} Stroke dash style. Default is \"solid\". [dot | dash | dashdot | longdash | longdashdot | solid]\n- * graphic - {Boolean} Set to false if no graphic is desired.\n- * pointRadius - {Number} Pixel point radius. Default is 6.\n- * pointerEvents - {String} Default is \"visiblePainted\".\n- * cursor - {String} Default is \"\".\n- * externalGraphic - {String} Url to an external graphic that will be used for rendering points.\n- * graphicWidth - {Number} Pixel width for sizing an external graphic.\n- * graphicHeight - {Number} Pixel height for sizing an external graphic.\n- * graphicOpacity - {Number} Opacity (0-1) for an external graphic.\n- * graphicXOffset - {Number} Pixel offset along the positive x axis for displacing an external graphic.\n- * graphicYOffset - {Number} Pixel offset along the positive y axis for displacing an external graphic.\n- * rotation - {Number} For point symbolizers, this is the rotation of a graphic in the clockwise direction about its center point (or any point off center as specified by graphicXOffset and graphicYOffset).\n- * graphicZIndex - {Number} The integer z-index value to use in rendering.\n- * graphicName - {String} Named graphic to use when rendering points. Supported values include \"circle\" (default),\n- * \"square\", \"star\", \"x\", \"cross\", \"triangle\".\n- * graphicTitle - {String} Tooltip when hovering over a feature. *deprecated*, use title instead\n- * title - {String} Tooltip when hovering over a feature. Not supported by the canvas renderer.\n- * backgroundGraphic - {String} Url to a graphic to be used as the background under an externalGraphic.\n- * backgroundGraphicZIndex - {Number} The integer z-index value to use in rendering the background graphic.\n- * backgroundXOffset - {Number} The x offset (in pixels) for the background graphic.\n- * backgroundYOffset - {Number} The y offset (in pixels) for the background graphic.\n- * backgroundHeight - {Number} The height of the background graphic. If not provided, the graphicHeight will be used.\n- * backgroundWidth - {Number} The width of the background width. If not provided, the graphicWidth will be used.\n- * label - {String} The text for an optional label. For browsers that use the canvas renderer, this requires either\n- * fillText or mozDrawText to be available.\n- * labelAlign - {String} Label alignment. This specifies the insertion point relative to the text. It is a string\n- * composed of two characters. The first character is for the horizontal alignment, the second for the vertical\n- * alignment. Valid values for horizontal alignment: \"l\"=left, \"c\"=center, \"r\"=right. Valid values for vertical\n- * alignment: \"t\"=top, \"m\"=middle, \"b\"=bottom. Example values: \"lt\", \"cm\", \"rb\". Default is \"cm\".\n- * labelXOffset - {Number} Pixel offset along the positive x axis for displacing the label. Not supported by the canvas renderer.\n- * labelYOffset - {Number} Pixel offset along the positive y axis for displacing the label. Not supported by the canvas renderer.\n- * labelSelect - {Boolean} If set to true, labels will be selectable using SelectFeature or similar controls.\n- * Default is false.\n- * labelOutlineColor - {String} The color of the label outline. Default is 'white'. Only supported by the canvas & SVG renderers.\n- * labelOutlineWidth - {Number} The width of the label outline. Default is 3, set to 0 or null to disable. Only supported by the SVG renderers.\n- * labelOutlineOpacity - {Number} The opacity (0-1) of the label outline. Default is fontOpacity. Only supported by the canvas & SVG renderers.\n- * fontColor - {String} The font color for the label, to be provided like CSS.\n- * fontOpacity - {Number} Opacity (0-1) for the label\n- * fontFamily - {String} The font family for the label, to be provided like in CSS.\n- * fontSize - {String} The font size for the label, to be provided like in CSS.\n- * fontStyle - {String} The font style for the label, to be provided like in CSS.\n- * fontWeight - {String} The font weight for the label, to be provided like in CSS.\n- * display - {String} Symbolizers will have no effect if display is set to \"none\". All other values have no effect.\n- */\n-OpenLayers.Feature.Vector.style = {\n- 'default': {\n- fillColor: \"#ee9900\",\n- fillOpacity: 0.4,\n- hoverFillColor: \"white\",\n- hoverFillOpacity: 0.8,\n- strokeColor: \"#ee9900\",\n- strokeOpacity: 1,\n- strokeWidth: 1,\n- strokeLinecap: \"round\",\n- strokeDashstyle: \"solid\",\n- hoverStrokeColor: \"red\",\n- hoverStrokeOpacity: 1,\n- hoverStrokeWidth: 0.2,\n- pointRadius: 6,\n- hoverPointRadius: 1,\n- hoverPointUnit: \"%\",\n- pointerEvents: \"visiblePainted\",\n- cursor: \"inherit\",\n- fontColor: \"#000000\",\n- labelAlign: \"cm\",\n- labelOutlineColor: \"white\",\n- labelOutlineWidth: 3\n- },\n- 'select': {\n- fillColor: \"blue\",\n- fillOpacity: 0.4,\n- hoverFillColor: \"white\",\n- hoverFillOpacity: 0.8,\n- strokeColor: \"blue\",\n- strokeOpacity: 1,\n- strokeWidth: 2,\n- strokeLinecap: \"round\",\n- strokeDashstyle: \"solid\",\n- hoverStrokeColor: \"red\",\n- hoverStrokeOpacity: 1,\n- hoverStrokeWidth: 0.2,\n- pointRadius: 6,\n- hoverPointRadius: 1,\n- hoverPointUnit: \"%\",\n- pointerEvents: \"visiblePainted\",\n- cursor: \"pointer\",\n- fontColor: \"#000000\",\n- labelAlign: \"cm\",\n- labelOutlineColor: \"white\",\n- labelOutlineWidth: 3\n-\n- },\n- 'temporary': {\n- fillColor: \"#66cccc\",\n- fillOpacity: 0.2,\n- hoverFillColor: \"white\",\n- hoverFillOpacity: 0.8,\n- strokeColor: \"#66cccc\",\n- strokeOpacity: 1,\n- strokeLinecap: \"round\",\n- strokeWidth: 2,\n- strokeDashstyle: \"solid\",\n- hoverStrokeColor: \"red\",\n- hoverStrokeOpacity: 1,\n- hoverStrokeWidth: 0.2,\n- pointRadius: 6,\n- hoverPointRadius: 1,\n- hoverPointUnit: \"%\",\n- pointerEvents: \"visiblePainted\",\n- cursor: \"inherit\",\n- fontColor: \"#000000\",\n- labelAlign: \"cm\",\n- labelOutlineColor: \"white\",\n- labelOutlineWidth: 3\n-\n- },\n- 'delete': {\n- display: \"none\"\n- }\n-};\n-/* ======================================================================\n OpenLayers/Format.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -18560,467 +20297,14 @@\n * Constant: OpenLayers.Format.WFST.DEFAULTS\n * {Object} Default properties for the WFST format.\n */\n OpenLayers.Format.WFST.DEFAULTS = {\n \"version\": \"1.0.0\"\n };\n /* ======================================================================\n- OpenLayers/Style.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Feature/Vector.js\n- */\n-\n-/**\n- * Class: OpenLayers.Style\n- * This class represents a UserStyle obtained\n- * from a SLD, containing styling rules.\n- */\n-OpenLayers.Style = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String} A unique id for this session.\n- */\n- id: null,\n-\n- /**\n- * APIProperty: name\n- * {String}\n- */\n- name: null,\n-\n- /**\n- * Property: title\n- * {String} Title of this style (set if included in SLD)\n- */\n- title: null,\n-\n- /**\n- * Property: description\n- * {String} Description of this style (set if abstract is included in SLD)\n- */\n- description: null,\n-\n- /**\n- * APIProperty: layerName\n- * {} name of the layer that this style belongs to, usually\n- * according to the NamedLayer attribute of an SLD document.\n- */\n- layerName: null,\n-\n- /**\n- * APIProperty: isDefault\n- * {Boolean}\n- */\n- isDefault: false,\n-\n- /** \n- * Property: rules \n- * {Array()}\n- */\n- rules: null,\n-\n- /**\n- * APIProperty: context\n- * {Object} An optional object with properties that symbolizers' property\n- * values should be evaluated against. If no context is specified,\n- * feature.attributes will be used\n- */\n- context: null,\n-\n- /**\n- * Property: defaultStyle\n- * {Object} hash of style properties to use as default for merging\n- * rule-based style symbolizers onto. If no rules are defined,\n- * createSymbolizer will return this style. If is set to\n- * true, the defaultStyle will only be taken into account if there are\n- * rules defined.\n- */\n- defaultStyle: null,\n-\n- /**\n- * Property: defaultsPerSymbolizer\n- * {Boolean} If set to true, the will extend the symbolizer\n- * of every rule. Properties of the will also be used to set\n- * missing symbolizer properties if the symbolizer has stroke, fill or\n- * graphic set to true. Default is false.\n- */\n- defaultsPerSymbolizer: false,\n-\n- /**\n- * Property: propertyStyles\n- * {Hash of Boolean} cache of style properties that need to be parsed for\n- * propertyNames. Property names are keys, values won't be used.\n- */\n- propertyStyles: null,\n-\n-\n- /** \n- * Constructor: OpenLayers.Style\n- * Creates a UserStyle.\n- *\n- * Parameters:\n- * style - {Object} Optional hash of style properties that will be\n- * used as default style for this style object. This style\n- * applies if no rules are specified. Symbolizers defined in\n- * rules will extend this default style.\n- * options - {Object} An optional object with properties to set on the\n- * style.\n- *\n- * Valid options:\n- * rules - {Array()} List of rules to be added to the\n- * style.\n- * \n- * Returns:\n- * {}\n- */\n- initialize: function(style, options) {\n-\n- OpenLayers.Util.extend(this, options);\n- this.rules = [];\n- if (options && options.rules) {\n- this.addRules(options.rules);\n- }\n-\n- // use the default style from OpenLayers.Feature.Vector if no style\n- // was given in the constructor\n- this.setDefaultStyle(style ||\n- OpenLayers.Feature.Vector.style[\"default\"]);\n-\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /** \n- * APIMethod: destroy\n- * nullify references to prevent circular references and memory leaks\n- */\n- destroy: function() {\n- for (var i = 0, len = this.rules.length; i < len; i++) {\n- this.rules[i].destroy();\n- this.rules[i] = null;\n- }\n- this.rules = null;\n- this.defaultStyle = null;\n- },\n-\n- /**\n- * Method: createSymbolizer\n- * creates a style by applying all feature-dependent rules to the base\n- * style.\n- * \n- * Parameters:\n- * feature - {} feature to evaluate rules for\n- * \n- * Returns:\n- * {Object} symbolizer hash\n- */\n- createSymbolizer: function(feature) {\n- var style = this.defaultsPerSymbolizer ? {} : this.createLiterals(\n- OpenLayers.Util.extend({}, this.defaultStyle), feature);\n-\n- var rules = this.rules;\n-\n- var rule, context;\n- var elseRules = [];\n- var appliedRules = false;\n- for (var i = 0, len = rules.length; i < len; i++) {\n- rule = rules[i];\n- // does the rule apply?\n- var applies = rule.evaluate(feature);\n-\n- if (applies) {\n- if (rule instanceof OpenLayers.Rule && rule.elseFilter) {\n- elseRules.push(rule);\n- } else {\n- appliedRules = true;\n- this.applySymbolizer(rule, style, feature);\n- }\n- }\n- }\n-\n- // if no other rules apply, apply the rules with else filters\n- if (appliedRules == false && elseRules.length > 0) {\n- appliedRules = true;\n- for (var i = 0, len = elseRules.length; i < len; i++) {\n- this.applySymbolizer(elseRules[i], style, feature);\n- }\n- }\n-\n- // don't display if there were rules but none applied\n- if (rules.length > 0 && appliedRules == false) {\n- style.display = \"none\";\n- }\n-\n- if (style.label != null && typeof style.label !== \"string\") {\n- style.label = String(style.label);\n- }\n-\n- return style;\n- },\n-\n- /**\n- * Method: applySymbolizer\n- *\n- * Parameters:\n- * rule - {}\n- * style - {Object}\n- * feature - {}\n- *\n- * Returns:\n- * {Object} A style with new symbolizer applied.\n- */\n- applySymbolizer: function(rule, style, feature) {\n- var symbolizerPrefix = feature.geometry ?\n- this.getSymbolizerPrefix(feature.geometry) :\n- OpenLayers.Style.SYMBOLIZER_PREFIXES[0];\n-\n- var symbolizer = rule.symbolizer[symbolizerPrefix] || rule.symbolizer;\n-\n- if (this.defaultsPerSymbolizer === true) {\n- var defaults = this.defaultStyle;\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- pointRadius: defaults.pointRadius\n- });\n- if (symbolizer.stroke === true || symbolizer.graphic === true) {\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- strokeWidth: defaults.strokeWidth,\n- strokeColor: defaults.strokeColor,\n- strokeOpacity: defaults.strokeOpacity,\n- strokeDashstyle: defaults.strokeDashstyle,\n- strokeLinecap: defaults.strokeLinecap\n- });\n- }\n- if (symbolizer.fill === true || symbolizer.graphic === true) {\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- fillColor: defaults.fillColor,\n- fillOpacity: defaults.fillOpacity\n- });\n- }\n- if (symbolizer.graphic === true) {\n- OpenLayers.Util.applyDefaults(symbolizer, {\n- pointRadius: this.defaultStyle.pointRadius,\n- externalGraphic: this.defaultStyle.externalGraphic,\n- graphicName: this.defaultStyle.graphicName,\n- graphicOpacity: this.defaultStyle.graphicOpacity,\n- graphicWidth: this.defaultStyle.graphicWidth,\n- graphicHeight: this.defaultStyle.graphicHeight,\n- graphicXOffset: this.defaultStyle.graphicXOffset,\n- graphicYOffset: this.defaultStyle.graphicYOffset\n- });\n- }\n- }\n-\n- // merge the style with the current style\n- return this.createLiterals(\n- OpenLayers.Util.extend(style, symbolizer), feature);\n- },\n-\n- /**\n- * Method: createLiterals\n- * creates literals for all style properties that have an entry in\n- * .\n- * \n- * Parameters:\n- * style - {Object} style to create literals for. Will be modified\n- * inline.\n- * feature - {Object}\n- * \n- * Returns:\n- * {Object} the modified style\n- */\n- createLiterals: function(style, feature) {\n- var context = OpenLayers.Util.extend({}, feature.attributes || feature.data);\n- OpenLayers.Util.extend(context, this.context);\n-\n- for (var i in this.propertyStyles) {\n- style[i] = OpenLayers.Style.createLiteral(style[i], context, feature, i);\n- }\n- return style;\n- },\n-\n- /**\n- * Method: findPropertyStyles\n- * Looks into all rules for this style and the defaultStyle to collect\n- * all the style hash property names containing ${...} strings that have\n- * to be replaced using the createLiteral method before returning them.\n- * \n- * Returns:\n- * {Object} hash of property names that need createLiteral parsing. The\n- * name of the property is the key, and the value is true;\n- */\n- findPropertyStyles: function() {\n- var propertyStyles = {};\n-\n- // check the default style\n- var style = this.defaultStyle;\n- this.addPropertyStyles(propertyStyles, style);\n-\n- // walk through all rules to check for properties in their symbolizer\n- var rules = this.rules;\n- var symbolizer, value;\n- for (var i = 0, len = rules.length; i < len; i++) {\n- symbolizer = rules[i].symbolizer;\n- for (var key in symbolizer) {\n- value = symbolizer[key];\n- if (typeof value == \"object\") {\n- // symbolizer key is \"Point\", \"Line\" or \"Polygon\"\n- this.addPropertyStyles(propertyStyles, value);\n- } else {\n- // symbolizer is a hash of style properties\n- this.addPropertyStyles(propertyStyles, symbolizer);\n- break;\n- }\n- }\n- }\n- return propertyStyles;\n- },\n-\n- /**\n- * Method: addPropertyStyles\n- * \n- * Parameters:\n- * propertyStyles - {Object} hash to add new property styles to. Will be\n- * modified inline\n- * symbolizer - {Object} search this symbolizer for property styles\n- * \n- * Returns:\n- * {Object} propertyStyles hash\n- */\n- addPropertyStyles: function(propertyStyles, symbolizer) {\n- var property;\n- for (var key in symbolizer) {\n- property = symbolizer[key];\n- if (typeof property == \"string\" &&\n- property.match(/\\$\\{\\w+\\}/)) {\n- propertyStyles[key] = true;\n- }\n- }\n- return propertyStyles;\n- },\n-\n- /**\n- * APIMethod: addRules\n- * Adds rules to this style.\n- * \n- * Parameters:\n- * rules - {Array()}\n- */\n- addRules: function(rules) {\n- Array.prototype.push.apply(this.rules, rules);\n- this.propertyStyles = this.findPropertyStyles();\n- },\n-\n- /**\n- * APIMethod: setDefaultStyle\n- * Sets the default style for this style object.\n- * \n- * Parameters:\n- * style - {Object} Hash of style properties\n- */\n- setDefaultStyle: function(style) {\n- this.defaultStyle = style;\n- this.propertyStyles = this.findPropertyStyles();\n- },\n-\n- /**\n- * Method: getSymbolizerPrefix\n- * Returns the correct symbolizer prefix according to the\n- * geometry type of the passed geometry\n- * \n- * Parameters:\n- * geometry - {}\n- * \n- * Returns:\n- * {String} key of the according symbolizer\n- */\n- getSymbolizerPrefix: function(geometry) {\n- var prefixes = OpenLayers.Style.SYMBOLIZER_PREFIXES;\n- for (var i = 0, len = prefixes.length; i < len; i++) {\n- if (geometry.CLASS_NAME.indexOf(prefixes[i]) != -1) {\n- return prefixes[i];\n- }\n- }\n- },\n-\n- /**\n- * APIMethod: clone\n- * Clones this style.\n- * \n- * Returns:\n- * {} Clone of this style.\n- */\n- clone: function() {\n- var options = OpenLayers.Util.extend({}, this);\n- // clone rules\n- if (this.rules) {\n- options.rules = [];\n- for (var i = 0, len = this.rules.length; i < len; ++i) {\n- options.rules.push(this.rules[i].clone());\n- }\n- }\n- // clone context\n- options.context = this.context && OpenLayers.Util.extend({}, this.context);\n- //clone default style\n- var defaultStyle = OpenLayers.Util.extend({}, this.defaultStyle);\n- return new OpenLayers.Style(defaultStyle, options);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Style\"\n-});\n-\n-\n-/**\n- * Function: createLiteral\n- * converts a style value holding a combination of PropertyName and Literal\n- * into a Literal, taking the property values from the passed features.\n- * \n- * Parameters:\n- * value - {String} value to parse. If this string contains a construct like\n- * \"foo ${bar}\", then \"foo \" will be taken as literal, and \"${bar}\"\n- * will be replaced by the value of the \"bar\" attribute of the passed\n- * feature.\n- * context - {Object} context to take attribute values from\n- * feature - {} optional feature to pass to\n- * for evaluating functions in the\n- * context.\n- * property - {String} optional, name of the property for which the literal is\n- * being created for evaluating functions in the context.\n- * \n- * Returns:\n- * {String} the parsed value. In the example of the value parameter above, the\n- * result would be \"foo valueOfBar\", assuming that the passed feature has an\n- * attribute named \"bar\" with the value \"valueOfBar\".\n- */\n-OpenLayers.Style.createLiteral = function(value, context, feature, property) {\n- if (typeof value == \"string\" && value.indexOf(\"${\") != -1) {\n- value = OpenLayers.String.format(value, context, [feature, property]);\n- value = (isNaN(value) || !value) ? value : parseFloat(value);\n- }\n- return value;\n-};\n-\n-/**\n- * Constant: OpenLayers.Style.SYMBOLIZER_PREFIXES\n- * {Array} prefixes of the sld symbolizers. These are the\n- * same as the main geometry types\n- */\n-OpenLayers.Style.SYMBOLIZER_PREFIXES = ['Point', 'Line', 'Polygon', 'Text',\n- 'Raster'\n-];\n-/* ======================================================================\n OpenLayers/Filter.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -24416,429 +25700,784 @@\n OpenLayers.Util.extend(this, options);\n },\n \n CLASS_NAME: \"OpenLayers.WPSProcess.ChainLink\"\n \n });\n /* ======================================================================\n- OpenLayers/Format/WPSDescribeProcess.js\n+ OpenLayers/Handler.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Events.js\n */\n \n /**\n- * Class: OpenLayers.Format.WPSDescribeProcess\n- * Read WPS DescribeProcess responses. \n+ * Class: OpenLayers.Handler\n+ * Base class to construct a higher-level handler for event sequences. All\n+ * handlers have activate and deactivate methods. In addition, they have\n+ * methods named like browser events. When a handler is activated, any\n+ * additional methods named like a browser event is registered as a\n+ * listener for the corresponding event. When a handler is deactivated,\n+ * those same methods are unregistered as event listeners.\n *\n- * Inherits from:\n- * - \n+ * Handlers also typically have a callbacks object with keys named like\n+ * the abstracted events or event sequences that they are in charge of\n+ * handling. The controls that wrap handlers define the methods that\n+ * correspond to these abstract events - so instead of listening for\n+ * individual browser events, they only listen for the abstract events\n+ * defined by the handler.\n+ * \n+ * Handlers are created by controls, which ultimately have the responsibility\n+ * of making changes to the the state of the application. Handlers\n+ * themselves may make temporary changes, but in general are expected to\n+ * return the application in the same state that they found it.\n */\n-OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(\n- OpenLayers.Format.XML, {\n+OpenLayers.Handler = OpenLayers.Class({\n \n- /**\n- * Constant: VERSION\n- * {String} 1.0.0\n- */\n- VERSION: \"1.0.0\",\n+ /**\n+ * Property: id\n+ * {String}\n+ */\n+ id: null,\n \n- /**\n- * Property: namespaces\n- * {Object} Mapping of namespace aliases to namespace URIs.\n- */\n- namespaces: {\n- wps: \"http://www.opengis.net/wps/1.0.0\",\n- ows: \"http://www.opengis.net/ows/1.1\",\n- xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n- },\n+ /**\n+ * APIProperty: control\n+ * {}. The control that initialized this handler. The\n+ * control is assumed to have a valid map property - that map is used\n+ * in the handler's own setMap method.\n+ */\n+ control: null,\n \n- /**\n- * Property: schemaLocation\n- * {String} Schema location\n- */\n- schemaLocation: \"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\",\n+ /**\n+ * Property: map\n+ * {}\n+ */\n+ map: null,\n \n- /**\n- * Property: defaultPrefix\n- */\n- defaultPrefix: \"wps\",\n+ /**\n+ * APIProperty: keyMask\n+ * {Integer} Use bitwise operators and one or more of the OpenLayers.Handler\n+ * constants to construct a keyMask. The keyMask is used by\n+ * . If the keyMask matches the combination of keys\n+ * down on an event, checkModifiers returns true.\n+ *\n+ * Example:\n+ * (code)\n+ * // handler only responds if the Shift key is down\n+ * handler.keyMask = OpenLayers.Handler.MOD_SHIFT;\n+ *\n+ * // handler only responds if Ctrl-Shift is down\n+ * handler.keyMask = OpenLayers.Handler.MOD_SHIFT |\n+ * OpenLayers.Handler.MOD_CTRL;\n+ * (end)\n+ */\n+ keyMask: null,\n \n- /**\n- * Property: regExes\n- * Compiled regular expressions for manipulating strings.\n- */\n- regExes: {\n- trimSpace: (/^\\s*|\\s*$/g),\n- removeSpace: (/\\s*/g),\n- splitSpace: (/\\s+/),\n- trimComma: (/\\s*,\\s*/g)\n- },\n+ /**\n+ * Property: active\n+ * {Boolean}\n+ */\n+ active: false,\n \n- /**\n- * Constructor: OpenLayers.Format.WPSDescribeProcess\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n- */\n+ /**\n+ * Property: evt\n+ * {Event} This property references the last event handled by the handler.\n+ * Note that this property is not part of the stable API. Use of the\n+ * evt property should be restricted to controls in the library\n+ * or other applications that are willing to update with changes to\n+ * the OpenLayers code.\n+ */\n+ evt: null,\n \n- /**\n- * APIMethod: read\n- * Parse a WPS DescribeProcess and return an object with its information.\n- * \n- * Parameters: \n- * data - {String} or {DOMElement} data to read/parse.\n- *\n- * Returns:\n- * {Object}\n- */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ /**\n+ * Property: touch\n+ * {Boolean} Indicates the support of touch events. When touch events are \n+ * started touch will be true and all mouse related listeners will do \n+ * nothing.\n+ */\n+ touch: false,\n+\n+ /**\n+ * Constructor: OpenLayers.Handler\n+ * Construct a handler.\n+ *\n+ * Parameters:\n+ * control - {} The control that initialized this\n+ * handler. The control is assumed to have a valid map property; that\n+ * map is used in the handler's own setMap method. If a map property\n+ * is present in the options argument it will be used instead.\n+ * callbacks - {Object} An object whose properties correspond to abstracted\n+ * events or sequences of browser events. The values for these\n+ * properties are functions defined by the control that get called by\n+ * the handler.\n+ * options - {Object} An optional object whose properties will be set on\n+ * the handler.\n+ */\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.control = control;\n+ this.callbacks = callbacks;\n+\n+ var map = this.map || control.map;\n+ if (map) {\n+ this.setMap(map);\n+ }\n+\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\n+\n+ /**\n+ * Method: setMap\n+ */\n+ setMap: function(map) {\n+ this.map = map;\n+ },\n+\n+ /**\n+ * Method: checkModifiers\n+ * Check the keyMask on the handler. If no is set, this always\n+ * returns true. If a is set and it matches the combination\n+ * of keys down on an event, this returns true.\n+ *\n+ * Returns:\n+ * {Boolean} The keyMask matches the keys down on an event.\n+ */\n+ checkModifiers: function(evt) {\n+ if (this.keyMask == null) {\n+ return true;\n+ }\n+ /* calculate the keyboard modifier mask for this event */\n+ var keyModifiers =\n+ (evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) |\n+ (evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) |\n+ (evt.altKey ? OpenLayers.Handler.MOD_ALT : 0) |\n+ (evt.metaKey ? OpenLayers.Handler.MOD_META : 0);\n+\n+ /* if it differs from the handler object's key mask,\n+ bail out of the event handler */\n+ return (keyModifiers == this.keyMask);\n+ },\n+\n+ /**\n+ * APIMethod: activate\n+ * Turn on the handler. Returns false if the handler was already active.\n+ * \n+ * Returns: \n+ * {Boolean} The handler was activated.\n+ */\n+ activate: function() {\n+ if (this.active) {\n+ return false;\n+ }\n+ // register for event handlers defined on this class.\n+ var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n+ for (var i = 0, len = events.length; i < len; i++) {\n+ if (this[events[i]]) {\n+ this.register(events[i], this[events[i]]);\n }\n- if (data && data.nodeType == 9) {\n- data = data.documentElement;\n+ }\n+ this.active = true;\n+ return true;\n+ },\n+\n+ /**\n+ * APIMethod: deactivate\n+ * Turn off the handler. Returns false if the handler was already inactive.\n+ * \n+ * Returns:\n+ * {Boolean} The handler was deactivated.\n+ */\n+ deactivate: function() {\n+ if (!this.active) {\n+ return false;\n+ }\n+ // unregister event handlers defined on this class.\n+ var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n+ for (var i = 0, len = events.length; i < len; i++) {\n+ if (this[events[i]]) {\n+ this.unregister(events[i], this[events[i]]);\n }\n- var info = {};\n- this.readNode(data, info);\n- return info;\n- },\n+ }\n+ this.touch = false;\n+ this.active = false;\n+ return true;\n+ },\n \n- /**\n- * Property: readers\n- * Contains public functions, grouped by namespace prefix, that will\n- * be applied when a namespaced node is found matching the function\n- * name. The function will be applied in the scope of this parser\n- * with two arguments: the node being read and a context object passed\n- * from the parent.\n- */\n- readers: {\n- \"wps\": {\n- \"ProcessDescriptions\": function(node, obj) {\n- obj.processDescriptions = {};\n- this.readChildNodes(node, obj.processDescriptions);\n- },\n- \"ProcessDescription\": function(node, processDescriptions) {\n- var processVersion = this.getAttributeNS(node, this.namespaces.wps, \"processVersion\");\n- var processDescription = {\n- processVersion: processVersion,\n- statusSupported: (node.getAttribute(\"statusSupported\") === \"true\"),\n- storeSupported: (node.getAttribute(\"storeSupported\") === \"true\")\n- };\n- this.readChildNodes(node, processDescription);\n- processDescriptions[processDescription.identifier] = processDescription;\n- },\n- \"DataInputs\": function(node, processDescription) {\n- processDescription.dataInputs = [];\n- this.readChildNodes(node, processDescription.dataInputs);\n- },\n- \"ProcessOutputs\": function(node, processDescription) {\n- processDescription.processOutputs = [];\n- this.readChildNodes(node, processDescription.processOutputs);\n- },\n- \"Output\": function(node, processOutputs) {\n- var output = {};\n- this.readChildNodes(node, output);\n- processOutputs.push(output);\n- },\n- \"ComplexOutput\": function(node, output) {\n- output.complexOutput = {};\n- this.readChildNodes(node, output.complexOutput);\n- },\n- \"LiteralOutput\": function(node, output) {\n- output.literalOutput = {};\n- this.readChildNodes(node, output.literalOutput);\n- },\n- \"Input\": function(node, dataInputs) {\n- var input = {\n- maxOccurs: parseInt(node.getAttribute(\"maxOccurs\")),\n- minOccurs: parseInt(node.getAttribute(\"minOccurs\"))\n- };\n- this.readChildNodes(node, input);\n- dataInputs.push(input);\n- },\n- \"BoundingBoxData\": function(node, input) {\n- input.boundingBoxData = {};\n- this.readChildNodes(node, input.boundingBoxData);\n- },\n- \"CRS\": function(node, obj) {\n- if (!obj.CRSs) {\n- obj.CRSs = {};\n- }\n- obj.CRSs[this.getChildValue(node)] = true;\n- },\n- \"LiteralData\": function(node, input) {\n- input.literalData = {};\n- this.readChildNodes(node, input.literalData);\n- },\n- \"ComplexData\": function(node, input) {\n- input.complexData = {};\n- this.readChildNodes(node, input.complexData);\n- },\n- \"Default\": function(node, complexData) {\n- complexData[\"default\"] = {};\n- this.readChildNodes(node, complexData[\"default\"]);\n- },\n- \"Supported\": function(node, complexData) {\n- complexData[\"supported\"] = {};\n- this.readChildNodes(node, complexData[\"supported\"]);\n- },\n- \"Format\": function(node, obj) {\n- var format = {};\n- this.readChildNodes(node, format);\n- if (!obj.formats) {\n- obj.formats = {};\n- }\n- obj.formats[format.mimeType] = true;\n- },\n- \"MimeType\": function(node, format) {\n- format.mimeType = this.getChildValue(node);\n+ /**\n+ * Method: startTouch\n+ * Start touch events, this method must be called by subclasses in \n+ * \"touchstart\" method. When touch events are started will be\n+ * true and all mouse related listeners will do nothing.\n+ */\n+ startTouch: function() {\n+ if (!this.touch) {\n+ this.touch = true;\n+ var events = [\n+ \"mousedown\", \"mouseup\", \"mousemove\", \"click\", \"dblclick\",\n+ \"mouseout\"\n+ ];\n+ for (var i = 0, len = events.length; i < len; i++) {\n+ if (this[events[i]]) {\n+ this.unregister(events[i], this[events[i]]);\n }\n- },\n- \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n- },\n+ }\n+ }\n+ },\n+\n+ /**\n+ * Method: callback\n+ * Trigger the control's named callback with the given arguments\n+ *\n+ * Parameters:\n+ * name - {String} The key for the callback that is one of the properties\n+ * of the handler's callbacks object.\n+ * args - {Array(*)} An array of arguments (any type) with which to call \n+ * the callback (defined by the control).\n+ */\n+ callback: function(name, args) {\n+ if (name && this.callbacks[name]) {\n+ this.callbacks[name].apply(this.control, args);\n+ }\n+ },\n+\n+ /**\n+ * Method: register\n+ * register an event on the map\n+ */\n+ register: function(name, method) {\n+ // TODO: deal with registerPriority in 3.0\n+ this.map.events.registerPriority(name, this, method);\n+ this.map.events.registerPriority(name, this, this.setEvent);\n+ },\n+\n+ /**\n+ * Method: unregister\n+ * unregister an event from the map\n+ */\n+ unregister: function(name, method) {\n+ this.map.events.unregister(name, this, method);\n+ this.map.events.unregister(name, this, this.setEvent);\n+ },\n+\n+ /**\n+ * Method: setEvent\n+ * With each registered browser event, the handler sets its own evt\n+ * property. This property can be accessed by controls if needed\n+ * to get more information about the event that the handler is\n+ * processing.\n+ *\n+ * This allows modifier keys on the event to be checked (alt, shift, ctrl,\n+ * and meta cannot be checked with the keyboard handler). For a\n+ * control to determine which modifier keys are associated with the\n+ * event that a handler is currently processing, it should access\n+ * (code)handler.evt.altKey || handler.evt.shiftKey ||\n+ * handler.evt.ctrlKey || handler.evt.metaKey(end).\n+ *\n+ * Parameters:\n+ * evt - {Event} The browser event.\n+ */\n+ setEvent: function(evt) {\n+ this.evt = evt;\n+ return true;\n+ },\n+\n+ /**\n+ * Method: destroy\n+ * Deconstruct the handler.\n+ */\n+ destroy: function() {\n+ // unregister event listeners\n+ this.deactivate();\n+ // eliminate circular references\n+ this.control = this.map = null;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler\"\n+});\n+\n+/**\n+ * Constant: OpenLayers.Handler.MOD_NONE\n+ * If set as the , returns false if any key is down.\n+ */\n+OpenLayers.Handler.MOD_NONE = 0;\n+\n+/**\n+ * Constant: OpenLayers.Handler.MOD_SHIFT\n+ * If set as the , returns false if Shift is down.\n+ */\n+OpenLayers.Handler.MOD_SHIFT = 1;\n+\n+/**\n+ * Constant: OpenLayers.Handler.MOD_CTRL\n+ * If set as the , returns false if Ctrl is down.\n+ */\n+OpenLayers.Handler.MOD_CTRL = 2;\n+\n+/**\n+ * Constant: OpenLayers.Handler.MOD_ALT\n+ * If set as the , returns false if Alt is down.\n+ */\n+OpenLayers.Handler.MOD_ALT = 4;\n+\n+/**\n+ * Constant: OpenLayers.Handler.MOD_META\n+ * If set as the , returns false if Cmd is down.\n+ */\n+OpenLayers.Handler.MOD_META = 8;\n \n- CLASS_NAME: \"OpenLayers.Format.WPSDescribeProcess\"\n \n- });\n /* ======================================================================\n- OpenLayers/WPSClient.js\n+ OpenLayers/Renderer.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/SingleFile.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/WPSProcess.js\n- * @requires OpenLayers/Format/WPSDescribeProcess.js\n- * @requires OpenLayers/Request.js\n+ * Class: OpenLayers.Renderer \n+ * This is the base class for all renderers.\n+ *\n+ * This is based on a merger code written by Paul Spencer and Bertil Chapuis.\n+ * It is largely composed of virtual functions that are to be implemented\n+ * in technology-specific subclasses, but there is some generic code too.\n+ * \n+ * The functions that *are* implemented here merely deal with the maintenance\n+ * of the size and extent variables, as well as the cached 'resolution' \n+ * value. \n+ * \n+ * A note to the user that all subclasses should use getResolution() instead\n+ * of directly accessing this.resolution in order to correctly use the \n+ * cacheing system.\n+ *\n */\n+OpenLayers.Renderer = OpenLayers.Class({\n \n-/**\n- * Class: OpenLayers.WPSClient\n- * High level API for interaction with Web Processing Services (WPS).\n- * An instance is used to create \n- * instances for servers known to the WPSClient. The WPSClient also caches\n- * DescribeProcess responses to reduce the number of requests sent to servers\n- * when processes are created.\n- */\n-OpenLayers.WPSClient = OpenLayers.Class({\n+ /** \n+ * Property: container\n+ * {DOMElement} \n+ */\n+ container: null,\n \n /**\n- * Property: servers\n- * {Object} Service metadata, keyed by a local identifier.\n- *\n- * Properties:\n- * url - {String} the url of the server\n- * version - {String} WPS version of the server\n- * processDescription - {Object} Cache of raw DescribeProcess\n- * responses, keyed by process identifier.\n+ * Property: root\n+ * {DOMElement}\n */\n- servers: null,\n+ root: null,\n+\n+ /** \n+ * Property: extent\n+ * {}\n+ */\n+ extent: null,\n \n /**\n- * Property: version\n- * {String} The default WPS version to use if none is configured. Default\n- * is '1.0.0'.\n+ * Property: locked\n+ * {Boolean} If the renderer is currently in a state where many things\n+ * are changing, the 'locked' property is set to true. This means \n+ * that renderers can expect at least one more drawFeature event to be\n+ * called with the 'locked' property set to 'true': In some renderers,\n+ * this might make sense to use as a 'only update local information'\n+ * flag. \n */\n- version: '1.0.0',\n+ locked: false,\n+\n+ /** \n+ * Property: size\n+ * {} \n+ */\n+ size: null,\n \n /**\n- * Property: lazy\n- * {Boolean} Should the DescribeProcess be deferred until a process is\n- * fully configured? Default is false.\n+ * Property: resolution\n+ * {Float} cache of current map resolution\n */\n- lazy: false,\n+ resolution: null,\n \n /**\n- * Property: events\n- * {}\n- *\n- * Supported event types:\n- * describeprocess - Fires when the process description is available.\n- * Listeners receive an object with a 'raw' property holding the raw\n- * DescribeProcess response, and an 'identifier' property holding the\n- * process identifier of the described process.\n+ * Property: map \n+ * {} Reference to the map -- this is set in Vector's setMap()\n */\n- events: null,\n+ map: null,\n \n /**\n- * Constructor: OpenLayers.WPSClient\n+ * Property: featureDx\n+ * {Number} Feature offset in x direction. Will be calculated for and\n+ * applied to the current feature while rendering (see\n+ * ).\n+ */\n+ featureDx: 0,\n+\n+ /**\n+ * Constructor: OpenLayers.Renderer \n *\n * Parameters:\n- * options - {Object} Object whose properties will be set on the instance.\n+ * containerID - {} \n+ * options - {Object} options for this renderer. See sublcasses for\n+ * supported options.\n+ */\n+ initialize: function(containerID, options) {\n+ this.container = OpenLayers.Util.getElement(containerID);\n+ OpenLayers.Util.extend(this, options);\n+ },\n+\n+ /**\n+ * APIMethod: destroy\n+ */\n+ destroy: function() {\n+ this.container = null;\n+ this.extent = null;\n+ this.size = null;\n+ this.resolution = null;\n+ this.map = null;\n+ },\n+\n+ /**\n+ * APIMethod: supported\n+ * This should be overridden by specific subclasses\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the browser supports the renderer class\n+ */\n+ supported: function() {\n+ return false;\n+ },\n+\n+ /**\n+ * Method: setExtent\n+ * Set the visible part of the layer.\n *\n- * Avaliable options:\n- * servers - {Object} Mandatory. Service metadata, keyed by a local\n- * identifier. Can either be a string with the service url or an\n- * object literal with additional metadata:\n+ * Resolution has probably changed, so we nullify the resolution \n+ * cache (this.resolution) -- this way it will be re-computed when \n+ * next it is needed.\n+ * We nullify the resolution cache (this.resolution) if resolutionChanged\n+ * is set to true - this way it will be re-computed on the next\n+ * getResolution() request.\n *\n- * (code)\n- * servers: {\n- * local: '/geoserver/wps'\n- * }, {\n- * opengeo: {\n- * url: 'http://demo.opengeo.org/geoserver/wps',\n- * version: '1.0.0'\n- * }\n- * }\n- * (end)\n+ * Parameters:\n+ * extent - {}\n+ * resolutionChanged - {Boolean}\n *\n- * lazy - {Boolean} Optional. Set to true if DescribeProcess should not be\n- * requested until a process is fully configured. Default is false.\n+ * Returns:\n+ * {Boolean} true to notify the layer that the new extent does not exceed\n+ * the coordinate range, and the features will not need to be redrawn.\n+ * False otherwise.\n */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.events = new OpenLayers.Events(this);\n- this.servers = {};\n- for (var s in options.servers) {\n- this.servers[s] = typeof options.servers[s] == 'string' ? {\n- url: options.servers[s],\n- version: this.version,\n- processDescription: {}\n- } : options.servers[s];\n+ setExtent: function(extent, resolutionChanged) {\n+ this.extent = extent.clone();\n+ if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n+ var ratio = extent.getWidth() / this.map.getExtent().getWidth(),\n+ extent = extent.scale(1 / ratio);\n+ this.extent = extent.wrapDateLine(this.map.getMaxExtent()).scale(ratio);\n+ }\n+ if (resolutionChanged) {\n+ this.resolution = null;\n }\n+ return true;\n },\n \n /**\n- * APIMethod: execute\n- * Shortcut to execute a process with a single function call. This is\n- * equivalent to using and then calling execute on the\n- * process.\n+ * Method: setSize\n+ * Sets the size of the drawing surface.\n+ * \n+ * Resolution has probably changed, so we nullify the resolution \n+ * cache (this.resolution) -- this way it will be re-computed when \n+ * next it is needed.\n *\n * Parameters:\n- * options - {Object} Options for the execute operation.\n- *\n- * Available options:\n- * server - {String} Mandatory. One of the local identifiers of the\n- * configured servers.\n- * process - {String} Mandatory. A process identifier known to the\n- * server.\n- * inputs - {Object} The inputs for the process, keyed by input identifier.\n- * For spatial data inputs, the value of an input is usually an\n- * , an or an array of\n- * geometries or features.\n- * output - {String} The identifier of an output to parse. Optional. If not\n- * provided, the first output will be parsed.\n- * success - {Function} Callback to call when the process is complete.\n- * This function is called with an outputs object as argument, which\n- * will have a property with the identifier of the requested output\n- * (e.g. 'result'). For processes that generate spatial output, the\n- * value will either be a single or an\n- * array of features.\n- * scope - {Object} Optional scope for the success callback.\n+ * size - {} \n */\n- execute: function(options) {\n- var process = this.getProcess(options.server, options.process);\n- process.execute({\n- inputs: options.inputs,\n- success: options.success,\n- scope: options.scope\n- });\n+ setSize: function(size) {\n+ this.size = size.clone();\n+ this.resolution = null;\n+ },\n+\n+ /** \n+ * Method: getResolution\n+ * Uses cached copy of resolution if available to minimize computing\n+ * \n+ * Returns:\n+ * {Float} The current map's resolution\n+ */\n+ getResolution: function() {\n+ this.resolution = this.resolution || this.map.getResolution();\n+ return this.resolution;\n },\n \n /**\n- * APIMethod: getProcess\n- * Creates an .\n+ * Method: drawFeature\n+ * Draw the feature. The optional style argument can be used\n+ * to override the feature's own style. This method should only\n+ * be called from layer.drawFeature().\n *\n * Parameters:\n- * serverID - {String} Local identifier from the servers that this instance\n- * was constructed with.\n- * processID - {String} Process identifier known to the server.\n- *\n+ * feature - {} \n+ * style - {}\n+ * \n * Returns:\n- * {}\n+ * {Boolean} true if the feature has been drawn completely, false if not,\n+ * undefined if the feature had no geometry\n */\n- getProcess: function(serverID, processID) {\n- var process = new OpenLayers.WPSProcess({\n- client: this,\n- server: serverID,\n- identifier: processID\n- });\n- if (!this.lazy) {\n- process.describe();\n+ drawFeature: function(feature, style) {\n+ if (style == null) {\n+ style = feature.style;\n+ }\n+ if (feature.geometry) {\n+ var bounds = feature.geometry.getBounds();\n+ if (bounds) {\n+ var worldBounds;\n+ if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n+ worldBounds = this.map.getMaxExtent();\n+ }\n+ if (!bounds.intersectsBounds(this.extent, {\n+ worldBounds: worldBounds\n+ })) {\n+ style = {\n+ display: \"none\"\n+ };\n+ } else {\n+ this.calculateFeatureDx(bounds, worldBounds);\n+ }\n+ var rendered = this.drawGeometry(feature.geometry, style, feature.id);\n+ if (style.display != \"none\" && style.label && rendered !== false) {\n+\n+ var location = feature.geometry.getCentroid();\n+ if (style.labelXOffset || style.labelYOffset) {\n+ var xOffset = isNaN(style.labelXOffset) ? 0 : style.labelXOffset;\n+ var yOffset = isNaN(style.labelYOffset) ? 0 : style.labelYOffset;\n+ var res = this.getResolution();\n+ location.move(xOffset * res, yOffset * res);\n+ }\n+ this.drawText(feature.id, style, location);\n+ } else {\n+ this.removeText(feature.id);\n+ }\n+ return rendered;\n+ }\n }\n- return process;\n },\n \n /**\n- * Method: describeProcess\n+ * Method: calculateFeatureDx\n+ * {Number} Calculates the feature offset in x direction. Looking at the\n+ * center of the feature bounds and the renderer extent, we calculate how\n+ * many world widths the two are away from each other. This distance is\n+ * used to shift the feature as close as possible to the center of the\n+ * current enderer extent, which ensures that the feature is visible in the\n+ * current viewport.\n *\n * Parameters:\n- * serverID - {String} Identifier of the server\n- * processID - {String} Identifier of the requested process\n- * callback - {Function} Callback to call when the description is available\n- * scope - {Object} Optional execution scope for the callback function\n+ * bounds - {} Bounds of the feature\n+ * worldBounds - {} Bounds of the world\n */\n- describeProcess: function(serverID, processID, callback, scope) {\n- var server = this.servers[serverID];\n- if (!server.processDescription[processID]) {\n- if (!(processID in server.processDescription)) {\n- // set to null so we know a describeFeature request is pending\n- server.processDescription[processID] = null;\n- OpenLayers.Request.GET({\n- url: server.url,\n- params: {\n- SERVICE: 'WPS',\n- VERSION: server.version,\n- REQUEST: 'DescribeProcess',\n- IDENTIFIER: processID\n- },\n- success: function(response) {\n- server.processDescription[processID] = response.responseText;\n- this.events.triggerEvent('describeprocess', {\n- identifier: processID,\n- raw: response.responseText\n- });\n- },\n- scope: this\n- });\n- } else {\n- // pending request\n- this.events.register('describeprocess', this, function describe(evt) {\n- if (evt.identifier === processID) {\n- this.events.unregister('describeprocess', this, describe);\n- callback.call(scope, evt.raw);\n- }\n- });\n- }\n- } else {\n- window.setTimeout(function() {\n- callback.call(scope, server.processDescription[processID]);\n- }, 0);\n+ calculateFeatureDx: function(bounds, worldBounds) {\n+ this.featureDx = 0;\n+ if (worldBounds) {\n+ var worldWidth = worldBounds.getWidth(),\n+ rendererCenterX = (this.extent.left + this.extent.right) / 2,\n+ featureCenterX = (bounds.left + bounds.right) / 2,\n+ worldsAway = Math.round((featureCenterX - rendererCenterX) / worldWidth);\n+ this.featureDx = worldsAway * worldWidth;\n }\n },\n \n+ /** \n+ * Method: drawGeometry\n+ * \n+ * Draw a geometry. This should only be called from the renderer itself.\n+ * Use layer.drawFeature() from outside the renderer.\n+ * virtual function\n+ *\n+ * Parameters:\n+ * geometry - {} \n+ * style - {Object} \n+ * featureId - {} \n+ */\n+ drawGeometry: function(geometry, style, featureId) {},\n+\n /**\n- * Method: destroy\n+ * Method: drawText\n+ * Function for drawing text labels.\n+ * This method is only called by the renderer itself.\n+ * \n+ * Parameters: \n+ * featureId - {String}\n+ * style -\n+ * location - {}\n */\n- destroy: function() {\n- this.events.destroy();\n- this.events = null;\n- this.servers = null;\n+ drawText: function(featureId, style, location) {},\n+\n+ /**\n+ * Method: removeText\n+ * Function for removing text labels.\n+ * This method is only called by the renderer itself.\n+ * \n+ * Parameters: \n+ * featureId - {String}\n+ */\n+ removeText: function(featureId) {},\n+\n+ /**\n+ * Method: clear\n+ * Clear all vectors from the renderer.\n+ * virtual function.\n+ */\n+ clear: function() {},\n+\n+ /**\n+ * Method: getFeatureIdFromEvent\n+ * Returns a feature id from an event on the renderer. \n+ * How this happens is specific to the renderer. This should be\n+ * called from layer.getFeatureFromEvent().\n+ * Virtual function.\n+ * \n+ * Parameters:\n+ * evt - {} \n+ *\n+ * Returns:\n+ * {String} A feature id or undefined.\n+ */\n+ getFeatureIdFromEvent: function(evt) {},\n+\n+ /**\n+ * Method: eraseFeatures \n+ * This is called by the layer to erase features\n+ * \n+ * Parameters:\n+ * features - {Array()} \n+ */\n+ eraseFeatures: function(features) {\n+ if (!(OpenLayers.Util.isArray(features))) {\n+ features = [features];\n+ }\n+ for (var i = 0, len = features.length; i < len; ++i) {\n+ var feature = features[i];\n+ this.eraseGeometry(feature.geometry, feature.id);\n+ this.removeText(feature.id);\n+ }\n },\n \n- CLASS_NAME: 'OpenLayers.WPSClient'\n+ /**\n+ * Method: eraseGeometry\n+ * Remove a geometry from the renderer (by id).\n+ * virtual function.\n+ * \n+ * Parameters:\n+ * geometry - {} \n+ * featureId - {String}\n+ */\n+ eraseGeometry: function(geometry, featureId) {},\n+\n+ /**\n+ * Method: moveRoot\n+ * moves this renderer's root to a (different) renderer.\n+ * To be implemented by subclasses that require a common renderer root for\n+ * feature selection.\n+ * \n+ * Parameters:\n+ * renderer - {} target renderer for the moved root\n+ */\n+ moveRoot: function(renderer) {},\n+\n+ /**\n+ * Method: getRenderLayerId\n+ * Gets the layer that this renderer's output appears on. If moveRoot was\n+ * used, this will be different from the id of the layer containing the\n+ * features rendered by this renderer.\n+ * \n+ * Returns:\n+ * {String} the id of the output layer.\n+ */\n+ getRenderLayerId: function() {\n+ return this.container.id;\n+ },\n+\n+ /**\n+ * Method: applyDefaultSymbolizer\n+ * \n+ * Parameters:\n+ * symbolizer - {Object}\n+ * \n+ * Returns:\n+ * {Object}\n+ */\n+ applyDefaultSymbolizer: function(symbolizer) {\n+ var result = OpenLayers.Util.extend({},\n+ OpenLayers.Renderer.defaultSymbolizer);\n+ if (symbolizer.stroke === false) {\n+ delete result.strokeWidth;\n+ delete result.strokeColor;\n+ }\n+ if (symbolizer.fill === false) {\n+ delete result.fillColor;\n+ }\n+ OpenLayers.Util.extend(result, symbolizer);\n+ return result;\n+ },\n \n+ CLASS_NAME: \"OpenLayers.Renderer\"\n });\n+\n+/**\n+ * Constant: OpenLayers.Renderer.defaultSymbolizer\n+ * {Object} Properties from this symbolizer will be applied to symbolizers\n+ * with missing properties. This can also be used to set a global\n+ * symbolizer default in OpenLayers. To be SLD 1.x compliant, add the\n+ * following code before rendering any vector features:\n+ * (code)\n+ * OpenLayers.Renderer.defaultSymbolizer = {\n+ * fillColor: \"#808080\",\n+ * fillOpacity: 1,\n+ * strokeColor: \"#000000\",\n+ * strokeOpacity: 1,\n+ * strokeWidth: 1,\n+ * pointRadius: 3,\n+ * graphicName: \"square\"\n+ * };\n+ * (end)\n+ */\n+OpenLayers.Renderer.defaultSymbolizer = {\n+ fillColor: \"#000000\",\n+ strokeColor: \"#000000\",\n+ strokeWidth: 2,\n+ fillOpacity: 1,\n+ strokeOpacity: 1,\n+ pointRadius: 0,\n+ labelAlign: 'cm'\n+};\n+\n+\n+\n+/**\n+ * Constant: OpenLayers.Renderer.symbol\n+ * Coordinate arrays for well known (named) symbols.\n+ */\n+OpenLayers.Renderer.symbol = {\n+ \"star\": [350, 75, 379, 161, 469, 161, 397, 215, 423, 301, 350, 250, 277, 301,\n+ 303, 215, 231, 161, 321, 161, 350, 75\n+ ],\n+ \"cross\": [4, 0, 6, 0, 6, 4, 10, 4, 10, 6, 6, 6, 6, 10, 4, 10, 4, 6, 0, 6, 0, 4, 4, 4,\n+ 4, 0\n+ ],\n+ \"x\": [0, 0, 25, 0, 50, 35, 75, 0, 100, 0, 65, 50, 100, 100, 75, 100, 50, 65, 25, 100, 0, 100, 35, 50, 0, 0],\n+ \"square\": [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],\n+ \"triangle\": [0, 10, 10, 10, 5, 0, 0, 10]\n+};\n /* ======================================================================\n OpenLayers/Icon.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -25085,47 +26724,1500 @@\n \n return isDrawn;\n },\n \n CLASS_NAME: \"OpenLayers.Icon\"\n });\n /* ======================================================================\n- OpenLayers/Protocol.js\n+ OpenLayers/Marker.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Icon.js\n */\n \n /**\n- * Class: OpenLayers.Protocol\n- * Abstract vector layer protocol class. Not to be instantiated directly. Use\n- * one of the protocol subclasses instead.\n- */\n-OpenLayers.Protocol = OpenLayers.Class({\n-\n- /**\n- * Property: format\n- * {} The format used by this protocol.\n- */\n- format: null,\n-\n- /**\n- * Property: options\n- * {Object} Any options sent to the constructor.\n- */\n- options: null,\n-\n- /**\n- * Property: autoDestroy\n+ * Class: OpenLayers.Marker\n+ * Instances of OpenLayers.Marker are a combination of a \n+ * and an . \n+ *\n+ * Markers are generally added to a special layer called\n+ * .\n+ *\n+ * Example:\n+ * (code)\n+ * var markers = new OpenLayers.Layer.Markers( \"Markers\" );\n+ * map.addLayer(markers);\n+ *\n+ * var size = new OpenLayers.Size(21,25);\n+ * var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);\n+ * var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);\n+ * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));\n+ * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon.clone()));\n+ *\n+ * (end)\n+ *\n+ * Note that if you pass an icon into the Marker constructor, it will take\n+ * that icon and use it. This means that you should not share icons between\n+ * markers -- you use them once, but you should clone() for any additional\n+ * markers using that same icon.\n+ */\n+OpenLayers.Marker = OpenLayers.Class({\n+\n+ /** \n+ * Property: icon \n+ * {} The icon used by this marker.\n+ */\n+ icon: null,\n+\n+ /** \n+ * Property: lonlat \n+ * {} location of object\n+ */\n+ lonlat: null,\n+\n+ /** \n+ * Property: events \n+ * {} the event handler.\n+ */\n+ events: null,\n+\n+ /** \n+ * Property: map \n+ * {} the map this marker is attached to\n+ */\n+ map: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Marker\n+ *\n+ * Parameters:\n+ * lonlat - {} the position of this marker\n+ * icon - {} the icon for this marker\n+ */\n+ initialize: function(lonlat, icon) {\n+ this.lonlat = lonlat;\n+\n+ var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();\n+ if (this.icon == null) {\n+ this.icon = newIcon;\n+ } else {\n+ this.icon.url = newIcon.url;\n+ this.icon.size = newIcon.size;\n+ this.icon.offset = newIcon.offset;\n+ this.icon.calculateOffset = newIcon.calculateOffset;\n+ }\n+ this.events = new OpenLayers.Events(this, this.icon.imageDiv);\n+ },\n+\n+ /**\n+ * APIMethod: destroy\n+ * Destroy the marker. You must first remove the marker from any \n+ * layer which it has been added to, or you will get buggy behavior.\n+ * (This can not be done within the marker since the marker does not\n+ * know which layer it is attached to.)\n+ */\n+ destroy: function() {\n+ // erase any drawn features\n+ this.erase();\n+\n+ this.map = null;\n+\n+ this.events.destroy();\n+ this.events = null;\n+\n+ if (this.icon != null) {\n+ this.icon.destroy();\n+ this.icon = null;\n+ }\n+ },\n+\n+ /** \n+ * Method: draw\n+ * Calls draw on the icon, and returns that output.\n+ * \n+ * Parameters:\n+ * px - {}\n+ * \n+ * Returns:\n+ * {DOMElement} A new DOM Image with this marker's icon set at the \n+ * location passed-in\n+ */\n+ draw: function(px) {\n+ return this.icon.draw(px);\n+ },\n+\n+ /** \n+ * Method: erase\n+ * Erases any drawn elements for this marker.\n+ */\n+ erase: function() {\n+ if (this.icon != null) {\n+ this.icon.erase();\n+ }\n+ },\n+\n+ /**\n+ * Method: moveTo\n+ * Move the marker to the new location.\n+ *\n+ * Parameters:\n+ * px - {|Object} the pixel position to move to.\n+ * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n+ */\n+ moveTo: function(px) {\n+ if ((px != null) && (this.icon != null)) {\n+ this.icon.moveTo(px);\n+ }\n+ this.lonlat = this.map.getLonLatFromLayerPx(px);\n+ },\n+\n+ /**\n+ * APIMethod: isDrawn\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the marker is drawn.\n+ */\n+ isDrawn: function() {\n+ var isDrawn = (this.icon && this.icon.isDrawn());\n+ return isDrawn;\n+ },\n+\n+ /**\n+ * Method: onScreen\n+ *\n+ * Returns:\n+ * {Boolean} Whether or not the marker is currently visible on screen.\n+ */\n+ onScreen: function() {\n+\n+ var onScreen = false;\n+ if (this.map) {\n+ var screenBounds = this.map.getExtent();\n+ onScreen = screenBounds.containsLonLat(this.lonlat);\n+ }\n+ return onScreen;\n+ },\n+\n+ /**\n+ * Method: inflate\n+ * Englarges the markers icon by the specified ratio.\n+ *\n+ * Parameters:\n+ * inflate - {float} the ratio to enlarge the marker by (passing 2\n+ * will double the size).\n+ */\n+ inflate: function(inflate) {\n+ if (this.icon) {\n+ this.icon.setSize({\n+ w: this.icon.size.w * inflate,\n+ h: this.icon.size.h * inflate\n+ });\n+ }\n+ },\n+\n+ /** \n+ * Method: setOpacity\n+ * Change the opacity of the marker by changin the opacity of \n+ * its icon\n+ * \n+ * Parameters:\n+ * opacity - {float} Specified as fraction (0.4, etc)\n+ */\n+ setOpacity: function(opacity) {\n+ this.icon.setOpacity(opacity);\n+ },\n+\n+ /**\n+ * Method: setUrl\n+ * Change URL of the Icon Image.\n+ * \n+ * url - {String} \n+ */\n+ setUrl: function(url) {\n+ this.icon.setUrl(url);\n+ },\n+\n+ /** \n+ * Method: display\n+ * Hide or show the icon\n+ * \n+ * display - {Boolean} \n+ */\n+ display: function(display) {\n+ this.icon.display(display);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Marker\"\n+});\n+\n+\n+/**\n+ * Function: defaultIcon\n+ * Creates a default .\n+ * \n+ * Returns:\n+ * {} A default OpenLayers.Icon to use for a marker\n+ */\n+OpenLayers.Marker.defaultIcon = function() {\n+ return new OpenLayers.Icon(OpenLayers.Util.getImageLocation(\"marker.png\"), {\n+ w: 21,\n+ h: 25\n+ }, {\n+ x: -10.5,\n+ y: -25\n+ });\n+};\n+\n+\n+/* ======================================================================\n+ OpenLayers/Symbolizer.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Symbolizer\n+ * Base class representing a symbolizer used for feature rendering.\n+ */\n+OpenLayers.Symbolizer = OpenLayers.Class({\n+\n+\n+ /**\n+ * APIProperty: zIndex\n+ * {Number} The zIndex determines the rendering order for a symbolizer.\n+ * Symbolizers with larger zIndex values are rendered over symbolizers\n+ * with smaller zIndex values. Default is 0.\n+ */\n+ zIndex: 0,\n+\n+ /**\n+ * Constructor: OpenLayers.Symbolizer\n+ * Instances of this class are not useful. See one of the subclasses.\n+ *\n+ * Parameters:\n+ * config - {Object} An object containing properties to be set on the \n+ * symbolizer. Any documented symbolizer property can be set at \n+ * construction.\n+ *\n+ * Returns:\n+ * A new symbolizer.\n+ */\n+ initialize: function(config) {\n+ OpenLayers.Util.extend(this, config);\n+ },\n+\n+ /** \n+ * APIMethod: clone\n+ * Create a copy of this symbolizer.\n+ *\n+ * Returns a symbolizer of the same type with the same properties.\n+ */\n+ clone: function() {\n+ var Type = eval(this.CLASS_NAME);\n+ return new Type(OpenLayers.Util.extend({}, this));\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Symbolizer\"\n+\n+});\n+\n+/* ======================================================================\n+ OpenLayers/Popup.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ */\n+\n+\n+/**\n+ * Class: OpenLayers.Popup\n+ * A popup is a small div that can opened and closed on the map.\n+ * Typically opened in response to clicking on a marker. \n+ * See . Popup's don't require their own\n+ * layer and are added the the map using the \n+ * method.\n+ *\n+ * Example:\n+ * (code)\n+ * popup = new OpenLayers.Popup(\"chicken\", \n+ * new OpenLayers.LonLat(5,40),\n+ * new OpenLayers.Size(200,200),\n+ * \"example popup\",\n+ * true);\n+ * \n+ * map.addPopup(popup);\n+ * (end)\n+ */\n+OpenLayers.Popup = OpenLayers.Class({\n+\n+ /** \n+ * Property: events \n+ * {} custom event manager \n+ */\n+ events: null,\n+\n+ /** Property: id\n+ * {String} the unique identifier assigned to this popup.\n+ */\n+ id: \"\",\n+\n+ /** \n+ * Property: lonlat \n+ * {} the position of this popup on the map\n+ */\n+ lonlat: null,\n+\n+ /** \n+ * Property: div \n+ * {DOMElement} the div that contains this popup.\n+ */\n+ div: null,\n+\n+ /** \n+ * Property: contentSize \n+ * {} the width and height of the content.\n+ */\n+ contentSize: null,\n+\n+ /** \n+ * Property: size \n+ * {} the width and height of the popup.\n+ */\n+ size: null,\n+\n+ /** \n+ * Property: contentHTML \n+ * {String} An HTML string for this popup to display.\n+ */\n+ contentHTML: null,\n+\n+ /** \n+ * Property: backgroundColor \n+ * {String} the background color used by the popup.\n+ */\n+ backgroundColor: \"\",\n+\n+ /** \n+ * Property: opacity \n+ * {float} the opacity of this popup (between 0.0 and 1.0)\n+ */\n+ opacity: \"\",\n+\n+ /** \n+ * Property: border \n+ * {String} the border size of the popup. (eg 2px)\n+ */\n+ border: \"\",\n+\n+ /** \n+ * Property: contentDiv \n+ * {DOMElement} a reference to the element that holds the content of\n+ * the div.\n+ */\n+ contentDiv: null,\n+\n+ /** \n+ * Property: groupDiv \n+ * {DOMElement} First and only child of 'div'. The group Div contains the\n+ * 'contentDiv' and the 'closeDiv'.\n+ */\n+ groupDiv: null,\n+\n+ /** \n+ * Property: closeDiv\n+ * {DOMElement} the optional closer image\n+ */\n+ closeDiv: null,\n+\n+ /** \n+ * APIProperty: autoSize\n+ * {Boolean} Resize the popup to auto-fit the contents.\n+ * Default is false.\n+ */\n+ autoSize: false,\n+\n+ /**\n+ * APIProperty: minSize\n+ * {} Minimum size allowed for the popup's contents.\n+ */\n+ minSize: null,\n+\n+ /**\n+ * APIProperty: maxSize\n+ * {} Maximum size allowed for the popup's contents.\n+ */\n+ maxSize: null,\n+\n+ /** \n+ * Property: displayClass\n+ * {String} The CSS class of the popup.\n+ */\n+ displayClass: \"olPopup\",\n+\n+ /** \n+ * Property: contentDisplayClass\n+ * {String} The CSS class of the popup content div.\n+ */\n+ contentDisplayClass: \"olPopupContent\",\n+\n+ /** \n+ * Property: padding \n+ * {int or } An extra opportunity to specify internal \n+ * padding of the content div inside the popup. This was originally\n+ * confused with the css padding as specified in style.css's \n+ * 'olPopupContent' class. We would like to get rid of this altogether,\n+ * except that it does come in handy for the framed and anchoredbubble\n+ * popups, who need to maintain yet another barrier between their \n+ * content and the outer border of the popup itself. \n+ * \n+ * Note that in order to not break API, we must continue to support \n+ * this property being set as an integer. Really, though, we'd like to \n+ * have this specified as a Bounds object so that user can specify\n+ * distinct left, top, right, bottom paddings. With the 3.0 release\n+ * we can make this only a bounds.\n+ */\n+ padding: 0,\n+\n+ /** \n+ * Property: disableFirefoxOverflowHack\n+ * {Boolean} The hack for overflow in Firefox causes all elements \n+ * to be re-drawn, which causes Flash elements to be \n+ * re-initialized, which is troublesome.\n+ * With this property the hack can be disabled.\n+ */\n+ disableFirefoxOverflowHack: false,\n+\n+ /**\n+ * Method: fixPadding\n+ * To be removed in 3.0, this function merely helps us to deal with the \n+ * case where the user may have set an integer value for padding, \n+ * instead of an object.\n+ */\n+ fixPadding: function() {\n+ if (typeof this.padding == \"number\") {\n+ this.padding = new OpenLayers.Bounds(\n+ this.padding, this.padding, this.padding, this.padding\n+ );\n+ }\n+ },\n+\n+ /**\n+ * APIProperty: panMapIfOutOfView\n+ * {Boolean} When drawn, pan map such that the entire popup is visible in\n+ * the current viewport (if necessary).\n+ * Default is false.\n+ */\n+ panMapIfOutOfView: false,\n+\n+ /**\n+ * APIProperty: keepInMap \n+ * {Boolean} If panMapIfOutOfView is false, and this property is true, \n+ * contrain the popup such that it always fits in the available map\n+ * space. By default, this is not set on the base class. If you are\n+ * creating popups that are near map edges and not allowing pannning,\n+ * and especially if you have a popup which has a\n+ * fixedRelativePosition, setting this to false may be a smart thing to\n+ * do. Subclasses may want to override this setting.\n+ * \n+ * Default is false.\n+ */\n+ keepInMap: false,\n+\n+ /**\n+ * APIProperty: closeOnMove\n+ * {Boolean} When map pans, close the popup.\n+ * Default is false.\n+ */\n+ closeOnMove: false,\n+\n+ /** \n+ * Property: map \n+ * {} this gets set in Map.js when the popup is added to the map\n+ */\n+ map: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Popup\n+ * Create a popup.\n+ * \n+ * Parameters: \n+ * id - {String} a unqiue identifier for this popup. If null is passed\n+ * an identifier will be automatically generated. \n+ * lonlat - {} The position on the map the popup will\n+ * be shown.\n+ * contentSize - {} The size of the content.\n+ * contentHTML - {String} An HTML string to display inside the \n+ * popup.\n+ * closeBox - {Boolean} Whether to display a close box inside\n+ * the popup.\n+ * closeBoxCallback - {Function} Function to be called on closeBox click.\n+ */\n+ initialize: function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) {\n+ if (id == null) {\n+ id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ }\n+\n+ this.id = id;\n+ this.lonlat = lonlat;\n+\n+ this.contentSize = (contentSize != null) ? contentSize :\n+ new OpenLayers.Size(\n+ OpenLayers.Popup.WIDTH,\n+ OpenLayers.Popup.HEIGHT);\n+ if (contentHTML != null) {\n+ this.contentHTML = contentHTML;\n+ }\n+ this.backgroundColor = OpenLayers.Popup.COLOR;\n+ this.opacity = OpenLayers.Popup.OPACITY;\n+ this.border = OpenLayers.Popup.BORDER;\n+\n+ this.div = OpenLayers.Util.createDiv(this.id, null, null,\n+ null, null, null, \"hidden\");\n+ this.div.className = this.displayClass;\n+\n+ var groupDivId = this.id + \"_GroupDiv\";\n+ this.groupDiv = OpenLayers.Util.createDiv(groupDivId, null, null,\n+ null, \"relative\", null,\n+ \"hidden\");\n+\n+ var id = this.div.id + \"_contentDiv\";\n+ this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(),\n+ null, \"relative\");\n+ this.contentDiv.className = this.contentDisplayClass;\n+ this.groupDiv.appendChild(this.contentDiv);\n+ this.div.appendChild(this.groupDiv);\n+\n+ if (closeBox) {\n+ this.addCloseBox(closeBoxCallback);\n+ }\n+\n+ this.registerEvents();\n+ },\n+\n+ /** \n+ * Method: destroy\n+ * nullify references to prevent circular references and memory leaks\n+ */\n+ destroy: function() {\n+\n+ this.id = null;\n+ this.lonlat = null;\n+ this.size = null;\n+ this.contentHTML = null;\n+\n+ this.backgroundColor = null;\n+ this.opacity = null;\n+ this.border = null;\n+\n+ if (this.closeOnMove && this.map) {\n+ this.map.events.unregister(\"movestart\", this, this.hide);\n+ }\n+\n+ this.events.destroy();\n+ this.events = null;\n+\n+ if (this.closeDiv) {\n+ OpenLayers.Event.stopObservingElement(this.closeDiv);\n+ this.groupDiv.removeChild(this.closeDiv);\n+ }\n+ this.closeDiv = null;\n+\n+ this.div.removeChild(this.groupDiv);\n+ this.groupDiv = null;\n+\n+ if (this.map != null) {\n+ this.map.removePopup(this);\n+ }\n+ this.map = null;\n+ this.div = null;\n+\n+ this.autoSize = null;\n+ this.minSize = null;\n+ this.maxSize = null;\n+ this.padding = null;\n+ this.panMapIfOutOfView = null;\n+ },\n+\n+ /** \n+ * Method: draw\n+ * Constructs the elements that make up the popup.\n+ *\n+ * Parameters:\n+ * px - {} the position the popup in pixels.\n+ * \n+ * Returns:\n+ * {DOMElement} Reference to a div that contains the drawn popup\n+ */\n+ draw: function(px) {\n+ if (px == null) {\n+ if ((this.lonlat != null) && (this.map != null)) {\n+ px = this.map.getLayerPxFromLonLat(this.lonlat);\n+ }\n+ }\n+\n+ // this assumes that this.map already exists, which is okay because \n+ // this.draw is only called once the popup has been added to the map.\n+ if (this.closeOnMove) {\n+ this.map.events.register(\"movestart\", this, this.hide);\n+ }\n+\n+ //listen to movestart, moveend to disable overflow (FF bug)\n+ if (!this.disableFirefoxOverflowHack && OpenLayers.BROWSER_NAME == 'firefox') {\n+ this.map.events.register(\"movestart\", this, function() {\n+ var style = document.defaultView.getComputedStyle(\n+ this.contentDiv, null\n+ );\n+ var currentOverflow = style.getPropertyValue(\"overflow\");\n+ if (currentOverflow != \"hidden\") {\n+ this.contentDiv._oldOverflow = currentOverflow;\n+ this.contentDiv.style.overflow = \"hidden\";\n+ }\n+ });\n+ this.map.events.register(\"moveend\", this, function() {\n+ var oldOverflow = this.contentDiv._oldOverflow;\n+ if (oldOverflow) {\n+ this.contentDiv.style.overflow = oldOverflow;\n+ this.contentDiv._oldOverflow = null;\n+ }\n+ });\n+ }\n+\n+ this.moveTo(px);\n+ if (!this.autoSize && !this.size) {\n+ this.setSize(this.contentSize);\n+ }\n+ this.setBackgroundColor();\n+ this.setOpacity();\n+ this.setBorder();\n+ this.setContentHTML();\n+\n+ if (this.panMapIfOutOfView) {\n+ this.panIntoView();\n+ }\n+\n+ return this.div;\n+ },\n+\n+ /** \n+ * Method: updatePosition\n+ * if the popup has a lonlat and its map members set, \n+ * then have it move itself to its proper position\n+ */\n+ updatePosition: function() {\n+ if ((this.lonlat) && (this.map)) {\n+ var px = this.map.getLayerPxFromLonLat(this.lonlat);\n+ if (px) {\n+ this.moveTo(px);\n+ }\n+ }\n+ },\n+\n+ /**\n+ * Method: moveTo\n+ * \n+ * Parameters:\n+ * px - {} the top and left position of the popup div. \n+ */\n+ moveTo: function(px) {\n+ if ((px != null) && (this.div != null)) {\n+ this.div.style.left = px.x + \"px\";\n+ this.div.style.top = px.y + \"px\";\n+ }\n+ },\n+\n+ /**\n+ * Method: visible\n+ *\n+ * Returns: \n+ * {Boolean} Boolean indicating whether or not the popup is visible\n+ */\n+ visible: function() {\n+ return OpenLayers.Element.visible(this.div);\n+ },\n+\n+ /**\n+ * Method: toggle\n+ * Toggles visibility of the popup.\n+ */\n+ toggle: function() {\n+ if (this.visible()) {\n+ this.hide();\n+ } else {\n+ this.show();\n+ }\n+ },\n+\n+ /**\n+ * Method: show\n+ * Makes the popup visible.\n+ */\n+ show: function() {\n+ this.div.style.display = '';\n+\n+ if (this.panMapIfOutOfView) {\n+ this.panIntoView();\n+ }\n+ },\n+\n+ /**\n+ * Method: hide\n+ * Makes the popup invisible.\n+ */\n+ hide: function() {\n+ this.div.style.display = 'none';\n+ },\n+\n+ /**\n+ * Method: setSize\n+ * Used to adjust the size of the popup. \n+ *\n+ * Parameters:\n+ * contentSize - {} the new size for the popup's \n+ * contents div (in pixels).\n+ */\n+ setSize: function(contentSize) {\n+ this.size = contentSize.clone();\n+\n+ // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n+ // must add that to the desired \"size\". \n+ var contentDivPadding = this.getContentDivPadding();\n+ var wPadding = contentDivPadding.left + contentDivPadding.right;\n+ var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n+\n+ // take into account the popup's 'padding' property\n+ this.fixPadding();\n+ wPadding += this.padding.left + this.padding.right;\n+ hPadding += this.padding.top + this.padding.bottom;\n+\n+ // make extra space for the close div\n+ if (this.closeDiv) {\n+ var closeDivWidth = parseInt(this.closeDiv.style.width);\n+ wPadding += closeDivWidth + contentDivPadding.right;\n+ }\n+\n+ //increase size of the main popup div to take into account the \n+ // users's desired padding and close div. \n+ this.size.w += wPadding;\n+ this.size.h += hPadding;\n+\n+ //now if our browser is IE, we need to actually make the contents \n+ // div itself bigger to take its own padding into effect. this makes \n+ // me want to shoot someone, but so it goes.\n+ if (OpenLayers.BROWSER_NAME == \"msie\") {\n+ this.contentSize.w +=\n+ contentDivPadding.left + contentDivPadding.right;\n+ this.contentSize.h +=\n+ contentDivPadding.bottom + contentDivPadding.top;\n+ }\n+\n+ if (this.div != null) {\n+ this.div.style.width = this.size.w + \"px\";\n+ this.div.style.height = this.size.h + \"px\";\n+ }\n+ if (this.contentDiv != null) {\n+ this.contentDiv.style.width = contentSize.w + \"px\";\n+ this.contentDiv.style.height = contentSize.h + \"px\";\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: updateSize\n+ * Auto size the popup so that it precisely fits its contents (as \n+ * determined by this.contentDiv.innerHTML). Popup size will, of\n+ * course, be limited by the available space on the current map\n+ */\n+ updateSize: function() {\n+\n+ // determine actual render dimensions of the contents by putting its\n+ // contents into a fake contentDiv (for the CSS) and then measuring it\n+ var preparedHTML = \"
\" +\n+ this.contentDiv.innerHTML +\n+ \"
\";\n+\n+ var containerElement = (this.map) ? this.map.div : document.body;\n+ var realSize = OpenLayers.Util.getRenderedDimensions(\n+ preparedHTML, null, {\n+ displayClass: this.displayClass,\n+ containerElement: containerElement\n+ }\n+ );\n+\n+ // is the \"real\" size of the div is safe to display in our map?\n+ var safeSize = this.getSafeContentSize(realSize);\n+\n+ var newSize = null;\n+ if (safeSize.equals(realSize)) {\n+ //real size of content is small enough to fit on the map, \n+ // so we use real size.\n+ newSize = realSize;\n+\n+ } else {\n+\n+ // make a new 'size' object with the clipped dimensions \n+ // set or null if not clipped.\n+ var fixedSize = {\n+ w: (safeSize.w < realSize.w) ? safeSize.w : null,\n+ h: (safeSize.h < realSize.h) ? safeSize.h : null\n+ };\n+\n+ if (fixedSize.w && fixedSize.h) {\n+ //content is too big in both directions, so we will use \n+ // max popup size (safeSize), knowing well that it will \n+ // overflow both ways. \n+ newSize = safeSize;\n+ } else {\n+ //content is clipped in only one direction, so we need to \n+ // run getRenderedDimensions() again with a fixed dimension\n+ var clippedSize = OpenLayers.Util.getRenderedDimensions(\n+ preparedHTML, fixedSize, {\n+ displayClass: this.contentDisplayClass,\n+ containerElement: containerElement\n+ }\n+ );\n+\n+ //if the clipped size is still the same as the safeSize, \n+ // that means that our content must be fixed in the \n+ // offending direction. If overflow is 'auto', this means \n+ // we are going to have a scrollbar for sure, so we must \n+ // adjust for that.\n+ //\n+ var currentOverflow = OpenLayers.Element.getStyle(\n+ this.contentDiv, \"overflow\"\n+ );\n+ if ((currentOverflow != \"hidden\") &&\n+ (clippedSize.equals(safeSize))) {\n+ var scrollBar = OpenLayers.Util.getScrollbarWidth();\n+ if (fixedSize.w) {\n+ clippedSize.h += scrollBar;\n+ } else {\n+ clippedSize.w += scrollBar;\n+ }\n+ }\n+\n+ newSize = this.getSafeContentSize(clippedSize);\n+ }\n+ }\n+ this.setSize(newSize);\n+ },\n+\n+ /**\n+ * Method: setBackgroundColor\n+ * Sets the background color of the popup.\n+ *\n+ * Parameters:\n+ * color - {String} the background color. eg \"#FFBBBB\"\n+ */\n+ setBackgroundColor: function(color) {\n+ if (color != undefined) {\n+ this.backgroundColor = color;\n+ }\n+\n+ if (this.div != null) {\n+ this.div.style.backgroundColor = this.backgroundColor;\n+ }\n+ },\n+\n+ /**\n+ * Method: setOpacity\n+ * Sets the opacity of the popup.\n+ * \n+ * Parameters:\n+ * opacity - {float} A value between 0.0 (transparent) and 1.0 (solid). \n+ */\n+ setOpacity: function(opacity) {\n+ if (opacity != undefined) {\n+ this.opacity = opacity;\n+ }\n+\n+ if (this.div != null) {\n+ // for Mozilla and Safari\n+ this.div.style.opacity = this.opacity;\n+\n+ // for IE\n+ this.div.style.filter = 'alpha(opacity=' + this.opacity * 100 + ')';\n+ }\n+ },\n+\n+ /**\n+ * Method: setBorder\n+ * Sets the border style of the popup.\n+ *\n+ * Parameters:\n+ * border - {String} The border style value. eg 2px \n+ */\n+ setBorder: function(border) {\n+ if (border != undefined) {\n+ this.border = border;\n+ }\n+\n+ if (this.div != null) {\n+ this.div.style.border = this.border;\n+ }\n+ },\n+\n+ /**\n+ * Method: setContentHTML\n+ * Allows the user to set the HTML content of the popup.\n+ *\n+ * Parameters:\n+ * contentHTML - {String} HTML for the div.\n+ */\n+ setContentHTML: function(contentHTML) {\n+\n+ if (contentHTML != null) {\n+ this.contentHTML = contentHTML;\n+ }\n+\n+ if ((this.contentDiv != null) &&\n+ (this.contentHTML != null) &&\n+ (this.contentHTML != this.contentDiv.innerHTML)) {\n+\n+ this.contentDiv.innerHTML = this.contentHTML;\n+\n+ if (this.autoSize) {\n+\n+ //if popup has images, listen for when they finish\n+ // loading and resize accordingly\n+ this.registerImageListeners();\n+\n+ //auto size the popup to its current contents\n+ this.updateSize();\n+ }\n+ }\n+\n+ },\n+\n+ /**\n+ * Method: registerImageListeners\n+ * Called when an image contained by the popup loaded. this function\n+ * updates the popup size, then unregisters the image load listener.\n+ */\n+ registerImageListeners: function() {\n+\n+ // As the images load, this function will call updateSize() to \n+ // resize the popup to fit the content div (which presumably is now\n+ // bigger than when the image was not loaded).\n+ // \n+ // If the 'panMapIfOutOfView' property is set, we will pan the newly\n+ // resized popup back into view.\n+ // \n+ // Note that this function, when called, will have 'popup' and \n+ // 'img' properties in the context.\n+ //\n+ var onImgLoad = function() {\n+ if (this.popup.id === null) { // this.popup has been destroyed!\n+ return;\n+ }\n+ this.popup.updateSize();\n+\n+ if (this.popup.visible() && this.popup.panMapIfOutOfView) {\n+ this.popup.panIntoView();\n+ }\n+\n+ OpenLayers.Event.stopObserving(\n+ this.img, \"load\", this.img._onImgLoad\n+ );\n+\n+ };\n+\n+ //cycle through the images and if their size is 0x0, that means that \n+ // they haven't been loaded yet, so we attach the listener, which \n+ // will fire when the images finish loading and will resize the \n+ // popup accordingly to its new size.\n+ var images = this.contentDiv.getElementsByTagName(\"img\");\n+ for (var i = 0, len = images.length; i < len; i++) {\n+ var img = images[i];\n+ if (img.width == 0 || img.height == 0) {\n+\n+ var context = {\n+ 'popup': this,\n+ 'img': img\n+ };\n+\n+ //expando this function to the image itself before registering\n+ // it. This way we can easily and properly unregister it.\n+ img._onImgLoad = OpenLayers.Function.bind(onImgLoad, context);\n+\n+ OpenLayers.Event.observe(img, 'load', img._onImgLoad);\n+ }\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: getSafeContentSize\n+ * \n+ * Parameters:\n+ * size - {} Desired size to make the popup.\n+ * \n+ * Returns:\n+ * {} A size to make the popup which is neither smaller\n+ * than the specified minimum size, nor bigger than the maximum \n+ * size (which is calculated relative to the size of the viewport).\n+ */\n+ getSafeContentSize: function(size) {\n+\n+ var safeContentSize = size.clone();\n+\n+ // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n+ // must add that to the desired \"size\". \n+ var contentDivPadding = this.getContentDivPadding();\n+ var wPadding = contentDivPadding.left + contentDivPadding.right;\n+ var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n+\n+ // take into account the popup's 'padding' property\n+ this.fixPadding();\n+ wPadding += this.padding.left + this.padding.right;\n+ hPadding += this.padding.top + this.padding.bottom;\n+\n+ if (this.closeDiv) {\n+ var closeDivWidth = parseInt(this.closeDiv.style.width);\n+ wPadding += closeDivWidth + contentDivPadding.right;\n+ }\n+\n+ // prevent the popup from being smaller than a specified minimal size\n+ if (this.minSize) {\n+ safeContentSize.w = Math.max(safeContentSize.w,\n+ (this.minSize.w - wPadding));\n+ safeContentSize.h = Math.max(safeContentSize.h,\n+ (this.minSize.h - hPadding));\n+ }\n+\n+ // prevent the popup from being bigger than a specified maximum size\n+ if (this.maxSize) {\n+ safeContentSize.w = Math.min(safeContentSize.w,\n+ (this.maxSize.w - wPadding));\n+ safeContentSize.h = Math.min(safeContentSize.h,\n+ (this.maxSize.h - hPadding));\n+ }\n+\n+ //make sure the desired size to set doesn't result in a popup that \n+ // is bigger than the map's viewport.\n+ //\n+ if (this.map && this.map.size) {\n+\n+ var extraX = 0,\n+ extraY = 0;\n+ if (this.keepInMap && !this.panMapIfOutOfView) {\n+ var px = this.map.getPixelFromLonLat(this.lonlat);\n+ switch (this.relativePosition) {\n+ case \"tr\":\n+ extraX = px.x;\n+ extraY = this.map.size.h - px.y;\n+ break;\n+ case \"tl\":\n+ extraX = this.map.size.w - px.x;\n+ extraY = this.map.size.h - px.y;\n+ break;\n+ case \"bl\":\n+ extraX = this.map.size.w - px.x;\n+ extraY = px.y;\n+ break;\n+ case \"br\":\n+ extraX = px.x;\n+ extraY = px.y;\n+ break;\n+ default:\n+ extraX = px.x;\n+ extraY = this.map.size.h - px.y;\n+ break;\n+ }\n+ }\n+\n+ var maxY = this.map.size.h -\n+ this.map.paddingForPopups.top -\n+ this.map.paddingForPopups.bottom -\n+ hPadding - extraY;\n+\n+ var maxX = this.map.size.w -\n+ this.map.paddingForPopups.left -\n+ this.map.paddingForPopups.right -\n+ wPadding - extraX;\n+\n+ safeContentSize.w = Math.min(safeContentSize.w, maxX);\n+ safeContentSize.h = Math.min(safeContentSize.h, maxY);\n+ }\n+\n+ return safeContentSize;\n+ },\n+\n+ /**\n+ * Method: getContentDivPadding\n+ * Glorious, oh glorious hack in order to determine the css 'padding' of \n+ * the contentDiv. IE/Opera return null here unless we actually add the \n+ * popup's main 'div' element (which contains contentDiv) to the DOM. \n+ * So we make it invisible and then add it to the document temporarily. \n+ *\n+ * Once we've taken the padding readings we need, we then remove it \n+ * from the DOM (it will actually get added to the DOM in \n+ * Map.js's addPopup)\n+ *\n+ * Returns:\n+ * {}\n+ */\n+ getContentDivPadding: function() {\n+\n+ //use cached value if we have it\n+ var contentDivPadding = this._contentDivPadding;\n+ if (!contentDivPadding) {\n+\n+ if (this.div.parentNode == null) {\n+ //make the div invisible and add it to the page \n+ this.div.style.display = \"none\";\n+ document.body.appendChild(this.div);\n+ }\n+\n+ //read the padding settings from css, put them in an OL.Bounds \n+ contentDivPadding = new OpenLayers.Bounds(\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-left\"),\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-bottom\"),\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-right\"),\n+ OpenLayers.Element.getStyle(this.contentDiv, \"padding-top\")\n+ );\n+\n+ //cache the value\n+ this._contentDivPadding = contentDivPadding;\n+\n+ if (this.div.parentNode == document.body) {\n+ //remove the div from the page and make it visible again\n+ document.body.removeChild(this.div);\n+ this.div.style.display = \"\";\n+ }\n+ }\n+ return contentDivPadding;\n+ },\n+\n+ /**\n+ * Method: addCloseBox\n+ * \n+ * Parameters:\n+ * callback - {Function} The callback to be called when the close button\n+ * is clicked.\n+ */\n+ addCloseBox: function(callback) {\n+\n+ this.closeDiv = OpenLayers.Util.createDiv(\n+ this.id + \"_close\", null, {\n+ w: 17,\n+ h: 17\n+ }\n+ );\n+ this.closeDiv.className = \"olPopupCloseBox\";\n+\n+ // use the content div's css padding to determine if we should\n+ // padd the close div\n+ var contentDivPadding = this.getContentDivPadding();\n+\n+ this.closeDiv.style.right = contentDivPadding.right + \"px\";\n+ this.closeDiv.style.top = contentDivPadding.top + \"px\";\n+ this.groupDiv.appendChild(this.closeDiv);\n+\n+ var closePopup = callback || function(e) {\n+ this.hide();\n+ OpenLayers.Event.stop(e);\n+ };\n+ OpenLayers.Event.observe(this.closeDiv, \"touchend\",\n+ OpenLayers.Function.bindAsEventListener(closePopup, this));\n+ OpenLayers.Event.observe(this.closeDiv, \"click\",\n+ OpenLayers.Function.bindAsEventListener(closePopup, this));\n+ },\n+\n+ /**\n+ * Method: panIntoView\n+ * Pans the map such that the popup is totaly viewable (if necessary)\n+ */\n+ panIntoView: function() {\n+\n+ var mapSize = this.map.getSize();\n+\n+ //start with the top left corner of the popup, in px, \n+ // relative to the viewport\n+ var origTL = this.map.getViewPortPxFromLayerPx(new OpenLayers.Pixel(\n+ parseInt(this.div.style.left),\n+ parseInt(this.div.style.top)\n+ ));\n+ var newTL = origTL.clone();\n+\n+ //new left (compare to margins, using this.size to calculate right)\n+ if (origTL.x < this.map.paddingForPopups.left) {\n+ newTL.x = this.map.paddingForPopups.left;\n+ } else\n+ if ((origTL.x + this.size.w) > (mapSize.w - this.map.paddingForPopups.right)) {\n+ newTL.x = mapSize.w - this.map.paddingForPopups.right - this.size.w;\n+ }\n+\n+ //new top (compare to margins, using this.size to calculate bottom)\n+ if (origTL.y < this.map.paddingForPopups.top) {\n+ newTL.y = this.map.paddingForPopups.top;\n+ } else\n+ if ((origTL.y + this.size.h) > (mapSize.h - this.map.paddingForPopups.bottom)) {\n+ newTL.y = mapSize.h - this.map.paddingForPopups.bottom - this.size.h;\n+ }\n+\n+ var dx = origTL.x - newTL.x;\n+ var dy = origTL.y - newTL.y;\n+\n+ this.map.pan(dx, dy);\n+ },\n+\n+ /** \n+ * Method: registerEvents\n+ * Registers events on the popup.\n+ *\n+ * Do this in a separate function so that subclasses can \n+ * choose to override it if they wish to deal differently\n+ * with mouse events\n+ * \n+ * Note in the following handler functions that some special\n+ * care is needed to deal correctly with mousing and popups. \n+ * \n+ * Because the user might select the zoom-rectangle option and\n+ * then drag it over a popup, we need a safe way to allow the\n+ * mousemove and mouseup events to pass through the popup when\n+ * they are initiated from outside. The same procedure is needed for\n+ * touchmove and touchend events.\n+ * \n+ * Otherwise, we want to essentially kill the event propagation\n+ * for all other events, though we have to do so carefully, \n+ * without disabling basic html functionality, like clicking on \n+ * hyperlinks or drag-selecting text.\n+ */\n+ registerEvents: function() {\n+ this.events = new OpenLayers.Events(this, this.div, null, true);\n+\n+ function onTouchstart(evt) {\n+ OpenLayers.Event.stop(evt, true);\n+ }\n+ this.events.on({\n+ \"mousedown\": this.onmousedown,\n+ \"mousemove\": this.onmousemove,\n+ \"mouseup\": this.onmouseup,\n+ \"click\": this.onclick,\n+ \"mouseout\": this.onmouseout,\n+ \"dblclick\": this.ondblclick,\n+ \"touchstart\": onTouchstart,\n+ scope: this\n+ });\n+\n+ },\n+\n+ /** \n+ * Method: onmousedown \n+ * When mouse goes down within the popup, make a note of\n+ * it locally, and then do not propagate the mousedown \n+ * (but do so safely so that user can select text inside)\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ onmousedown: function(evt) {\n+ this.mousedown = true;\n+ OpenLayers.Event.stop(evt, true);\n+ },\n+\n+ /** \n+ * Method: onmousemove\n+ * If the drag was started within the popup, then \n+ * do not propagate the mousemove (but do so safely\n+ * so that user can select text inside)\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ onmousemove: function(evt) {\n+ if (this.mousedown) {\n+ OpenLayers.Event.stop(evt, true);\n+ }\n+ },\n+\n+ /** \n+ * Method: onmouseup\n+ * When mouse comes up within the popup, after going down \n+ * in it, reset the flag, and then (once again) do not \n+ * propagate the event, but do so safely so that user can \n+ * select text inside\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ onmouseup: function(evt) {\n+ if (this.mousedown) {\n+ this.mousedown = false;\n+ OpenLayers.Event.stop(evt, true);\n+ }\n+ },\n+\n+ /**\n+ * Method: onclick\n+ * Ignore clicks, but allowing default browser handling\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ onclick: function(evt) {\n+ OpenLayers.Event.stop(evt, true);\n+ },\n+\n+ /** \n+ * Method: onmouseout\n+ * When mouse goes out of the popup set the flag to false so that\n+ * if they let go and then drag back in, we won't be confused.\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ onmouseout: function(evt) {\n+ this.mousedown = false;\n+ },\n+\n+ /** \n+ * Method: ondblclick\n+ * Ignore double-clicks, but allowing default browser handling\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ ondblclick: function(evt) {\n+ OpenLayers.Event.stop(evt, true);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Popup\"\n+});\n+\n+OpenLayers.Popup.WIDTH = 200;\n+OpenLayers.Popup.HEIGHT = 200;\n+OpenLayers.Popup.COLOR = \"white\";\n+OpenLayers.Popup.OPACITY = 1;\n+OpenLayers.Popup.BORDER = \"0px\";\n+/* ======================================================================\n+ OpenLayers/Spherical.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n+\n+/**\n+ * Namespace: Spherical\n+ * The OpenLayers.Spherical namespace includes utility functions for\n+ * calculations on the basis of a spherical earth (ignoring ellipsoidal\n+ * effects), which is accurate enough for most purposes.\n+ *\n+ * Relevant links:\n+ * * http://www.movable-type.co.uk/scripts/latlong.html\n+ * * http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical\n+ */\n+\n+OpenLayers.Spherical = OpenLayers.Spherical || {};\n+\n+OpenLayers.Spherical.DEFAULT_RADIUS = 6378137;\n+\n+/**\n+ * APIFunction: computeDistanceBetween\n+ * Computes the distance between two LonLats.\n+ *\n+ * Parameters:\n+ * from - {} or {Object} Starting point. A LonLat or\n+ * a JavaScript literal with lon lat properties.\n+ * to - {} or {Object} Ending point. A LonLat or a\n+ * JavaScript literal with lon lat properties.\n+ * radius - {Float} The radius. Optional. Defaults to 6378137 meters.\n+ *\n+ * Returns:\n+ * {Float} The distance in meters.\n+ */\n+OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) {\n+ var R = radius || OpenLayers.Spherical.DEFAULT_RADIUS;\n+ var sinHalfDeltaLon = Math.sin(Math.PI * (to.lon - from.lon) / 360);\n+ var sinHalfDeltaLat = Math.sin(Math.PI * (to.lat - from.lat) / 360);\n+ var a = sinHalfDeltaLat * sinHalfDeltaLat +\n+ sinHalfDeltaLon * sinHalfDeltaLon * Math.cos(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180);\n+ return 2 * R * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n+};\n+\n+\n+/**\n+ * APIFunction: computeHeading\n+ * Computes the heading from one LonLat to another LonLat.\n+ *\n+ * Parameters:\n+ * from - {} or {Object} Starting point. A LonLat or\n+ * a JavaScript literal with lon lat properties.\n+ * to - {} or {Object} Ending point. A LonLat or a\n+ * JavaScript literal with lon lat properties.\n+ *\n+ * Returns:\n+ * {Float} The heading in degrees.\n+ */\n+OpenLayers.Spherical.computeHeading = function(from, to) {\n+ var y = Math.sin(Math.PI * (from.lon - to.lon) / 180) * Math.cos(Math.PI * to.lat / 180);\n+ var x = Math.cos(Math.PI * from.lat / 180) * Math.sin(Math.PI * to.lat / 180) -\n+ Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (from.lon - to.lon) / 180);\n+ return 180 * Math.atan2(y, x) / Math.PI;\n+};\n+/* ======================================================================\n+ OpenLayers/Protocol.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Protocol\n+ * Abstract vector layer protocol class. Not to be instantiated directly. Use\n+ * one of the protocol subclasses instead.\n+ */\n+OpenLayers.Protocol = OpenLayers.Class({\n+\n+ /**\n+ * Property: format\n+ * {} The format used by this protocol.\n+ */\n+ format: null,\n+\n+ /**\n+ * Property: options\n+ * {Object} Any options sent to the constructor.\n+ */\n+ options: null,\n+\n+ /**\n+ * Property: autoDestroy\n * {Boolean} The creator of the protocol can set autoDestroy to false\n * to fully control when the protocol is destroyed. Defaults to\n * true.\n */\n autoDestroy: true,\n \n /**\n@@ -25375,1838 +28467,576 @@\n \n CLASS_NAME: \"OpenLayers.Protocol.Response\"\n });\n \n OpenLayers.Protocol.Response.SUCCESS = 1;\n OpenLayers.Protocol.Response.FAILURE = 0;\n /* ======================================================================\n- OpenLayers/Renderer.js\n+ OpenLayers/Kinetic.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Animation.js\n */\n \n-/**\n- * Class: OpenLayers.Renderer \n- * This is the base class for all renderers.\n- *\n- * This is based on a merger code written by Paul Spencer and Bertil Chapuis.\n- * It is largely composed of virtual functions that are to be implemented\n- * in technology-specific subclasses, but there is some generic code too.\n- * \n- * The functions that *are* implemented here merely deal with the maintenance\n- * of the size and extent variables, as well as the cached 'resolution' \n- * value. \n- * \n- * A note to the user that all subclasses should use getResolution() instead\n- * of directly accessing this.resolution in order to correctly use the \n- * cacheing system.\n- *\n- */\n-OpenLayers.Renderer = OpenLayers.Class({\n-\n- /** \n- * Property: container\n- * {DOMElement} \n- */\n- container: null,\n+OpenLayers.Kinetic = OpenLayers.Class({\n \n /**\n- * Property: root\n- * {DOMElement}\n- */\n- root: null,\n-\n- /** \n- * Property: extent\n- * {}\n+ * Property: threshold\n+ * In most cases changing the threshold isn't needed.\n+ * In px/ms, default to 0.\n */\n- extent: null,\n+ threshold: 0,\n \n /**\n- * Property: locked\n- * {Boolean} If the renderer is currently in a state where many things\n- * are changing, the 'locked' property is set to true. This means \n- * that renderers can expect at least one more drawFeature event to be\n- * called with the 'locked' property set to 'true': In some renderers,\n- * this might make sense to use as a 'only update local information'\n- * flag. \n+ * Property: deceleration\n+ * {Float} the deseleration in px/ms\u00b2, default to 0.0035.\n */\n- locked: false,\n+ deceleration: 0.0035,\n \n- /** \n- * Property: size\n- * {} \n+ /**\n+ * Property: nbPoints\n+ * {Integer} the number of points we use to calculate the kinetic\n+ * initial values.\n */\n- size: null,\n+ nbPoints: 100,\n \n /**\n- * Property: resolution\n- * {Float} cache of current map resolution\n+ * Property: delay\n+ * {Float} time to consider to calculate the kinetic initial values.\n+ * In ms, default to 200.\n */\n- resolution: null,\n+ delay: 200,\n \n /**\n- * Property: map \n- * {} Reference to the map -- this is set in Vector's setMap()\n+ * Property: points\n+ * List of points use to calculate the kinetic initial values.\n */\n- map: null,\n+ points: undefined,\n \n /**\n- * Property: featureDx\n- * {Number} Feature offset in x direction. Will be calculated for and\n- * applied to the current feature while rendering (see\n- * ).\n+ * Property: timerId\n+ * ID of the timer.\n */\n- featureDx: 0,\n+ timerId: undefined,\n \n /**\n- * Constructor: OpenLayers.Renderer \n+ * Constructor: OpenLayers.Kinetic\n *\n * Parameters:\n- * containerID - {} \n- * options - {Object} options for this renderer. See sublcasses for\n- * supported options.\n+ * options - {Object}\n */\n- initialize: function(containerID, options) {\n- this.container = OpenLayers.Util.getElement(containerID);\n+ initialize: function(options) {\n OpenLayers.Util.extend(this, options);\n },\n \n /**\n- * APIMethod: destroy\n- */\n- destroy: function() {\n- this.container = null;\n- this.extent = null;\n- this.size = null;\n- this.resolution = null;\n- this.map = null;\n- },\n-\n- /**\n- * APIMethod: supported\n- * This should be overridden by specific subclasses\n- * \n- * Returns:\n- * {Boolean} Whether or not the browser supports the renderer class\n+ * Method: begin\n+ * Begins the dragging.\n */\n- supported: function() {\n- return false;\n+ begin: function() {\n+ OpenLayers.Animation.stop(this.timerId);\n+ this.timerId = undefined;\n+ this.points = [];\n },\n \n /**\n- * Method: setExtent\n- * Set the visible part of the layer.\n- *\n- * Resolution has probably changed, so we nullify the resolution \n- * cache (this.resolution) -- this way it will be re-computed when \n- * next it is needed.\n- * We nullify the resolution cache (this.resolution) if resolutionChanged\n- * is set to true - this way it will be re-computed on the next\n- * getResolution() request.\n+ * Method: update\n+ * Updates during the dragging.\n *\n * Parameters:\n- * extent - {}\n- * resolutionChanged - {Boolean}\n- *\n- * Returns:\n- * {Boolean} true to notify the layer that the new extent does not exceed\n- * the coordinate range, and the features will not need to be redrawn.\n- * False otherwise.\n+ * xy - {} The new position.\n */\n- setExtent: function(extent, resolutionChanged) {\n- this.extent = extent.clone();\n- if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n- var ratio = extent.getWidth() / this.map.getExtent().getWidth(),\n- extent = extent.scale(1 / ratio);\n- this.extent = extent.wrapDateLine(this.map.getMaxExtent()).scale(ratio);\n- }\n- if (resolutionChanged) {\n- this.resolution = null;\n+ update: function(xy) {\n+ this.points.unshift({\n+ xy: xy,\n+ tick: new Date().getTime()\n+ });\n+ if (this.points.length > this.nbPoints) {\n+ this.points.pop();\n }\n- return true;\n },\n \n /**\n- * Method: setSize\n- * Sets the size of the drawing surface.\n- * \n- * Resolution has probably changed, so we nullify the resolution \n- * cache (this.resolution) -- this way it will be re-computed when \n- * next it is needed.\n+ * Method: end\n+ * Ends the dragging, start the kinetic.\n *\n * Parameters:\n- * size - {} \n- */\n- setSize: function(size) {\n- this.size = size.clone();\n- this.resolution = null;\n- },\n-\n- /** \n- * Method: getResolution\n- * Uses cached copy of resolution if available to minimize computing\n- * \n- * Returns:\n- * {Float} The current map's resolution\n- */\n- getResolution: function() {\n- this.resolution = this.resolution || this.map.getResolution();\n- return this.resolution;\n- },\n-\n- /**\n- * Method: drawFeature\n- * Draw the feature. The optional style argument can be used\n- * to override the feature's own style. This method should only\n- * be called from layer.drawFeature().\n+ * xy - {} The last position.\n *\n- * Parameters:\n- * feature - {} \n- * style - {}\n- * \n * Returns:\n- * {Boolean} true if the feature has been drawn completely, false if not,\n- * undefined if the feature had no geometry\n+ * {Object} An object with two properties: \"speed\", and \"theta\". The\n+ * \"speed\" and \"theta\" values are to be passed to the move \n+ * function when starting the animation.\n */\n- drawFeature: function(feature, style) {\n- if (style == null) {\n- style = feature.style;\n- }\n- if (feature.geometry) {\n- var bounds = feature.geometry.getBounds();\n- if (bounds) {\n- var worldBounds;\n- if (this.map.baseLayer && this.map.baseLayer.wrapDateLine) {\n- worldBounds = this.map.getMaxExtent();\n- }\n- if (!bounds.intersectsBounds(this.extent, {\n- worldBounds: worldBounds\n- })) {\n- style = {\n- display: \"none\"\n- };\n- } else {\n- this.calculateFeatureDx(bounds, worldBounds);\n- }\n- var rendered = this.drawGeometry(feature.geometry, style, feature.id);\n- if (style.display != \"none\" && style.label && rendered !== false) {\n-\n- var location = feature.geometry.getCentroid();\n- if (style.labelXOffset || style.labelYOffset) {\n- var xOffset = isNaN(style.labelXOffset) ? 0 : style.labelXOffset;\n- var yOffset = isNaN(style.labelYOffset) ? 0 : style.labelYOffset;\n- var res = this.getResolution();\n- location.move(xOffset * res, yOffset * res);\n- }\n- this.drawText(feature.id, style, location);\n- } else {\n- this.removeText(feature.id);\n- }\n- return rendered;\n+ end: function(xy) {\n+ var last, now = new Date().getTime();\n+ for (var i = 0, l = this.points.length, point; i < l; i++) {\n+ point = this.points[i];\n+ if (now - point.tick > this.delay) {\n+ break;\n }\n+ last = point;\n }\n- },\n-\n- /**\n- * Method: calculateFeatureDx\n- * {Number} Calculates the feature offset in x direction. Looking at the\n- * center of the feature bounds and the renderer extent, we calculate how\n- * many world widths the two are away from each other. This distance is\n- * used to shift the feature as close as possible to the center of the\n- * current enderer extent, which ensures that the feature is visible in the\n- * current viewport.\n- *\n- * Parameters:\n- * bounds - {} Bounds of the feature\n- * worldBounds - {} Bounds of the world\n- */\n- calculateFeatureDx: function(bounds, worldBounds) {\n- this.featureDx = 0;\n- if (worldBounds) {\n- var worldWidth = worldBounds.getWidth(),\n- rendererCenterX = (this.extent.left + this.extent.right) / 2,\n- featureCenterX = (bounds.left + bounds.right) / 2,\n- worldsAway = Math.round((featureCenterX - rendererCenterX) / worldWidth);\n- this.featureDx = worldsAway * worldWidth;\n+ if (!last) {\n+ return;\n+ }\n+ var time = new Date().getTime() - last.tick;\n+ var dist = Math.sqrt(Math.pow(xy.x - last.xy.x, 2) +\n+ Math.pow(xy.y - last.xy.y, 2));\n+ var speed = dist / time;\n+ if (speed == 0 || speed < this.threshold) {\n+ return;\n+ }\n+ var theta = Math.asin((xy.y - last.xy.y) / dist);\n+ if (last.xy.x <= xy.x) {\n+ theta = Math.PI - theta;\n }\n+ return {\n+ speed: speed,\n+ theta: theta\n+ };\n },\n \n- /** \n- * Method: drawGeometry\n- * \n- * Draw a geometry. This should only be called from the renderer itself.\n- * Use layer.drawFeature() from outside the renderer.\n- * virtual function\n+ /**\n+ * Method: move\n+ * Launch the kinetic move pan.\n *\n * Parameters:\n- * geometry - {} \n- * style - {Object} \n- * featureId - {} \n+ * info - {Object} An object with two properties, \"speed\", and \"theta\".\n+ * These values are those returned from the \"end\" call.\n+ * callback - {Function} Function called on every step of the animation,\n+ * receives x, y (values to pan), end (is the last point).\n */\n- drawGeometry: function(geometry, style, featureId) {},\n+ move: function(info, callback) {\n+ var v0 = info.speed;\n+ var fx = Math.cos(info.theta);\n+ var fy = -Math.sin(info.theta);\n \n- /**\n- * Method: drawText\n- * Function for drawing text labels.\n- * This method is only called by the renderer itself.\n- * \n- * Parameters: \n- * featureId - {String}\n- * style -\n- * location - {}\n- */\n- drawText: function(featureId, style, location) {},\n+ var initialTime = new Date().getTime();\n \n- /**\n- * Method: removeText\n- * Function for removing text labels.\n- * This method is only called by the renderer itself.\n- * \n- * Parameters: \n- * featureId - {String}\n- */\n- removeText: function(featureId) {},\n+ var lastX = 0;\n+ var lastY = 0;\n \n- /**\n- * Method: clear\n- * Clear all vectors from the renderer.\n- * virtual function.\n- */\n- clear: function() {},\n+ var timerCallback = function() {\n+ if (this.timerId == null) {\n+ return;\n+ }\n \n- /**\n- * Method: getFeatureIdFromEvent\n- * Returns a feature id from an event on the renderer. \n- * How this happens is specific to the renderer. This should be\n- * called from layer.getFeatureFromEvent().\n- * Virtual function.\n- * \n- * Parameters:\n- * evt - {} \n- *\n- * Returns:\n- * {String} A feature id or undefined.\n- */\n- getFeatureIdFromEvent: function(evt) {},\n+ var t = new Date().getTime() - initialTime;\n \n- /**\n- * Method: eraseFeatures \n- * This is called by the layer to erase features\n- * \n- * Parameters:\n- * features - {Array()} \n- */\n- eraseFeatures: function(features) {\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n- }\n- for (var i = 0, len = features.length; i < len; ++i) {\n- var feature = features[i];\n- this.eraseGeometry(feature.geometry, feature.id);\n- this.removeText(feature.id);\n- }\n- },\n+ var p = (-this.deceleration * Math.pow(t, 2)) / 2.0 + v0 * t;\n+ var x = p * fx;\n+ var y = p * fy;\n \n- /**\n- * Method: eraseGeometry\n- * Remove a geometry from the renderer (by id).\n- * virtual function.\n- * \n- * Parameters:\n- * geometry - {} \n- * featureId - {String}\n- */\n- eraseGeometry: function(geometry, featureId) {},\n+ var args = {};\n+ args.end = false;\n+ var v = -this.deceleration * t + v0;\n \n- /**\n- * Method: moveRoot\n- * moves this renderer's root to a (different) renderer.\n- * To be implemented by subclasses that require a common renderer root for\n- * feature selection.\n- * \n- * Parameters:\n- * renderer - {} target renderer for the moved root\n- */\n- moveRoot: function(renderer) {},\n+ if (v <= 0) {\n+ OpenLayers.Animation.stop(this.timerId);\n+ this.timerId = null;\n+ args.end = true;\n+ }\n \n- /**\n- * Method: getRenderLayerId\n- * Gets the layer that this renderer's output appears on. If moveRoot was\n- * used, this will be different from the id of the layer containing the\n- * features rendered by this renderer.\n- * \n- * Returns:\n- * {String} the id of the output layer.\n- */\n- getRenderLayerId: function() {\n- return this.container.id;\n- },\n+ args.x = x - lastX;\n+ args.y = y - lastY;\n+ lastX = x;\n+ lastY = y;\n+ callback(args.x, args.y, args.end);\n+ };\n \n- /**\n- * Method: applyDefaultSymbolizer\n- * \n- * Parameters:\n- * symbolizer - {Object}\n- * \n- * Returns:\n- * {Object}\n- */\n- applyDefaultSymbolizer: function(symbolizer) {\n- var result = OpenLayers.Util.extend({},\n- OpenLayers.Renderer.defaultSymbolizer);\n- if (symbolizer.stroke === false) {\n- delete result.strokeWidth;\n- delete result.strokeColor;\n- }\n- if (symbolizer.fill === false) {\n- delete result.fillColor;\n- }\n- OpenLayers.Util.extend(result, symbolizer);\n- return result;\n+ this.timerId = OpenLayers.Animation.start(\n+ OpenLayers.Function.bind(timerCallback, this)\n+ );\n },\n \n- CLASS_NAME: \"OpenLayers.Renderer\"\n+ CLASS_NAME: \"OpenLayers.Kinetic\"\n });\n-\n-/**\n- * Constant: OpenLayers.Renderer.defaultSymbolizer\n- * {Object} Properties from this symbolizer will be applied to symbolizers\n- * with missing properties. This can also be used to set a global\n- * symbolizer default in OpenLayers. To be SLD 1.x compliant, add the\n- * following code before rendering any vector features:\n- * (code)\n- * OpenLayers.Renderer.defaultSymbolizer = {\n- * fillColor: \"#808080\",\n- * fillOpacity: 1,\n- * strokeColor: \"#000000\",\n- * strokeOpacity: 1,\n- * strokeWidth: 1,\n- * pointRadius: 3,\n- * graphicName: \"square\"\n- * };\n- * (end)\n- */\n-OpenLayers.Renderer.defaultSymbolizer = {\n- fillColor: \"#000000\",\n- strokeColor: \"#000000\",\n- strokeWidth: 2,\n- fillOpacity: 1,\n- strokeOpacity: 1,\n- pointRadius: 0,\n- labelAlign: 'cm'\n-};\n-\n-\n-\n-/**\n- * Constant: OpenLayers.Renderer.symbol\n- * Coordinate arrays for well known (named) symbols.\n- */\n-OpenLayers.Renderer.symbol = {\n- \"star\": [350, 75, 379, 161, 469, 161, 397, 215, 423, 301, 350, 250, 277, 301,\n- 303, 215, 231, 161, 321, 161, 350, 75\n- ],\n- \"cross\": [4, 0, 6, 0, 6, 4, 10, 4, 10, 6, 6, 6, 6, 10, 4, 10, 4, 6, 0, 6, 0, 4, 4, 4,\n- 4, 0\n- ],\n- \"x\": [0, 0, 25, 0, 50, 35, 75, 0, 100, 0, 65, 50, 100, 100, 75, 100, 50, 65, 25, 100, 0, 100, 35, 50, 0, 0],\n- \"square\": [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],\n- \"triangle\": [0, 10, 10, 10, 5, 0, 0, 10]\n-};\n /* ======================================================================\n- OpenLayers/Layer.js\n+ OpenLayers/Control.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Map.js\n- * @requires OpenLayers/Projection.js\n */\n \n /**\n- * Class: OpenLayers.Layer\n+ * Class: OpenLayers.Control\n+ * Controls affect the display or behavior of the map. They allow everything\n+ * from panning and zooming to displaying a scale indicator. Controls by \n+ * default are added to the map they are contained within however it is\n+ * possible to add a control to an external div by passing the div in the\n+ * options parameter.\n+ * \n+ * Example:\n+ * The following example shows how to add many of the common controls\n+ * to a map.\n+ * \n+ * > var map = new OpenLayers.Map('map', { controls: [] });\n+ * >\n+ * > map.addControl(new OpenLayers.Control.PanZoomBar());\n+ * > map.addControl(new OpenLayers.Control.LayerSwitcher({'ascending':false}));\n+ * > map.addControl(new OpenLayers.Control.Permalink());\n+ * > map.addControl(new OpenLayers.Control.Permalink('permalink'));\n+ * > map.addControl(new OpenLayers.Control.MousePosition());\n+ * > map.addControl(new OpenLayers.Control.OverviewMap());\n+ * > map.addControl(new OpenLayers.Control.KeyboardDefaults());\n+ *\n+ * The next code fragment is a quick example of how to intercept \n+ * shift-mouse click to display the extent of the bounding box\n+ * dragged out by the user. Usually controls are not created\n+ * in exactly this manner. See the source for a more complete \n+ * example:\n+ *\n+ * > var control = new OpenLayers.Control();\n+ * > OpenLayers.Util.extend(control, {\n+ * > draw: function () {\n+ * > // this Handler.Box will intercept the shift-mousedown\n+ * > // before Control.MouseDefault gets to see it\n+ * > this.box = new OpenLayers.Handler.Box( control, \n+ * > {\"done\": this.notice},\n+ * > {keyMask: OpenLayers.Handler.MOD_SHIFT});\n+ * > this.box.activate();\n+ * > },\n+ * >\n+ * > notice: function (bounds) {\n+ * > OpenLayers.Console.userError(bounds);\n+ * > }\n+ * > }); \n+ * > map.addControl(control);\n+ * \n */\n-OpenLayers.Layer = OpenLayers.Class({\n+OpenLayers.Control = OpenLayers.Class({\n \n- /**\n- * APIProperty: id\n- * {String}\n+ /** \n+ * Property: id \n+ * {String} \n */\n id: null,\n \n /** \n- * APIProperty: name\n- * {String}\n+ * Property: map \n+ * {} this gets set in the addControl() function in\n+ * OpenLayers.Map \n */\n- name: null,\n+ map: null,\n \n /** \n- * APIProperty: div\n- * {DOMElement}\n+ * APIProperty: div \n+ * {DOMElement} The element that contains the control, if not present the \n+ * control is placed inside the map.\n */\n div: null,\n \n- /**\n- * APIProperty: opacity\n- * {Float} The layer's opacity. Float number between 0.0 and 1.0. Default\n- * is 1.\n- */\n- opacity: 1,\n-\n- /**\n- * APIProperty: alwaysInRange\n- * {Boolean} If a layer's display should not be scale-based, this should \n- * be set to true. This will cause the layer, as an overlay, to always \n- * be 'active', by always returning true from the calculateInRange() \n- * function. \n- * \n- * If not explicitly specified for a layer, its value will be \n- * determined on startup in initResolutions() based on whether or not \n- * any scale-specific properties have been set as options on the \n- * layer. If no scale-specific options have been set on the layer, we \n- * assume that it should always be in range.\n- * \n- * See #987 for more info.\n- */\n- alwaysInRange: null,\n-\n- /**\n- * Constant: RESOLUTION_PROPERTIES\n- * {Array} The properties that are used for calculating resolutions\n- * information.\n- */\n- RESOLUTION_PROPERTIES: [\n- 'scales', 'resolutions',\n- 'maxScale', 'minScale',\n- 'maxResolution', 'minResolution',\n- 'numZoomLevels', 'maxZoomLevel'\n- ],\n-\n- /**\n- * APIProperty: events\n- * {}\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * layer.events.register(type, obj, listener);\n- * (end)\n- *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n- *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to layer.events.object.\n- * element - {DOMElement} A reference to layer.events.element.\n- *\n- * Supported map event types:\n- * loadstart - Triggered when layer loading starts. When using a Vector \n- * layer with a Fixed or BBOX strategy, the event object includes \n- * a *filter* property holding the OpenLayers.Filter used when \n- * calling read on the protocol.\n- * loadend - Triggered when layer loading ends. When using a Vector layer\n- * with a Fixed or BBOX strategy, the event object includes a \n- * *response* property holding an OpenLayers.Protocol.Response object.\n- * visibilitychanged - Triggered when the layer's visibility property is\n- * changed, e.g. by turning the layer on or off in the layer switcher.\n- * Note that the actual visibility of the layer can also change if it\n- * gets out of range (see ). If you also want to catch\n- * these cases, register for the map's 'changelayer' event instead.\n- * move - Triggered when layer moves (triggered with every mousemove\n- * during a drag).\n- * moveend - Triggered when layer is done moving, object passed as\n- * argument has a zoomChanged boolean property which tells that the\n- * zoom has changed.\n- * added - Triggered after the layer is added to a map. Listeners will\n- * receive an object with a *map* property referencing the map and a\n- * *layer* property referencing the layer.\n- * removed - Triggered after the layer is removed from the map. Listeners\n- * will receive an object with a *map* property referencing the map and\n- * a *layer* property referencing the layer.\n- */\n- events: null,\n-\n- /**\n- * APIProperty: map\n- * {} This variable is set when the layer is added to \n- * the map, via the accessor function setMap().\n- */\n- map: null,\n-\n- /**\n- * APIProperty: isBaseLayer\n- * {Boolean} Whether or not the layer is a base layer. This should be set \n- * individually by all subclasses. Default is false\n+ /** \n+ * APIProperty: type \n+ * {Number} Controls can have a 'type'. The type determines the type of\n+ * interactions which are possible with them when they are placed in an\n+ * . \n */\n- isBaseLayer: false,\n+ type: null,\n \n- /**\n- * Property: alpha\n- * {Boolean} The layer's images have an alpha channel. Default is false.\n+ /** \n+ * Property: allowSelection\n+ * {Boolean} By default, controls do not allow selection, because\n+ * it may interfere with map dragging. If this is true, OpenLayers\n+ * will not prevent selection of the control.\n+ * Default is false.\n */\n- alpha: false,\n+ allowSelection: false,\n \n /** \n- * APIProperty: displayInLayerSwitcher\n- * {Boolean} Display the layer's name in the layer switcher. Default is\n- * true.\n+ * Property: displayClass \n+ * {string} This property is used for CSS related to the drawing of the\n+ * Control. \n */\n- displayInLayerSwitcher: true,\n+ displayClass: \"\",\n \n /**\n- * APIProperty: visibility\n- * {Boolean} The layer should be displayed in the map. Default is true.\n+ * APIProperty: title \n+ * {string} This property is used for showing a tooltip over the \n+ * Control. \n */\n- visibility: true,\n+ title: \"\",\n \n /**\n- * APIProperty: attribution\n- * {String} Attribution string, displayed when an \n- * has been added to the map.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * false.\n */\n- attribution: null,\n+ autoActivate: false,\n \n /** \n- * Property: inRange\n- * {Boolean} The current map resolution is within the layer's min/max \n- * range. This is set in whenever the zoom \n- * changes.\n+ * APIProperty: active \n+ * {Boolean} The control is active (read-only). Use and \n+ * to change control state.\n */\n- inRange: false,\n+ active: null,\n \n /**\n- * Propery: imageSize\n- * {} For layers with a gutter, the image is larger than \n- * the tile by twice the gutter in each dimension.\n+ * Property: handlerOptions\n+ * {Object} Used to set non-default properties on the control's handler\n */\n- imageSize: null,\n-\n- // OPTIONS\n+ handlerOptions: null,\n \n /** \n- * Property: options\n- * {Object} An optional object whose properties will be set on the layer.\n- * Any of the layer properties can be set as a property of the options\n- * object and sent to the constructor when the layer is created.\n+ * Property: handler \n+ * {} null\n */\n- options: null,\n+ handler: null,\n \n /**\n * APIProperty: eventListeners\n * {Object} If set as an option at construction, the eventListeners\n * object will be registered with . Object\n * structure must be a listeners object as shown in the example for\n * the events.on method.\n */\n eventListeners: null,\n \n- /**\n- * APIProperty: gutter\n- * {Integer} Determines the width (in pixels) of the gutter around image\n- * tiles to ignore. By setting this property to a non-zero value,\n- * images will be requested that are wider and taller than the tile\n- * size by a value of 2 x gutter. This allows artifacts of rendering\n- * at tile edges to be ignored. Set a gutter value that is equal to\n- * half the size of the widest symbol that needs to be displayed.\n- * Defaults to zero. Non-tiled layers always have zero gutter.\n- */\n- gutter: 0,\n-\n- /**\n- * APIProperty: projection\n- * {} or {} Specifies the projection of the layer.\n- * Can be set in the layer options. If not specified in the layer options,\n- * it is set to the default projection specified in the map,\n- * when the layer is added to the map.\n- * Projection along with default maxExtent and resolutions\n- * are set automatically with commercial baselayers in EPSG:3857,\n- * such as Google, Bing and OpenStreetMap, and do not need to be specified.\n- * Otherwise, if specifying projection, also set maxExtent,\n- * maxResolution or resolutions as appropriate.\n- * When using vector layers with strategies, layer projection should be set\n- * to the projection of the source data if that is different from the map default.\n- * \n- * Can be either a string or an object;\n- * if a string is passed, will be converted to an object when\n- * the layer is added to the map.\n- * \n- */\n- projection: null,\n-\n- /**\n- * APIProperty: units\n- * {String} The layer map units. Defaults to null. Possible values\n- * are 'degrees' (or 'dd'), 'm', 'ft', 'km', 'mi', 'inches'.\n- * Normally taken from the projection.\n- * Only required if both map and layers do not define a projection,\n- * or if they define a projection which does not define units.\n- */\n- units: null,\n-\n- /**\n- * APIProperty: scales\n- * {Array} An array of map scales in descending order. The values in the\n- * array correspond to the map scale denominator. Note that these\n- * values only make sense if the display (monitor) resolution of the\n- * client is correctly guessed by whomever is configuring the\n- * application. In addition, the units property must also be set.\n- * Use instead wherever possible.\n- */\n- scales: null,\n-\n- /**\n- * APIProperty: resolutions\n- * {Array} A list of map resolutions (map units per pixel) in descending\n- * order. If this is not set in the layer constructor, it will be set\n- * based on other resolution related properties (maxExtent,\n- * maxResolution, maxScale, etc.).\n+ /** \n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n+ *\n+ * Listeners will be called with a reference to an event object. The\n+ * properties of this event depends on exactly what happened.\n+ *\n+ * All event objects have at least the following properties:\n+ * object - {Object} A reference to control.events.object (a reference\n+ * to the control).\n+ * element - {DOMElement} A reference to control.events.element (which\n+ * will be null unless documented otherwise).\n+ *\n+ * Supported map event types:\n+ * activate - Triggered when activated.\n+ * deactivate - Triggered when deactivated.\n */\n- resolutions: null,\n+ events: null,\n \n /**\n- * APIProperty: maxExtent\n- * {|Array} If provided as an array, the array\n- * should consist of four values (left, bottom, right, top).\n- * The maximum extent for the layer. Defaults to null.\n+ * Constructor: OpenLayers.Control\n+ * Create an OpenLayers Control. The options passed as a parameter\n+ * directly extend the control. For example passing the following:\n * \n- * The center of these bounds will not stray outside\n- * of the viewport extent during panning. In addition, if\n- * is set to false, data will not be\n- * requested that falls completely outside of these bounds.\n- */\n- maxExtent: null,\n-\n- /**\n- * APIProperty: minExtent\n- * {|Array} If provided as an array, the array\n- * should consist of four values (left, bottom, right, top).\n- * The minimum extent for the layer. Defaults to null.\n- */\n- minExtent: null,\n-\n- /**\n- * APIProperty: maxResolution\n- * {Float} Default max is 360 deg / 256 px, which corresponds to\n- * zoom level 0 on gmaps. Specify a different value in the layer \n- * options if you are not using the default \n- * and displaying the whole world.\n- */\n- maxResolution: null,\n-\n- /**\n- * APIProperty: minResolution\n- * {Float}\n- */\n- minResolution: null,\n-\n- /**\n- * APIProperty: numZoomLevels\n- * {Integer}\n- */\n- numZoomLevels: null,\n-\n- /**\n- * APIProperty: minScale\n- * {Float}\n- */\n- minScale: null,\n-\n- /**\n- * APIProperty: maxScale\n- * {Float}\n- */\n- maxScale: null,\n-\n- /**\n- * APIProperty: displayOutsideMaxExtent\n- * {Boolean} Request map tiles that are completely outside of the max \n- * extent for this layer. Defaults to false.\n- */\n- displayOutsideMaxExtent: false,\n-\n- /**\n- * APIProperty: wrapDateLine\n- * {Boolean} Wraps the world at the international dateline, so the map can\n- * be panned infinitely in longitudinal direction. Only use this on the\n- * base layer, and only if the layer's maxExtent equals the world bounds.\n- * #487 for more info. \n- */\n- wrapDateLine: false,\n-\n- /**\n- * Property: metadata\n- * {Object} This object can be used to store additional information on a\n- * layer object.\n- */\n- metadata: null,\n-\n- /**\n- * Constructor: OpenLayers.Layer\n+ * > var control = new OpenLayers.Control({div: myDiv});\n *\n+ * Overrides the default div attribute value of null.\n+ * \n * Parameters:\n- * name - {String} The layer name\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * options - {Object} \n */\n- initialize: function(name, options) {\n+ initialize: function(options) {\n+ // We do this before the extend so that instances can override\n+ // className in options.\n+ this.displayClass =\n+ this.CLASS_NAME.replace(\"OpenLayers.\", \"ol\").replace(/\\./g, \"\");\n \n- this.metadata = {};\n+ OpenLayers.Util.extend(this, options);\n \n- options = OpenLayers.Util.extend({}, options);\n- // make sure we respect alwaysInRange if set on the prototype\n- if (this.alwaysInRange != null) {\n- options.alwaysInRange = this.alwaysInRange;\n+ this.events = new OpenLayers.Events(this);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n }\n- this.addOptions(options);\n-\n- this.name = name;\n-\n if (this.id == null) {\n-\n this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n-\n- this.div = OpenLayers.Util.createDiv(this.id);\n- this.div.style.width = \"100%\";\n- this.div.style.height = \"100%\";\n- this.div.dir = \"ltr\";\n-\n- this.events = new OpenLayers.Events(this, this.div);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n- }\n-\n }\n },\n \n /**\n * Method: destroy\n- * Destroy is a destructor: this is to alleviate cyclic references which\n- * the Javascript garbage cleaner can not take care of on its own.\n- *\n- * Parameters:\n- * setNewBaseLayer - {Boolean} Set a new base layer when this layer has\n- * been destroyed. Default is true.\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n */\n- destroy: function(setNewBaseLayer) {\n- if (setNewBaseLayer == null) {\n- setNewBaseLayer = true;\n- }\n- if (this.map != null) {\n- this.map.removeLayer(this, setNewBaseLayer);\n- }\n- this.projection = null;\n- this.map = null;\n- this.name = null;\n- this.div = null;\n- this.options = null;\n-\n+ destroy: function() {\n if (this.events) {\n if (this.eventListeners) {\n this.events.un(this.eventListeners);\n }\n this.events.destroy();\n+ this.events = null;\n }\n this.eventListeners = null;\n- this.events = null;\n- },\n-\n- /**\n- * Method: clone\n- *\n- * Parameters:\n- * obj - {} The layer to be cloned\n- *\n- * Returns:\n- * {} An exact clone of this \n- */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer(this.name, this.getOptions());\n- }\n-\n- // catch any randomly tagged-on properties\n- OpenLayers.Util.applyDefaults(obj, this);\n-\n- // a cloned layer should never have its map property set\n- // because it has not been added to a map yet. \n- obj.map = null;\n-\n- return obj;\n- },\n-\n- /**\n- * Method: getOptions\n- * Extracts an object from the layer with the properties that were set as\n- * options, but updates them with the values currently set on the\n- * instance.\n- * \n- * Returns:\n- * {Object} the of the layer, representing the current state.\n- */\n- getOptions: function() {\n- var options = {};\n- for (var o in this.options) {\n- options[o] = this[o];\n- }\n- return options;\n- },\n-\n- /** \n- * APIMethod: setName\n- * Sets the new layer name for this layer. Can trigger a changelayer event\n- * on the map.\n- *\n- * Parameters:\n- * newName - {String} The new name.\n- */\n- setName: function(newName) {\n- if (newName != this.name) {\n- this.name = newName;\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"name\"\n- });\n- }\n- }\n- },\n-\n- /**\n- * APIMethod: addOptions\n- * \n- * Parameters:\n- * newOptions - {Object}\n- * reinitialize - {Boolean} If set to true, and if resolution options of the\n- * current baseLayer were changed, the map will be recentered to make\n- * sure that it is displayed with a valid resolution, and a\n- * changebaselayer event will be triggered.\n- */\n- addOptions: function(newOptions, reinitialize) {\n-\n- if (this.options == null) {\n- this.options = {};\n- }\n-\n- if (newOptions) {\n- // make sure this.projection references a projection object\n- if (typeof newOptions.projection == \"string\") {\n- newOptions.projection = new OpenLayers.Projection(newOptions.projection);\n- }\n- if (newOptions.projection) {\n- // get maxResolution, units and maxExtent from projection defaults if\n- // they are not defined already\n- OpenLayers.Util.applyDefaults(newOptions,\n- OpenLayers.Projection.defaults[newOptions.projection.getCode()]);\n- }\n- // allow array for extents\n- if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {\n- newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);\n- }\n- if (newOptions.minExtent && !(newOptions.minExtent instanceof OpenLayers.Bounds)) {\n- newOptions.minExtent = new OpenLayers.Bounds(newOptions.minExtent);\n- }\n- }\n \n- // update our copy for clone\n- OpenLayers.Util.extend(this.options, newOptions);\n-\n- // add new options to this\n- OpenLayers.Util.extend(this, newOptions);\n-\n- // get the units from the projection, if we have a projection\n- // and it it has units\n- if (this.projection && this.projection.getUnits()) {\n- this.units = this.projection.getUnits();\n+ // eliminate circular references\n+ if (this.handler) {\n+ this.handler.destroy();\n+ this.handler = null;\n }\n-\n- // re-initialize resolutions if necessary, i.e. if any of the\n- // properties of the \"properties\" array defined below is set\n- // in the new options\n- if (this.map) {\n- // store current resolution so we can try to restore it later\n- var resolution = this.map.getResolution();\n- var properties = this.RESOLUTION_PROPERTIES.concat(\n- [\"projection\", \"units\", \"minExtent\", \"maxExtent\"]\n- );\n- for (var o in newOptions) {\n- if (newOptions.hasOwnProperty(o) &&\n- OpenLayers.Util.indexOf(properties, o) >= 0) {\n-\n- this.initResolutions();\n- if (reinitialize && this.map.baseLayer === this) {\n- // update map position, and restore previous resolution\n- this.map.setCenter(this.map.getCenter(),\n- this.map.getZoomForResolution(resolution),\n- false, true\n- );\n- // trigger a changebaselayer event to make sure that\n- // all controls (especially\n- // OpenLayers.Control.PanZoomBar) get notified of the\n- // new options\n- this.map.events.triggerEvent(\"changebaselayer\", {\n- layer: this\n- });\n- }\n- break;\n+ if (this.handlers) {\n+ for (var key in this.handlers) {\n+ if (this.handlers.hasOwnProperty(key) &&\n+ typeof this.handlers[key].destroy == \"function\") {\n+ this.handlers[key].destroy();\n }\n }\n+ this.handlers = null;\n }\n- },\n-\n- /**\n- * APIMethod: onMapResize\n- * This function can be implemented by subclasses\n- */\n- onMapResize: function() {\n- //this function can be implemented by subclasses \n- },\n-\n- /**\n- * APIMethod: redraw\n- * Redraws the layer. Returns true if the layer was redrawn, false if not.\n- *\n- * Returns:\n- * {Boolean} The layer was redrawn.\n- */\n- redraw: function() {\n- var redrawn = false;\n if (this.map) {\n-\n- // min/max Range may have changed\n- this.inRange = this.calculateInRange();\n-\n- // map's center might not yet be set\n- var extent = this.getExtent();\n-\n- if (extent && this.inRange && this.visibility) {\n- var zoomChanged = true;\n- this.moveTo(extent, zoomChanged, false);\n- this.events.triggerEvent(\"moveend\", {\n- \"zoomChanged\": zoomChanged\n- });\n- redrawn = true;\n- }\n- }\n- return redrawn;\n- },\n-\n- /**\n- * Method: moveTo\n- * \n- * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean} Tells when zoom has changed, as layers have to\n- * do some init work in that case.\n- * dragging - {Boolean}\n- */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- var display = this.visibility;\n- if (!this.isBaseLayer) {\n- display = display && this.inRange;\n- }\n- this.display(display);\n- },\n-\n- /**\n- * Method: moveByPx\n- * Move the layer based on pixel vector. To be implemented by subclasses.\n- *\n- * Parameters:\n- * dx - {Number} The x coord of the displacement vector.\n- * dy - {Number} The y coord of the displacement vector.\n- */\n- moveByPx: function(dx, dy) {},\n-\n- /**\n- * Method: setMap\n- * Set the map property for the layer. This is done through an accessor\n- * so that subclasses can override this and take special action once \n- * they have their map variable set. \n- * \n- * Here we take care to bring over any of the necessary default \n- * properties from the map. \n- * \n- * Parameters:\n- * map - {}\n- */\n- setMap: function(map) {\n- if (this.map == null) {\n-\n- this.map = map;\n-\n- // grab some essential layer data from the map if it hasn't already\n- // been set\n- this.maxExtent = this.maxExtent || this.map.maxExtent;\n- this.minExtent = this.minExtent || this.map.minExtent;\n-\n- this.projection = this.projection || this.map.projection;\n- if (typeof this.projection == \"string\") {\n- this.projection = new OpenLayers.Projection(this.projection);\n- }\n-\n- // Check the projection to see if we can get units -- if not, refer\n- // to properties.\n- this.units = this.projection.getUnits() ||\n- this.units || this.map.units;\n-\n- this.initResolutions();\n-\n- if (!this.isBaseLayer) {\n- this.inRange = this.calculateInRange();\n- var show = ((this.visibility) && (this.inRange));\n- this.div.style.display = show ? \"\" : \"none\";\n- }\n-\n- // deal with gutters\n- this.setTileSize();\n- }\n- },\n-\n- /**\n- * Method: afterAdd\n- * Called at the end of the map.addLayer sequence. At this point, the map\n- * will have a base layer. To be overridden by subclasses.\n- */\n- afterAdd: function() {},\n-\n- /**\n- * APIMethod: removeMap\n- * Just as setMap() allows each layer the possibility to take a \n- * personalized action on being added to the map, removeMap() allows\n- * each layer to take a personalized action on being removed from it. \n- * For now, this will be mostly unused, except for the EventPane layer,\n- * which needs this hook so that it can remove the special invisible\n- * pane. \n- * \n- * Parameters:\n- * map - {}\n- */\n- removeMap: function(map) {\n- //to be overridden by subclasses\n- },\n-\n- /**\n- * APIMethod: getImageSize\n- *\n- * Parameters:\n- * bounds - {} optional tile bounds, can be used\n- * by subclasses that have to deal with different tile sizes at the\n- * layer extent edges (e.g. Zoomify)\n- * \n- * Returns:\n- * {} The size that the image should be, taking into \n- * account gutters.\n- */\n- getImageSize: function(bounds) {\n- return (this.imageSize || this.tileSize);\n- },\n-\n- /**\n- * APIMethod: setTileSize\n- * Set the tile size based on the map size. This also sets layer.imageSize\n- * or use by Tile.Image.\n- * \n- * Parameters:\n- * size - {}\n- */\n- setTileSize: function(size) {\n- var tileSize = (size) ? size :\n- ((this.tileSize) ? this.tileSize :\n- this.map.getTileSize());\n- this.tileSize = tileSize;\n- if (this.gutter) {\n- // layers with gutters need non-null tile sizes\n- //if(tileSize == null) {\n- // OpenLayers.console.error(\"Error in layer.setMap() for \" +\n- // this.name + \": layers with \" +\n- // \"gutters need non-null tile sizes\");\n- //}\n- this.imageSize = new OpenLayers.Size(tileSize.w + (2 * this.gutter),\n- tileSize.h + (2 * this.gutter));\n- }\n- },\n-\n- /**\n- * APIMethod: getVisibility\n- * \n- * Returns:\n- * {Boolean} The layer should be displayed (if in range).\n- */\n- getVisibility: function() {\n- return this.visibility;\n- },\n-\n- /** \n- * APIMethod: setVisibility\n- * Set the visibility flag for the layer and hide/show & redraw \n- * accordingly. Fire event unless otherwise specified\n- * \n- * Note that visibility is no longer simply whether or not the layer's\n- * style.display is set to \"block\". Now we store a 'visibility' state \n- * property on the layer class, this allows us to remember whether or \n- * not we *desire* for a layer to be visible. In the case where the \n- * map's resolution is out of the layer's range, this desire may be \n- * subverted.\n- * \n- * Parameters:\n- * visibility - {Boolean} Whether or not to display the layer (if in range)\n- */\n- setVisibility: function(visibility) {\n- if (visibility != this.visibility) {\n- this.visibility = visibility;\n- this.display(visibility);\n- this.redraw();\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"visibility\"\n- });\n- }\n- this.events.triggerEvent(\"visibilitychanged\");\n- }\n- },\n-\n- /** \n- * APIMethod: display\n- * Hide or show the Layer. This is designed to be used internally, and \n- * is not generally the way to enable or disable the layer. For that,\n- * use the setVisibility function instead..\n- * \n- * Parameters:\n- * display - {Boolean}\n- */\n- display: function(display) {\n- if (display != (this.div.style.display != \"none\")) {\n- this.div.style.display = (display && this.calculateInRange()) ? \"block\" : \"none\";\n- }\n- },\n-\n- /**\n- * APIMethod: calculateInRange\n- * \n- * Returns:\n- * {Boolean} The layer is displayable at the current map's current\n- * resolution. Note that if 'alwaysInRange' is true for the layer, \n- * this function will always return true.\n- */\n- calculateInRange: function() {\n- var inRange = false;\n-\n- if (this.alwaysInRange) {\n- inRange = true;\n- } else {\n- if (this.map) {\n- var resolution = this.map.getResolution();\n- inRange = ((resolution >= this.minResolution) &&\n- (resolution <= this.maxResolution));\n- }\n- }\n- return inRange;\n- },\n-\n- /** \n- * APIMethod: setIsBaseLayer\n- * \n- * Parameters:\n- * isBaseLayer - {Boolean}\n- */\n- setIsBaseLayer: function(isBaseLayer) {\n- if (isBaseLayer != this.isBaseLayer) {\n- this.isBaseLayer = isBaseLayer;\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changebaselayer\", {\n- layer: this\n- });\n- }\n+ this.map.removeControl(this);\n+ this.map = null;\n }\n+ this.div = null;\n },\n \n- /********************************************************/\n- /* */\n- /* Baselayer Functions */\n- /* */\n- /********************************************************/\n-\n /** \n- * Method: initResolutions\n- * This method's responsibility is to set up the 'resolutions' array \n- * for the layer -- this array is what the layer will use to interface\n- * between the zoom levels of the map and the resolution display \n- * of the layer.\n- * \n- * The user has several options that determine how the array is set up.\n- * \n- * For a detailed explanation, see the following wiki from the \n- * openlayers.org homepage:\n- * http://trac.openlayers.org/wiki/SettingZoomLevels\n- */\n- initResolutions: function() {\n-\n- // ok we want resolutions, here's our strategy:\n- //\n- // 1. if resolutions are defined in the layer config, use them\n- // 2. else, if scales are defined in the layer config then derive\n- // resolutions from these scales\n- // 3. else, attempt to calculate resolutions from maxResolution,\n- // minResolution, numZoomLevels, maxZoomLevel set in the\n- // layer config\n- // 4. if we still don't have resolutions, and if resolutions\n- // are defined in the same, use them\n- // 5. else, if scales are defined in the map then derive\n- // resolutions from these scales\n- // 6. else, attempt to calculate resolutions from maxResolution,\n- // minResolution, numZoomLevels, maxZoomLevel set in the\n- // map\n- // 7. hope for the best!\n-\n- var i, len, p;\n- var props = {},\n- alwaysInRange = true;\n-\n- // get resolution data from layer config\n- // (we also set alwaysInRange in the layer as appropriate)\n- for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n- p = this.RESOLUTION_PROPERTIES[i];\n- props[p] = this.options[p];\n- if (alwaysInRange && this.options[p]) {\n- alwaysInRange = false;\n- }\n- }\n- if (this.options.alwaysInRange == null) {\n- this.alwaysInRange = alwaysInRange;\n- }\n-\n- // if we don't have resolutions then attempt to derive them from scales\n- if (props.resolutions == null) {\n- props.resolutions = this.resolutionsFromScales(props.scales);\n- }\n-\n- // if we still don't have resolutions then attempt to calculate them\n- if (props.resolutions == null) {\n- props.resolutions = this.calculateResolutions(props);\n- }\n-\n- // if we couldn't calculate resolutions then we look at we have\n- // in the map\n- if (props.resolutions == null) {\n- for (i = 0, len = this.RESOLUTION_PROPERTIES.length; i < len; i++) {\n- p = this.RESOLUTION_PROPERTIES[i];\n- props[p] = this.options[p] != null ?\n- this.options[p] : this.map[p];\n- }\n- if (props.resolutions == null) {\n- props.resolutions = this.resolutionsFromScales(props.scales);\n- }\n- if (props.resolutions == null) {\n- props.resolutions = this.calculateResolutions(props);\n- }\n- }\n-\n- // ok, we new need to set properties in the instance\n-\n- // get maxResolution from the config if it's defined there\n- var maxResolution;\n- if (this.options.maxResolution &&\n- this.options.maxResolution !== \"auto\") {\n- maxResolution = this.options.maxResolution;\n- }\n- if (this.options.minScale) {\n- maxResolution = OpenLayers.Util.getResolutionFromScale(\n- this.options.minScale, this.units);\n- }\n-\n- // get minResolution from the config if it's defined there\n- var minResolution;\n- if (this.options.minResolution &&\n- this.options.minResolution !== \"auto\") {\n- minResolution = this.options.minResolution;\n- }\n- if (this.options.maxScale) {\n- minResolution = OpenLayers.Util.getResolutionFromScale(\n- this.options.maxScale, this.units);\n- }\n-\n- if (props.resolutions) {\n-\n- //sort resolutions array descendingly\n- props.resolutions.sort(function(a, b) {\n- return (b - a);\n- });\n-\n- // if we still don't have a maxResolution get it from the\n- // resolutions array\n- if (!maxResolution) {\n- maxResolution = props.resolutions[0];\n- }\n-\n- // if we still don't have a minResolution get it from the\n- // resolutions array\n- if (!minResolution) {\n- var lastIdx = props.resolutions.length - 1;\n- minResolution = props.resolutions[lastIdx];\n- }\n- }\n-\n- this.resolutions = props.resolutions;\n- if (this.resolutions) {\n- len = this.resolutions.length;\n- this.scales = new Array(len);\n- for (i = 0; i < len; i++) {\n- this.scales[i] = OpenLayers.Util.getScaleFromResolution(\n- this.resolutions[i], this.units);\n- }\n- this.numZoomLevels = len;\n- }\n- this.minResolution = minResolution;\n- if (minResolution) {\n- this.maxScale = OpenLayers.Util.getScaleFromResolution(\n- minResolution, this.units);\n- }\n- this.maxResolution = maxResolution;\n- if (maxResolution) {\n- this.minScale = OpenLayers.Util.getScaleFromResolution(\n- maxResolution, this.units);\n- }\n- },\n-\n- /**\n- * Method: resolutionsFromScales\n- * Derive resolutions from scales.\n+ * Method: setMap\n+ * Set the map property for the control. This is done through an accessor\n+ * so that subclasses can override this and take special action once \n+ * they have their map variable set. \n *\n * Parameters:\n- * scales - {Array(Number)} Scales\n- *\n- * Returns\n- * {Array(Number)} Resolutions\n+ * map - {} \n */\n- resolutionsFromScales: function(scales) {\n- if (scales == null) {\n- return;\n- }\n- var resolutions, i, len;\n- len = scales.length;\n- resolutions = new Array(len);\n- for (i = 0; i < len; i++) {\n- resolutions[i] = OpenLayers.Util.getResolutionFromScale(\n- scales[i], this.units);\n+ setMap: function(map) {\n+ this.map = map;\n+ if (this.handler) {\n+ this.handler.setMap(map);\n }\n- return resolutions;\n },\n \n /**\n- * Method: calculateResolutions\n- * Calculate resolutions based on the provided properties.\n+ * Method: draw\n+ * The draw method is called when the control is ready to be displayed\n+ * on the page. If a div has not been created one is created. Controls\n+ * with a visual component will almost always want to override this method \n+ * to customize the look of control. \n *\n * Parameters:\n- * props - {Object} Properties\n+ * px - {} The top-left pixel position of the control\n+ * or null.\n *\n * Returns:\n- * {Array({Number})} Array of resolutions.\n+ * {DOMElement} A reference to the DIV DOMElement containing the control\n */\n- calculateResolutions: function(props) {\n-\n- var viewSize, wRes, hRes;\n-\n- // determine maxResolution\n- var maxResolution = props.maxResolution;\n- if (props.minScale != null) {\n- maxResolution =\n- OpenLayers.Util.getResolutionFromScale(props.minScale,\n- this.units);\n- } else if (maxResolution == \"auto\" && this.maxExtent != null) {\n- viewSize = this.map.getSize();\n- wRes = this.maxExtent.getWidth() / viewSize.w;\n- hRes = this.maxExtent.getHeight() / viewSize.h;\n- maxResolution = Math.max(wRes, hRes);\n- }\n-\n- // determine minResolution\n- var minResolution = props.minResolution;\n- if (props.maxScale != null) {\n- minResolution =\n- OpenLayers.Util.getResolutionFromScale(props.maxScale,\n- this.units);\n- } else if (props.minResolution == \"auto\" && this.minExtent != null) {\n- viewSize = this.map.getSize();\n- wRes = this.minExtent.getWidth() / viewSize.w;\n- hRes = this.minExtent.getHeight() / viewSize.h;\n- minResolution = Math.max(wRes, hRes);\n- }\n-\n- if (typeof maxResolution !== \"number\" &&\n- typeof minResolution !== \"number\" &&\n- this.maxExtent != null) {\n- // maxResolution for default grid sets assumes that at zoom\n- // level zero, the whole world fits on one tile.\n- var tileSize = this.map.getTileSize();\n- maxResolution = Math.max(\n- this.maxExtent.getWidth() / tileSize.w,\n- this.maxExtent.getHeight() / tileSize.h\n- );\n- }\n-\n- // determine numZoomLevels\n- var maxZoomLevel = props.maxZoomLevel;\n- var numZoomLevels = props.numZoomLevels;\n- if (typeof minResolution === \"number\" &&\n- typeof maxResolution === \"number\" && numZoomLevels === undefined) {\n- var ratio = maxResolution / minResolution;\n- numZoomLevels = Math.floor(Math.log(ratio) / Math.log(2)) + 1;\n- } else if (numZoomLevels === undefined && maxZoomLevel != null) {\n- numZoomLevels = maxZoomLevel + 1;\n- }\n-\n- // are we able to calculate resolutions?\n- if (typeof numZoomLevels !== \"number\" || numZoomLevels <= 0 ||\n- (typeof maxResolution !== \"number\" &&\n- typeof minResolution !== \"number\")) {\n- return;\n- }\n-\n- // now we have numZoomLevels and at least one of maxResolution\n- // or minResolution, we can populate the resolutions array\n-\n- var resolutions = new Array(numZoomLevels);\n- var base = 2;\n- if (typeof minResolution == \"number\" &&\n- typeof maxResolution == \"number\") {\n- // if maxResolution and minResolution are set, we calculate\n- // the base for exponential scaling that starts at\n- // maxResolution and ends at minResolution in numZoomLevels\n- // steps.\n- base = Math.pow(\n- (maxResolution / minResolution),\n- (1 / (numZoomLevels - 1))\n- );\n- }\n-\n- var i;\n- if (typeof maxResolution === \"number\") {\n- for (i = 0; i < numZoomLevels; i++) {\n- resolutions[i] = maxResolution / Math.pow(base, i);\n+ draw: function(px) {\n+ if (this.div == null) {\n+ this.div = OpenLayers.Util.createDiv(this.id);\n+ this.div.className = this.displayClass;\n+ if (!this.allowSelection) {\n+ this.div.className += \" olControlNoSelect\";\n+ this.div.setAttribute(\"unselectable\", \"on\", 0);\n+ this.div.onselectstart = OpenLayers.Function.False;\n }\n- } else {\n- for (i = 0; i < numZoomLevels; i++) {\n- resolutions[numZoomLevels - 1 - i] =\n- minResolution * Math.pow(base, i);\n+ if (this.title != \"\") {\n+ this.div.title = this.title;\n }\n }\n-\n- return resolutions;\n- },\n-\n- /**\n- * APIMethod: getResolution\n- * \n- * Returns:\n- * {Float} The currently selected resolution of the map, taken from the\n- * resolutions array, indexed by current zoom level.\n- */\n- getResolution: function() {\n- var zoom = this.map.getZoom();\n- return this.getResolutionForZoom(zoom);\n- },\n-\n- /** \n- * APIMethod: getExtent\n- * \n- * Returns:\n- * {} A Bounds object which represents the lon/lat \n- * bounds of the current viewPort.\n- */\n- getExtent: function() {\n- // just use stock map calculateBounds function -- passing no arguments\n- // means it will user map's current center & resolution\n- //\n- return this.map.calculateBounds();\n+ if (px != null) {\n+ this.position = px.clone();\n+ }\n+ this.moveTo(this.position);\n+ return this.div;\n },\n \n /**\n- * APIMethod: getZoomForExtent\n- * \n- * Parameters:\n- * extent - {}\n- * closest - {Boolean} Find the zoom level that most closely fits the \n- * specified bounds. Note that this may result in a zoom that does \n- * not exactly contain the entire extent.\n- * Default is false.\n+ * Method: moveTo\n+ * Sets the left and top style attributes to the passed in pixel \n+ * coordinates.\n *\n- * Returns:\n- * {Integer} The index of the zoomLevel (entry in the resolutions array) \n- * for the passed-in extent. We do this by calculating the ideal \n- * resolution for the given extent (based on the map size) and then \n- * calling getZoomForResolution(), passing along the 'closest'\n- * parameter.\n- */\n- getZoomForExtent: function(extent, closest) {\n- var viewSize = this.map.getSize();\n- var idealResolution = Math.max(extent.getWidth() / viewSize.w,\n- extent.getHeight() / viewSize.h);\n-\n- return this.getZoomForResolution(idealResolution, closest);\n- },\n-\n- /** \n- * Method: getDataExtent\n- * Calculates the max extent which includes all of the data for the layer.\n- * This function is to be implemented by subclasses.\n- * \n- * Returns:\n- * {}\n- */\n- getDataExtent: function() {\n- //to be implemented by subclasses\n- },\n-\n- /**\n- * APIMethod: getResolutionForZoom\n- * \n * Parameters:\n- * zoom - {Float}\n- * \n- * Returns:\n- * {Float} A suitable resolution for the specified zoom.\n+ * px - {}\n */\n- getResolutionForZoom: function(zoom) {\n- zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));\n- var resolution;\n- if (this.map.fractionalZoom) {\n- var low = Math.floor(zoom);\n- var high = Math.ceil(zoom);\n- resolution = this.resolutions[low] -\n- ((zoom - low) * (this.resolutions[low] - this.resolutions[high]));\n- } else {\n- resolution = this.resolutions[Math.round(zoom)];\n+ moveTo: function(px) {\n+ if ((px != null) && (this.div != null)) {\n+ this.div.style.left = px.x + \"px\";\n+ this.div.style.top = px.y + \"px\";\n }\n- return resolution;\n },\n \n /**\n- * APIMethod: getZoomForResolution\n- * \n- * Parameters:\n- * resolution - {Float}\n- * closest - {Boolean} Find the zoom level that corresponds to the absolute \n- * closest resolution, which may result in a zoom whose corresponding\n- * resolution is actually smaller than we would have desired (if this\n- * is being called from a getZoomForExtent() call, then this means that\n- * the returned zoom index might not actually contain the entire \n- * extent specified... but it'll be close).\n- * Default is false.\n+ * APIMethod: activate\n+ * Explicitly activates a control and it's associated\n+ * handler if one has been set. Controls can be\n+ * deactivated by calling the deactivate() method.\n * \n * Returns:\n- * {Integer} The index of the zoomLevel (entry in the resolutions array) \n- * that corresponds to the best fit resolution given the passed in \n- * value and the 'closest' specification.\n+ * {Boolean} True if the control was successfully activated or\n+ * false if the control was already active.\n */\n- getZoomForResolution: function(resolution, closest) {\n- var zoom, i, len;\n- if (this.map.fractionalZoom) {\n- var lowZoom = 0;\n- var highZoom = this.resolutions.length - 1;\n- var highRes = this.resolutions[lowZoom];\n- var lowRes = this.resolutions[highZoom];\n- var res;\n- for (i = 0, len = this.resolutions.length; i < len; ++i) {\n- res = this.resolutions[i];\n- if (res >= resolution) {\n- highRes = res;\n- lowZoom = i;\n- }\n- if (res <= resolution) {\n- lowRes = res;\n- highZoom = i;\n- break;\n- }\n- }\n- var dRes = highRes - lowRes;\n- if (dRes > 0) {\n- zoom = lowZoom + ((highRes - resolution) / dRes);\n- } else {\n- zoom = lowZoom;\n- }\n- } else {\n- var diff;\n- var minDiff = Number.POSITIVE_INFINITY;\n- for (i = 0, len = this.resolutions.length; i < len; i++) {\n- if (closest) {\n- diff = Math.abs(this.resolutions[i] - resolution);\n- if (diff > minDiff) {\n- break;\n- }\n- minDiff = diff;\n- } else {\n- if (this.resolutions[i] < resolution) {\n- break;\n- }\n- }\n- }\n- zoom = Math.max(0, i - 1);\n+ activate: function() {\n+ if (this.active) {\n+ return false;\n }\n- return zoom;\n- },\n-\n- /**\n- * APIMethod: getLonLatFromViewPortPx\n- * \n- * Parameters:\n- * viewPortPx - {|Object} An OpenLayers.Pixel or\n- * an object with a 'x'\n- * and 'y' properties.\n- *\n- * Returns:\n- * {} An OpenLayers.LonLat which is the passed-in \n- * view port , translated into lon/lat by the layer.\n- */\n- getLonLatFromViewPortPx: function(viewPortPx) {\n- var lonlat = null;\n- var map = this.map;\n- if (viewPortPx != null && map.minPx) {\n- var res = map.getResolution();\n- var maxExtent = map.getMaxExtent({\n- restricted: true\n- });\n- var lon = (viewPortPx.x - map.minPx.x) * res + maxExtent.left;\n- var lat = (map.minPx.y - viewPortPx.y) * res + maxExtent.top;\n- lonlat = new OpenLayers.LonLat(lon, lat);\n-\n- if (this.wrapDateLine) {\n- lonlat = lonlat.wrapDateLine(this.maxExtent);\n- }\n+ if (this.handler) {\n+ this.handler.activate();\n }\n- return lonlat;\n- },\n-\n- /**\n- * APIMethod: getViewPortPxFromLonLat\n- * Returns a pixel location given a map location. This method will return\n- * fractional pixel values.\n- * \n- * Parameters:\n- * lonlat - {|Object} An OpenLayers.LonLat or\n- * an object with a 'lon'\n- * and 'lat' properties.\n- *\n- * Returns: \n- * {} An which is the passed-in \n- * lonlat translated into view port pixels.\n- */\n- getViewPortPxFromLonLat: function(lonlat, resolution) {\n- var px = null;\n- if (lonlat != null) {\n- resolution = resolution || this.map.getResolution();\n- var extent = this.map.calculateBounds(null, resolution);\n- px = new OpenLayers.Pixel(\n- (1 / resolution * (lonlat.lon - extent.left)),\n- (1 / resolution * (extent.top - lonlat.lat))\n+ this.active = true;\n+ if (this.map) {\n+ OpenLayers.Element.addClass(\n+ this.map.viewPortDiv,\n+ this.displayClass.replace(/ /g, \"\") + \"Active\"\n );\n }\n- return px;\n+ this.events.triggerEvent(\"activate\");\n+ return true;\n },\n \n /**\n- * APIMethod: setOpacity\n- * Sets the opacity for the entire layer (all images)\n+ * APIMethod: deactivate\n+ * Deactivates a control and it's associated handler if any. The exact\n+ * effect of this depends on the control itself.\n * \n- * Parameters:\n- * opacity - {Float}\n+ * Returns:\n+ * {Boolean} True if the control was effectively deactivated or false\n+ * if the control was already inactive.\n */\n- setOpacity: function(opacity) {\n- if (opacity != this.opacity) {\n- this.opacity = opacity;\n- var childNodes = this.div.childNodes;\n- for (var i = 0, len = childNodes.length; i < len; ++i) {\n- var element = childNodes[i].firstChild || childNodes[i];\n- var lastChild = childNodes[i].lastChild;\n- //TODO de-uglify this\n- if (lastChild && lastChild.nodeName.toLowerCase() === \"iframe\") {\n- element = lastChild.parentNode;\n- }\n- OpenLayers.Util.modifyDOMElement(element, null, null, null,\n- null, null, null, opacity);\n+ deactivate: function() {\n+ if (this.active) {\n+ if (this.handler) {\n+ this.handler.deactivate();\n }\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"opacity\"\n- });\n+ this.active = false;\n+ if (this.map) {\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv,\n+ this.displayClass.replace(/ /g, \"\") + \"Active\"\n+ );\n }\n+ this.events.triggerEvent(\"deactivate\");\n+ return true;\n }\n+ return false;\n },\n \n- /**\n- * Method: getZIndex\n- * \n- * Returns: \n- * {Integer} the z-index of this layer\n- */\n- getZIndex: function() {\n- return this.div.style.zIndex;\n- },\n-\n- /**\n- * Method: setZIndex\n- * \n- * Parameters: \n- * zIndex - {Integer}\n- */\n- setZIndex: function(zIndex) {\n- this.div.style.zIndex = zIndex;\n- },\n-\n- /**\n- * Method: adjustBounds\n- * This function will take a bounds, and if wrapDateLine option is set\n- * on the layer, it will return a bounds which is wrapped around the \n- * world. We do not wrap for bounds which *cross* the \n- * maxExtent.left/right, only bounds which are entirely to the left \n- * or entirely to the right.\n- * \n- * Parameters:\n- * bounds - {}\n- */\n- adjustBounds: function(bounds) {\n-\n- if (this.gutter) {\n- // Adjust the extent of a bounds in map units by the \n- // layer's gutter in pixels.\n- var mapGutter = this.gutter * this.map.getResolution();\n- bounds = new OpenLayers.Bounds(bounds.left - mapGutter,\n- bounds.bottom - mapGutter,\n- bounds.right + mapGutter,\n- bounds.top + mapGutter);\n- }\n+ CLASS_NAME: \"OpenLayers.Control\"\n+});\n \n- if (this.wrapDateLine) {\n- // wrap around the date line, within the limits of rounding error\n- var wrappingOptions = {\n- 'rightTolerance': this.getResolution(),\n- 'leftTolerance': this.getResolution()\n- };\n- bounds = bounds.wrapDateLine(this.maxExtent, wrappingOptions);\n+/**\n+ * Constant: OpenLayers.Control.TYPE_BUTTON\n+ */\n+OpenLayers.Control.TYPE_BUTTON = 1;\n \n- }\n- return bounds;\n- },\n+/**\n+ * Constant: OpenLayers.Control.TYPE_TOGGLE\n+ */\n+OpenLayers.Control.TYPE_TOGGLE = 2;\n \n- CLASS_NAME: \"OpenLayers.Layer\"\n-});\n+/**\n+ * Constant: OpenLayers.Control.TYPE_TOOL\n+ */\n+OpenLayers.Control.TYPE_TOOL = 3;\n /* ======================================================================\n OpenLayers/Layer/HTTPRequest.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -27436,313 +29266,14 @@\n \n return OpenLayers.Util.urlAppend(url, paramsString);\n },\n \n CLASS_NAME: \"OpenLayers.Layer.HTTPRequest\"\n });\n /* ======================================================================\n- OpenLayers/Tile.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Class: OpenLayers.Tile \n- * This is a class designed to designate a single tile, however\n- * it is explicitly designed to do relatively little. Tiles store \n- * information about themselves -- such as the URL that they are related\n- * to, and their size - but do not add themselves to the layer div \n- * automatically, for example. Create a new tile with the \n- * constructor, or a subclass. \n- * \n- * TBD 3.0 - remove reference to url in above paragraph\n- * \n- */\n-OpenLayers.Tile = OpenLayers.Class({\n-\n- /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the tile.\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * tile.events.register(type, obj, listener);\n- * (end)\n- *\n- * Supported event types:\n- * beforedraw - Triggered before the tile is drawn. Used to defer\n- * drawing to an animation queue. To defer drawing, listeners need\n- * to return false, which will abort drawing. The queue handler needs\n- * to call (true) to actually draw the tile.\n- * loadstart - Triggered when tile loading starts.\n- * loadend - Triggered when tile loading ends.\n- * loaderror - Triggered before the loadend event (i.e. when the tile is\n- * still hidden) if the tile could not be loaded.\n- * reload - Triggered when an already loading tile is reloaded.\n- * unload - Triggered before a tile is unloaded.\n- */\n- events: null,\n-\n- /**\n- * APIProperty: eventListeners\n- * {Object} If set as an option at construction, the eventListeners\n- * object will be registered with . Object\n- * structure must be a listeners object as shown in the example for\n- * the events.on method.\n- *\n- * This options can be set in the ``tileOptions`` option from\n- * . For example, to be notified of the\n- * ``loadend`` event of each tiles:\n- * (code)\n- * new OpenLayers.Layer.OSM('osm', 'http://tile.openstreetmap.org/${z}/${x}/${y}.png', {\n- * tileOptions: {\n- * eventListeners: {\n- * 'loadend': function(evt) {\n- * // do something on loadend\n- * }\n- * }\n- * }\n- * });\n- * (end)\n- */\n- eventListeners: null,\n-\n- /**\n- * Property: id \n- * {String} null\n- */\n- id: null,\n-\n- /** \n- * Property: layer \n- * {} layer the tile is attached to \n- */\n- layer: null,\n-\n- /**\n- * Property: url\n- * {String} url of the request.\n- *\n- * TBD 3.0 \n- * Deprecated. The base tile class does not need an url. This should be \n- * handled in subclasses. Does not belong here.\n- */\n- url: null,\n-\n- /** \n- * APIProperty: bounds \n- * {} null\n- */\n- bounds: null,\n-\n- /** \n- * Property: size \n- * {} null\n- */\n- size: null,\n-\n- /** \n- * Property: position \n- * {} Top Left pixel of the tile\n- */\n- position: null,\n-\n- /**\n- * Property: isLoading\n- * {Boolean} Is the tile loading?\n- */\n- isLoading: false,\n-\n- /** TBD 3.0 -- remove 'url' from the list of parameters to the constructor.\n- * there is no need for the base tile class to have a url.\n- */\n-\n- /** \n- * Constructor: OpenLayers.Tile\n- * Constructor for a new instance.\n- * \n- * Parameters:\n- * layer - {} layer that the tile will go in.\n- * position - {}\n- * bounds - {}\n- * url - {}\n- * size - {}\n- * options - {Object}\n- */\n- initialize: function(layer, position, bounds, url, size, options) {\n- this.layer = layer;\n- this.position = position.clone();\n- this.setBounds(bounds);\n- this.url = url;\n- if (size) {\n- this.size = size.clone();\n- }\n-\n- //give the tile a unique id based on its BBOX.\n- this.id = OpenLayers.Util.createUniqueID(\"Tile_\");\n-\n- OpenLayers.Util.extend(this, options);\n-\n- this.events = new OpenLayers.Events(this);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n- }\n- },\n-\n- /**\n- * Method: unload\n- * Call immediately before destroying if you are listening to tile\n- * events, so that counters are properly handled if tile is still\n- * loading at destroy-time. Will only fire an event if the tile is\n- * still loading.\n- */\n- unload: function() {\n- if (this.isLoading) {\n- this.isLoading = false;\n- this.events.triggerEvent(\"unload\");\n- }\n- },\n-\n- /** \n- * APIMethod: destroy\n- * Nullify references to prevent circular references and memory leaks.\n- */\n- destroy: function() {\n- this.layer = null;\n- this.bounds = null;\n- this.size = null;\n- this.position = null;\n-\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n- }\n- this.events.destroy();\n- this.eventListeners = null;\n- this.events = null;\n- },\n-\n- /**\n- * Method: draw\n- * Clear whatever is currently in the tile, then return whether or not \n- * it should actually be re-drawn. This is an example implementation\n- * that can be overridden by subclasses. The minimum thing to do here\n- * is to call and return the result from .\n- *\n- * Parameters:\n- * force - {Boolean} If true, the tile will not be cleared and no beforedraw\n- * event will be fired. This is used for drawing tiles asynchronously\n- * after drawing has been cancelled by returning false from a beforedraw\n- * listener.\n- * \n- * Returns:\n- * {Boolean} Whether or not the tile should actually be drawn. Returns null\n- * if a beforedraw listener returned false.\n- */\n- draw: function(force) {\n- if (!force) {\n- //clear tile's contents and mark as not drawn\n- this.clear();\n- }\n- var draw = this.shouldDraw();\n- if (draw && !force && this.events.triggerEvent(\"beforedraw\") === false) {\n- draw = null;\n- }\n- return draw;\n- },\n-\n- /**\n- * Method: shouldDraw\n- * Return whether or not the tile should actually be (re-)drawn. The only\n- * case where we *wouldn't* want to draw the tile is if the tile is outside\n- * its layer's maxExtent\n- * \n- * Returns:\n- * {Boolean} Whether or not the tile should actually be drawn.\n- */\n- shouldDraw: function() {\n- var withinMaxExtent = false,\n- maxExtent = this.layer.maxExtent;\n- if (maxExtent) {\n- var map = this.layer.map;\n- var worldBounds = map.baseLayer.wrapDateLine && map.getMaxExtent();\n- if (this.bounds.intersectsBounds(maxExtent, {\n- inclusive: false,\n- worldBounds: worldBounds\n- })) {\n- withinMaxExtent = true;\n- }\n- }\n-\n- return withinMaxExtent || this.layer.displayOutsideMaxExtent;\n- },\n-\n- /**\n- * Method: setBounds\n- * Sets the bounds on this instance\n- *\n- * Parameters:\n- * bounds {}\n- */\n- setBounds: function(bounds) {\n- bounds = bounds.clone();\n- if (this.layer.map.baseLayer.wrapDateLine) {\n- var worldExtent = this.layer.map.getMaxExtent(),\n- tolerance = this.layer.map.getResolution();\n- bounds = bounds.wrapDateLine(worldExtent, {\n- leftTolerance: tolerance,\n- rightTolerance: tolerance\n- });\n- }\n- this.bounds = bounds;\n- },\n-\n- /** \n- * Method: moveTo\n- * Reposition the tile.\n- *\n- * Parameters:\n- * bounds - {}\n- * position - {}\n- * redraw - {Boolean} Call draw method on tile after moving.\n- * Default is true\n- */\n- moveTo: function(bounds, position, redraw) {\n- if (redraw == null) {\n- redraw = true;\n- }\n-\n- this.setBounds(bounds);\n- this.position = position.clone();\n- if (redraw) {\n- this.draw();\n- }\n- },\n-\n- /** \n- * Method: clear\n- * Clear the tile of any bounds/position-related data so that it can \n- * be reused in a new location.\n- */\n- clear: function(draw) {\n- // to be extended by subclasses\n- },\n-\n- CLASS_NAME: \"OpenLayers.Tile\"\n-});\n-/* ======================================================================\n OpenLayers/Tile/Image.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -30087,2085 +31618,429 @@\n this.tileCache = null;\n this.tileCacheIndex = null;\n this._destroyed = true;\n }\n \n });\n /* ======================================================================\n- OpenLayers/Marker.js\n+ OpenLayers/Format/WPSDescribeProcess.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Icon.js\n+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n */\n \n /**\n- * Class: OpenLayers.Marker\n- * Instances of OpenLayers.Marker are a combination of a \n- * and an . \n- *\n- * Markers are generally added to a special layer called\n- * .\n- *\n- * Example:\n- * (code)\n- * var markers = new OpenLayers.Layer.Markers( \"Markers\" );\n- * map.addLayer(markers);\n- *\n- * var size = new OpenLayers.Size(21,25);\n- * var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);\n- * var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset);\n- * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon));\n- * markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon.clone()));\n- *\n- * (end)\n+ * Class: OpenLayers.Format.WPSDescribeProcess\n+ * Read WPS DescribeProcess responses. \n *\n- * Note that if you pass an icon into the Marker constructor, it will take\n- * that icon and use it. This means that you should not share icons between\n- * markers -- you use them once, but you should clone() for any additional\n- * markers using that same icon.\n+ * Inherits from:\n+ * - \n */\n-OpenLayers.Marker = OpenLayers.Class({\n+OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(\n+ OpenLayers.Format.XML, {\n \n- /** \n- * Property: icon \n- * {} The icon used by this marker.\n- */\n- icon: null,\n+ /**\n+ * Constant: VERSION\n+ * {String} 1.0.0\n+ */\n+ VERSION: \"1.0.0\",\n \n- /** \n- * Property: lonlat \n- * {} location of object\n- */\n- lonlat: null,\n+ /**\n+ * Property: namespaces\n+ * {Object} Mapping of namespace aliases to namespace URIs.\n+ */\n+ namespaces: {\n+ wps: \"http://www.opengis.net/wps/1.0.0\",\n+ ows: \"http://www.opengis.net/ows/1.1\",\n+ xsi: \"http://www.w3.org/2001/XMLSchema-instance\"\n+ },\n \n- /** \n- * Property: events \n- * {} the event handler.\n- */\n- events: null,\n+ /**\n+ * Property: schemaLocation\n+ * {String} Schema location\n+ */\n+ schemaLocation: \"http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd\",\n \n- /** \n- * Property: map \n- * {} the map this marker is attached to\n- */\n- map: null,\n+ /**\n+ * Property: defaultPrefix\n+ */\n+ defaultPrefix: \"wps\",\n \n- /** \n- * Constructor: OpenLayers.Marker\n- *\n- * Parameters:\n- * lonlat - {} the position of this marker\n- * icon - {} the icon for this marker\n- */\n- initialize: function(lonlat, icon) {\n- this.lonlat = lonlat;\n+ /**\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n+ */\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n+ },\n \n- var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();\n- if (this.icon == null) {\n- this.icon = newIcon;\n- } else {\n- this.icon.url = newIcon.url;\n- this.icon.size = newIcon.size;\n- this.icon.offset = newIcon.offset;\n- this.icon.calculateOffset = newIcon.calculateOffset;\n- }\n- this.events = new OpenLayers.Events(this, this.icon.imageDiv);\n- },\n+ /**\n+ * Constructor: OpenLayers.Format.WPSDescribeProcess\n+ *\n+ * Parameters:\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n+ */\n \n- /**\n- * APIMethod: destroy\n- * Destroy the marker. You must first remove the marker from any \n- * layer which it has been added to, or you will get buggy behavior.\n- * (This can not be done within the marker since the marker does not\n- * know which layer it is attached to.)\n- */\n- destroy: function() {\n- // erase any drawn features\n- this.erase();\n+ /**\n+ * APIMethod: read\n+ * Parse a WPS DescribeProcess and return an object with its information.\n+ * \n+ * Parameters: \n+ * data - {String} or {DOMElement} data to read/parse.\n+ *\n+ * Returns:\n+ * {Object}\n+ */\n+ read: function(data) {\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n+ }\n+ if (data && data.nodeType == 9) {\n+ data = data.documentElement;\n+ }\n+ var info = {};\n+ this.readNode(data, info);\n+ return info;\n+ },\n \n- this.map = null;\n+ /**\n+ * Property: readers\n+ * Contains public functions, grouped by namespace prefix, that will\n+ * be applied when a namespaced node is found matching the function\n+ * name. The function will be applied in the scope of this parser\n+ * with two arguments: the node being read and a context object passed\n+ * from the parent.\n+ */\n+ readers: {\n+ \"wps\": {\n+ \"ProcessDescriptions\": function(node, obj) {\n+ obj.processDescriptions = {};\n+ this.readChildNodes(node, obj.processDescriptions);\n+ },\n+ \"ProcessDescription\": function(node, processDescriptions) {\n+ var processVersion = this.getAttributeNS(node, this.namespaces.wps, \"processVersion\");\n+ var processDescription = {\n+ processVersion: processVersion,\n+ statusSupported: (node.getAttribute(\"statusSupported\") === \"true\"),\n+ storeSupported: (node.getAttribute(\"storeSupported\") === \"true\")\n+ };\n+ this.readChildNodes(node, processDescription);\n+ processDescriptions[processDescription.identifier] = processDescription;\n+ },\n+ \"DataInputs\": function(node, processDescription) {\n+ processDescription.dataInputs = [];\n+ this.readChildNodes(node, processDescription.dataInputs);\n+ },\n+ \"ProcessOutputs\": function(node, processDescription) {\n+ processDescription.processOutputs = [];\n+ this.readChildNodes(node, processDescription.processOutputs);\n+ },\n+ \"Output\": function(node, processOutputs) {\n+ var output = {};\n+ this.readChildNodes(node, output);\n+ processOutputs.push(output);\n+ },\n+ \"ComplexOutput\": function(node, output) {\n+ output.complexOutput = {};\n+ this.readChildNodes(node, output.complexOutput);\n+ },\n+ \"LiteralOutput\": function(node, output) {\n+ output.literalOutput = {};\n+ this.readChildNodes(node, output.literalOutput);\n+ },\n+ \"Input\": function(node, dataInputs) {\n+ var input = {\n+ maxOccurs: parseInt(node.getAttribute(\"maxOccurs\")),\n+ minOccurs: parseInt(node.getAttribute(\"minOccurs\"))\n+ };\n+ this.readChildNodes(node, input);\n+ dataInputs.push(input);\n+ },\n+ \"BoundingBoxData\": function(node, input) {\n+ input.boundingBoxData = {};\n+ this.readChildNodes(node, input.boundingBoxData);\n+ },\n+ \"CRS\": function(node, obj) {\n+ if (!obj.CRSs) {\n+ obj.CRSs = {};\n+ }\n+ obj.CRSs[this.getChildValue(node)] = true;\n+ },\n+ \"LiteralData\": function(node, input) {\n+ input.literalData = {};\n+ this.readChildNodes(node, input.literalData);\n+ },\n+ \"ComplexData\": function(node, input) {\n+ input.complexData = {};\n+ this.readChildNodes(node, input.complexData);\n+ },\n+ \"Default\": function(node, complexData) {\n+ complexData[\"default\"] = {};\n+ this.readChildNodes(node, complexData[\"default\"]);\n+ },\n+ \"Supported\": function(node, complexData) {\n+ complexData[\"supported\"] = {};\n+ this.readChildNodes(node, complexData[\"supported\"]);\n+ },\n+ \"Format\": function(node, obj) {\n+ var format = {};\n+ this.readChildNodes(node, format);\n+ if (!obj.formats) {\n+ obj.formats = {};\n+ }\n+ obj.formats[format.mimeType] = true;\n+ },\n+ \"MimeType\": function(node, format) {\n+ format.mimeType = this.getChildValue(node);\n+ }\n+ },\n+ \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n+ },\n \n- this.events.destroy();\n- this.events = null;\n+ CLASS_NAME: \"OpenLayers.Format.WPSDescribeProcess\"\n \n- if (this.icon != null) {\n- this.icon.destroy();\n- this.icon = null;\n- }\n- },\n+ });\n+/* ======================================================================\n+ OpenLayers/WPSClient.js\n+ ====================================================================== */\n \n- /** \n- * Method: draw\n- * Calls draw on the icon, and returns that output.\n- * \n- * Parameters:\n- * px - {}\n- * \n- * Returns:\n- * {DOMElement} A new DOM Image with this marker's icon set at the \n- * location passed-in\n- */\n- draw: function(px) {\n- return this.icon.draw(px);\n- },\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n \n- /** \n- * Method: erase\n- * Erases any drawn elements for this marker.\n- */\n- erase: function() {\n- if (this.icon != null) {\n- this.icon.erase();\n- }\n- },\n+/**\n+ * @requires OpenLayers/SingleFile.js\n+ */\n+\n+/**\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/WPSProcess.js\n+ * @requires OpenLayers/Format/WPSDescribeProcess.js\n+ * @requires OpenLayers/Request.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.WPSClient\n+ * High level API for interaction with Web Processing Services (WPS).\n+ * An instance is used to create \n+ * instances for servers known to the WPSClient. The WPSClient also caches\n+ * DescribeProcess responses to reduce the number of requests sent to servers\n+ * when processes are created.\n+ */\n+OpenLayers.WPSClient = OpenLayers.Class({\n \n /**\n- * Method: moveTo\n- * Move the marker to the new location.\n+ * Property: servers\n+ * {Object} Service metadata, keyed by a local identifier.\n *\n- * Parameters:\n- * px - {|Object} the pixel position to move to.\n- * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n+ * Properties:\n+ * url - {String} the url of the server\n+ * version - {String} WPS version of the server\n+ * processDescription - {Object} Cache of raw DescribeProcess\n+ * responses, keyed by process identifier.\n */\n- moveTo: function(px) {\n- if ((px != null) && (this.icon != null)) {\n- this.icon.moveTo(px);\n- }\n- this.lonlat = this.map.getLonLatFromLayerPx(px);\n- },\n+ servers: null,\n \n /**\n- * APIMethod: isDrawn\n- * \n- * Returns:\n- * {Boolean} Whether or not the marker is drawn.\n+ * Property: version\n+ * {String} The default WPS version to use if none is configured. Default\n+ * is '1.0.0'.\n */\n- isDrawn: function() {\n- var isDrawn = (this.icon && this.icon.isDrawn());\n- return isDrawn;\n- },\n+ version: '1.0.0',\n \n /**\n- * Method: onScreen\n- *\n- * Returns:\n- * {Boolean} Whether or not the marker is currently visible on screen.\n+ * Property: lazy\n+ * {Boolean} Should the DescribeProcess be deferred until a process is\n+ * fully configured? Default is false.\n */\n- onScreen: function() {\n-\n- var onScreen = false;\n- if (this.map) {\n- var screenBounds = this.map.getExtent();\n- onScreen = screenBounds.containsLonLat(this.lonlat);\n- }\n- return onScreen;\n- },\n+ lazy: false,\n \n /**\n- * Method: inflate\n- * Englarges the markers icon by the specified ratio.\n+ * Property: events\n+ * {}\n *\n- * Parameters:\n- * inflate - {float} the ratio to enlarge the marker by (passing 2\n- * will double the size).\n- */\n- inflate: function(inflate) {\n- if (this.icon) {\n- this.icon.setSize({\n- w: this.icon.size.w * inflate,\n- h: this.icon.size.h * inflate\n- });\n- }\n- },\n-\n- /** \n- * Method: setOpacity\n- * Change the opacity of the marker by changin the opacity of \n- * its icon\n- * \n- * Parameters:\n- * opacity - {float} Specified as fraction (0.4, etc)\n- */\n- setOpacity: function(opacity) {\n- this.icon.setOpacity(opacity);\n- },\n-\n- /**\n- * Method: setUrl\n- * Change URL of the Icon Image.\n- * \n- * url - {String} \n- */\n- setUrl: function(url) {\n- this.icon.setUrl(url);\n- },\n-\n- /** \n- * Method: display\n- * Hide or show the icon\n- * \n- * display - {Boolean} \n- */\n- display: function(display) {\n- this.icon.display(display);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Marker\"\n-});\n-\n-\n-/**\n- * Function: defaultIcon\n- * Creates a default .\n- * \n- * Returns:\n- * {} A default OpenLayers.Icon to use for a marker\n- */\n-OpenLayers.Marker.defaultIcon = function() {\n- return new OpenLayers.Icon(OpenLayers.Util.getImageLocation(\"marker.png\"), {\n- w: 21,\n- h: 25\n- }, {\n- x: -10.5,\n- y: -25\n- });\n-};\n-\n-\n-/* ======================================================================\n- OpenLayers/Strategy.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Strategy\n- * Abstract vector layer strategy class. Not to be instantiated directly. Use\n- * one of the strategy subclasses instead.\n- */\n-OpenLayers.Strategy = OpenLayers.Class({\n-\n- /**\n- * Property: layer\n- * {} The layer this strategy belongs to.\n- */\n- layer: null,\n-\n- /**\n- * Property: options\n- * {Object} Any options sent to the constructor.\n- */\n- options: null,\n-\n- /** \n- * Property: active \n- * {Boolean} The control is active.\n- */\n- active: null,\n-\n- /**\n- * Property: autoActivate\n- * {Boolean} The creator of the strategy can set autoActivate to false\n- * to fully control when the protocol is activated and deactivated.\n- * Defaults to true.\n- */\n- autoActivate: true,\n-\n- /**\n- * Property: autoDestroy\n- * {Boolean} The creator of the strategy can set autoDestroy to false\n- * to fully control when the strategy is destroyed. Defaults to\n- * true.\n- */\n- autoDestroy: true,\n-\n- /**\n- * Constructor: OpenLayers.Strategy\n- * Abstract class for vector strategies. Create instances of a subclass.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.options = options;\n- // set the active property here, so that user cannot override it\n- this.active = false;\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Clean up the strategy.\n- */\n- destroy: function() {\n- this.deactivate();\n- this.layer = null;\n- this.options = null;\n- },\n-\n- /**\n- * Method: setLayer\n- * Called to set the property.\n- *\n- * Parameters:\n- * layer - {}\n- */\n- setLayer: function(layer) {\n- this.layer = layer;\n- },\n-\n- /**\n- * Method: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n- *\n- * Returns:\n- * {Boolean} True if the strategy was successfully activated or false if\n- * the strategy was already active.\n- */\n- activate: function() {\n- if (!this.active) {\n- this.active = true;\n- return true;\n- }\n- return false;\n- },\n-\n- /**\n- * Method: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\n- *\n- * Returns:\n- * {Boolean} True if the strategy was successfully deactivated or false if\n- * the strategy was already inactive.\n- */\n- deactivate: function() {\n- if (this.active) {\n- this.active = false;\n- return true;\n- }\n- return false;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Strategy\"\n-});\n-/* ======================================================================\n- OpenLayers/Popup.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-\n-/**\n- * Class: OpenLayers.Popup\n- * A popup is a small div that can opened and closed on the map.\n- * Typically opened in response to clicking on a marker. \n- * See . Popup's don't require their own\n- * layer and are added the the map using the \n- * method.\n- *\n- * Example:\n- * (code)\n- * popup = new OpenLayers.Popup(\"chicken\", \n- * new OpenLayers.LonLat(5,40),\n- * new OpenLayers.Size(200,200),\n- * \"example popup\",\n- * true);\n- * \n- * map.addPopup(popup);\n- * (end)\n- */\n-OpenLayers.Popup = OpenLayers.Class({\n-\n- /** \n- * Property: events \n- * {} custom event manager \n+ * Supported event types:\n+ * describeprocess - Fires when the process description is available.\n+ * Listeners receive an object with a 'raw' property holding the raw\n+ * DescribeProcess response, and an 'identifier' property holding the\n+ * process identifier of the described process.\n */\n events: null,\n \n- /** Property: id\n- * {String} the unique identifier assigned to this popup.\n- */\n- id: \"\",\n-\n- /** \n- * Property: lonlat \n- * {} the position of this popup on the map\n- */\n- lonlat: null,\n-\n- /** \n- * Property: div \n- * {DOMElement} the div that contains this popup.\n- */\n- div: null,\n-\n- /** \n- * Property: contentSize \n- * {} the width and height of the content.\n- */\n- contentSize: null,\n-\n- /** \n- * Property: size \n- * {} the width and height of the popup.\n- */\n- size: null,\n-\n- /** \n- * Property: contentHTML \n- * {String} An HTML string for this popup to display.\n- */\n- contentHTML: null,\n-\n- /** \n- * Property: backgroundColor \n- * {String} the background color used by the popup.\n- */\n- backgroundColor: \"\",\n-\n- /** \n- * Property: opacity \n- * {float} the opacity of this popup (between 0.0 and 1.0)\n- */\n- opacity: \"\",\n-\n- /** \n- * Property: border \n- * {String} the border size of the popup. (eg 2px)\n- */\n- border: \"\",\n-\n- /** \n- * Property: contentDiv \n- * {DOMElement} a reference to the element that holds the content of\n- * the div.\n- */\n- contentDiv: null,\n-\n- /** \n- * Property: groupDiv \n- * {DOMElement} First and only child of 'div'. The group Div contains the\n- * 'contentDiv' and the 'closeDiv'.\n- */\n- groupDiv: null,\n-\n- /** \n- * Property: closeDiv\n- * {DOMElement} the optional closer image\n- */\n- closeDiv: null,\n-\n- /** \n- * APIProperty: autoSize\n- * {Boolean} Resize the popup to auto-fit the contents.\n- * Default is false.\n- */\n- autoSize: false,\n-\n- /**\n- * APIProperty: minSize\n- * {} Minimum size allowed for the popup's contents.\n- */\n- minSize: null,\n-\n- /**\n- * APIProperty: maxSize\n- * {} Maximum size allowed for the popup's contents.\n- */\n- maxSize: null,\n-\n- /** \n- * Property: displayClass\n- * {String} The CSS class of the popup.\n- */\n- displayClass: \"olPopup\",\n-\n- /** \n- * Property: contentDisplayClass\n- * {String} The CSS class of the popup content div.\n- */\n- contentDisplayClass: \"olPopupContent\",\n-\n- /** \n- * Property: padding \n- * {int or } An extra opportunity to specify internal \n- * padding of the content div inside the popup. This was originally\n- * confused with the css padding as specified in style.css's \n- * 'olPopupContent' class. We would like to get rid of this altogether,\n- * except that it does come in handy for the framed and anchoredbubble\n- * popups, who need to maintain yet another barrier between their \n- * content and the outer border of the popup itself. \n- * \n- * Note that in order to not break API, we must continue to support \n- * this property being set as an integer. Really, though, we'd like to \n- * have this specified as a Bounds object so that user can specify\n- * distinct left, top, right, bottom paddings. With the 3.0 release\n- * we can make this only a bounds.\n- */\n- padding: 0,\n-\n- /** \n- * Property: disableFirefoxOverflowHack\n- * {Boolean} The hack for overflow in Firefox causes all elements \n- * to be re-drawn, which causes Flash elements to be \n- * re-initialized, which is troublesome.\n- * With this property the hack can be disabled.\n- */\n- disableFirefoxOverflowHack: false,\n-\n- /**\n- * Method: fixPadding\n- * To be removed in 3.0, this function merely helps us to deal with the \n- * case where the user may have set an integer value for padding, \n- * instead of an object.\n- */\n- fixPadding: function() {\n- if (typeof this.padding == \"number\") {\n- this.padding = new OpenLayers.Bounds(\n- this.padding, this.padding, this.padding, this.padding\n- );\n- }\n- },\n-\n- /**\n- * APIProperty: panMapIfOutOfView\n- * {Boolean} When drawn, pan map such that the entire popup is visible in\n- * the current viewport (if necessary).\n- * Default is false.\n- */\n- panMapIfOutOfView: false,\n-\n- /**\n- * APIProperty: keepInMap \n- * {Boolean} If panMapIfOutOfView is false, and this property is true, \n- * contrain the popup such that it always fits in the available map\n- * space. By default, this is not set on the base class. If you are\n- * creating popups that are near map edges and not allowing pannning,\n- * and especially if you have a popup which has a\n- * fixedRelativePosition, setting this to false may be a smart thing to\n- * do. Subclasses may want to override this setting.\n- * \n- * Default is false.\n- */\n- keepInMap: false,\n-\n- /**\n- * APIProperty: closeOnMove\n- * {Boolean} When map pans, close the popup.\n- * Default is false.\n- */\n- closeOnMove: false,\n-\n- /** \n- * Property: map \n- * {} this gets set in Map.js when the popup is added to the map\n- */\n- map: null,\n-\n- /** \n- * Constructor: OpenLayers.Popup\n- * Create a popup.\n- * \n- * Parameters: \n- * id - {String} a unqiue identifier for this popup. If null is passed\n- * an identifier will be automatically generated. \n- * lonlat - {} The position on the map the popup will\n- * be shown.\n- * contentSize - {} The size of the content.\n- * contentHTML - {String} An HTML string to display inside the \n- * popup.\n- * closeBox - {Boolean} Whether to display a close box inside\n- * the popup.\n- * closeBoxCallback - {Function} Function to be called on closeBox click.\n- */\n- initialize: function(id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback) {\n- if (id == null) {\n- id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- }\n-\n- this.id = id;\n- this.lonlat = lonlat;\n-\n- this.contentSize = (contentSize != null) ? contentSize :\n- new OpenLayers.Size(\n- OpenLayers.Popup.WIDTH,\n- OpenLayers.Popup.HEIGHT);\n- if (contentHTML != null) {\n- this.contentHTML = contentHTML;\n- }\n- this.backgroundColor = OpenLayers.Popup.COLOR;\n- this.opacity = OpenLayers.Popup.OPACITY;\n- this.border = OpenLayers.Popup.BORDER;\n-\n- this.div = OpenLayers.Util.createDiv(this.id, null, null,\n- null, null, null, \"hidden\");\n- this.div.className = this.displayClass;\n-\n- var groupDivId = this.id + \"_GroupDiv\";\n- this.groupDiv = OpenLayers.Util.createDiv(groupDivId, null, null,\n- null, \"relative\", null,\n- \"hidden\");\n-\n- var id = this.div.id + \"_contentDiv\";\n- this.contentDiv = OpenLayers.Util.createDiv(id, null, this.contentSize.clone(),\n- null, \"relative\");\n- this.contentDiv.className = this.contentDisplayClass;\n- this.groupDiv.appendChild(this.contentDiv);\n- this.div.appendChild(this.groupDiv);\n-\n- if (closeBox) {\n- this.addCloseBox(closeBoxCallback);\n- }\n-\n- this.registerEvents();\n- },\n-\n- /** \n- * Method: destroy\n- * nullify references to prevent circular references and memory leaks\n- */\n- destroy: function() {\n-\n- this.id = null;\n- this.lonlat = null;\n- this.size = null;\n- this.contentHTML = null;\n-\n- this.backgroundColor = null;\n- this.opacity = null;\n- this.border = null;\n-\n- if (this.closeOnMove && this.map) {\n- this.map.events.unregister(\"movestart\", this, this.hide);\n- }\n-\n- this.events.destroy();\n- this.events = null;\n-\n- if (this.closeDiv) {\n- OpenLayers.Event.stopObservingElement(this.closeDiv);\n- this.groupDiv.removeChild(this.closeDiv);\n- }\n- this.closeDiv = null;\n-\n- this.div.removeChild(this.groupDiv);\n- this.groupDiv = null;\n-\n- if (this.map != null) {\n- this.map.removePopup(this);\n- }\n- this.map = null;\n- this.div = null;\n-\n- this.autoSize = null;\n- this.minSize = null;\n- this.maxSize = null;\n- this.padding = null;\n- this.panMapIfOutOfView = null;\n- },\n-\n- /** \n- * Method: draw\n- * Constructs the elements that make up the popup.\n- *\n- * Parameters:\n- * px - {} the position the popup in pixels.\n- * \n- * Returns:\n- * {DOMElement} Reference to a div that contains the drawn popup\n- */\n- draw: function(px) {\n- if (px == null) {\n- if ((this.lonlat != null) && (this.map != null)) {\n- px = this.map.getLayerPxFromLonLat(this.lonlat);\n- }\n- }\n-\n- // this assumes that this.map already exists, which is okay because \n- // this.draw is only called once the popup has been added to the map.\n- if (this.closeOnMove) {\n- this.map.events.register(\"movestart\", this, this.hide);\n- }\n-\n- //listen to movestart, moveend to disable overflow (FF bug)\n- if (!this.disableFirefoxOverflowHack && OpenLayers.BROWSER_NAME == 'firefox') {\n- this.map.events.register(\"movestart\", this, function() {\n- var style = document.defaultView.getComputedStyle(\n- this.contentDiv, null\n- );\n- var currentOverflow = style.getPropertyValue(\"overflow\");\n- if (currentOverflow != \"hidden\") {\n- this.contentDiv._oldOverflow = currentOverflow;\n- this.contentDiv.style.overflow = \"hidden\";\n- }\n- });\n- this.map.events.register(\"moveend\", this, function() {\n- var oldOverflow = this.contentDiv._oldOverflow;\n- if (oldOverflow) {\n- this.contentDiv.style.overflow = oldOverflow;\n- this.contentDiv._oldOverflow = null;\n- }\n- });\n- }\n-\n- this.moveTo(px);\n- if (!this.autoSize && !this.size) {\n- this.setSize(this.contentSize);\n- }\n- this.setBackgroundColor();\n- this.setOpacity();\n- this.setBorder();\n- this.setContentHTML();\n-\n- if (this.panMapIfOutOfView) {\n- this.panIntoView();\n- }\n-\n- return this.div;\n- },\n-\n- /** \n- * Method: updatePosition\n- * if the popup has a lonlat and its map members set, \n- * then have it move itself to its proper position\n- */\n- updatePosition: function() {\n- if ((this.lonlat) && (this.map)) {\n- var px = this.map.getLayerPxFromLonLat(this.lonlat);\n- if (px) {\n- this.moveTo(px);\n- }\n- }\n- },\n-\n- /**\n- * Method: moveTo\n- * \n- * Parameters:\n- * px - {} the top and left position of the popup div. \n- */\n- moveTo: function(px) {\n- if ((px != null) && (this.div != null)) {\n- this.div.style.left = px.x + \"px\";\n- this.div.style.top = px.y + \"px\";\n- }\n- },\n-\n- /**\n- * Method: visible\n- *\n- * Returns: \n- * {Boolean} Boolean indicating whether or not the popup is visible\n- */\n- visible: function() {\n- return OpenLayers.Element.visible(this.div);\n- },\n-\n- /**\n- * Method: toggle\n- * Toggles visibility of the popup.\n- */\n- toggle: function() {\n- if (this.visible()) {\n- this.hide();\n- } else {\n- this.show();\n- }\n- },\n-\n- /**\n- * Method: show\n- * Makes the popup visible.\n- */\n- show: function() {\n- this.div.style.display = '';\n-\n- if (this.panMapIfOutOfView) {\n- this.panIntoView();\n- }\n- },\n-\n- /**\n- * Method: hide\n- * Makes the popup invisible.\n- */\n- hide: function() {\n- this.div.style.display = 'none';\n- },\n-\n /**\n- * Method: setSize\n- * Used to adjust the size of the popup. \n+ * Constructor: OpenLayers.WPSClient\n *\n * Parameters:\n- * contentSize - {} the new size for the popup's \n- * contents div (in pixels).\n- */\n- setSize: function(contentSize) {\n- this.size = contentSize.clone();\n-\n- // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n- // must add that to the desired \"size\". \n- var contentDivPadding = this.getContentDivPadding();\n- var wPadding = contentDivPadding.left + contentDivPadding.right;\n- var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n-\n- // take into account the popup's 'padding' property\n- this.fixPadding();\n- wPadding += this.padding.left + this.padding.right;\n- hPadding += this.padding.top + this.padding.bottom;\n-\n- // make extra space for the close div\n- if (this.closeDiv) {\n- var closeDivWidth = parseInt(this.closeDiv.style.width);\n- wPadding += closeDivWidth + contentDivPadding.right;\n- }\n-\n- //increase size of the main popup div to take into account the \n- // users's desired padding and close div. \n- this.size.w += wPadding;\n- this.size.h += hPadding;\n-\n- //now if our browser is IE, we need to actually make the contents \n- // div itself bigger to take its own padding into effect. this makes \n- // me want to shoot someone, but so it goes.\n- if (OpenLayers.BROWSER_NAME == \"msie\") {\n- this.contentSize.w +=\n- contentDivPadding.left + contentDivPadding.right;\n- this.contentSize.h +=\n- contentDivPadding.bottom + contentDivPadding.top;\n- }\n-\n- if (this.div != null) {\n- this.div.style.width = this.size.w + \"px\";\n- this.div.style.height = this.size.h + \"px\";\n- }\n- if (this.contentDiv != null) {\n- this.contentDiv.style.width = contentSize.w + \"px\";\n- this.contentDiv.style.height = contentSize.h + \"px\";\n- }\n- },\n-\n- /**\n- * APIMethod: updateSize\n- * Auto size the popup so that it precisely fits its contents (as \n- * determined by this.contentDiv.innerHTML). Popup size will, of\n- * course, be limited by the available space on the current map\n- */\n- updateSize: function() {\n-\n- // determine actual render dimensions of the contents by putting its\n- // contents into a fake contentDiv (for the CSS) and then measuring it\n- var preparedHTML = \"
\" +\n- this.contentDiv.innerHTML +\n- \"
\";\n-\n- var containerElement = (this.map) ? this.map.div : document.body;\n- var realSize = OpenLayers.Util.getRenderedDimensions(\n- preparedHTML, null, {\n- displayClass: this.displayClass,\n- containerElement: containerElement\n- }\n- );\n-\n- // is the \"real\" size of the div is safe to display in our map?\n- var safeSize = this.getSafeContentSize(realSize);\n-\n- var newSize = null;\n- if (safeSize.equals(realSize)) {\n- //real size of content is small enough to fit on the map, \n- // so we use real size.\n- newSize = realSize;\n-\n- } else {\n-\n- // make a new 'size' object with the clipped dimensions \n- // set or null if not clipped.\n- var fixedSize = {\n- w: (safeSize.w < realSize.w) ? safeSize.w : null,\n- h: (safeSize.h < realSize.h) ? safeSize.h : null\n- };\n-\n- if (fixedSize.w && fixedSize.h) {\n- //content is too big in both directions, so we will use \n- // max popup size (safeSize), knowing well that it will \n- // overflow both ways. \n- newSize = safeSize;\n- } else {\n- //content is clipped in only one direction, so we need to \n- // run getRenderedDimensions() again with a fixed dimension\n- var clippedSize = OpenLayers.Util.getRenderedDimensions(\n- preparedHTML, fixedSize, {\n- displayClass: this.contentDisplayClass,\n- containerElement: containerElement\n- }\n- );\n-\n- //if the clipped size is still the same as the safeSize, \n- // that means that our content must be fixed in the \n- // offending direction. If overflow is 'auto', this means \n- // we are going to have a scrollbar for sure, so we must \n- // adjust for that.\n- //\n- var currentOverflow = OpenLayers.Element.getStyle(\n- this.contentDiv, \"overflow\"\n- );\n- if ((currentOverflow != \"hidden\") &&\n- (clippedSize.equals(safeSize))) {\n- var scrollBar = OpenLayers.Util.getScrollbarWidth();\n- if (fixedSize.w) {\n- clippedSize.h += scrollBar;\n- } else {\n- clippedSize.w += scrollBar;\n- }\n- }\n-\n- newSize = this.getSafeContentSize(clippedSize);\n- }\n- }\n- this.setSize(newSize);\n- },\n-\n- /**\n- * Method: setBackgroundColor\n- * Sets the background color of the popup.\n+ * options - {Object} Object whose properties will be set on the instance.\n *\n- * Parameters:\n- * color - {String} the background color. eg \"#FFBBBB\"\n- */\n- setBackgroundColor: function(color) {\n- if (color != undefined) {\n- this.backgroundColor = color;\n- }\n-\n- if (this.div != null) {\n- this.div.style.backgroundColor = this.backgroundColor;\n- }\n- },\n-\n- /**\n- * Method: setOpacity\n- * Sets the opacity of the popup.\n- * \n- * Parameters:\n- * opacity - {float} A value between 0.0 (transparent) and 1.0 (solid). \n- */\n- setOpacity: function(opacity) {\n- if (opacity != undefined) {\n- this.opacity = opacity;\n- }\n-\n- if (this.div != null) {\n- // for Mozilla and Safari\n- this.div.style.opacity = this.opacity;\n-\n- // for IE\n- this.div.style.filter = 'alpha(opacity=' + this.opacity * 100 + ')';\n- }\n- },\n-\n- /**\n- * Method: setBorder\n- * Sets the border style of the popup.\n+ * Avaliable options:\n+ * servers - {Object} Mandatory. Service metadata, keyed by a local\n+ * identifier. Can either be a string with the service url or an\n+ * object literal with additional metadata:\n *\n- * Parameters:\n- * border - {String} The border style value. eg 2px \n- */\n- setBorder: function(border) {\n- if (border != undefined) {\n- this.border = border;\n- }\n-\n- if (this.div != null) {\n- this.div.style.border = this.border;\n- }\n- },\n-\n- /**\n- * Method: setContentHTML\n- * Allows the user to set the HTML content of the popup.\n+ * (code)\n+ * servers: {\n+ * local: '/geoserver/wps'\n+ * }, {\n+ * opengeo: {\n+ * url: 'http://demo.opengeo.org/geoserver/wps',\n+ * version: '1.0.0'\n+ * }\n+ * }\n+ * (end)\n *\n- * Parameters:\n- * contentHTML - {String} HTML for the div.\n- */\n- setContentHTML: function(contentHTML) {\n-\n- if (contentHTML != null) {\n- this.contentHTML = contentHTML;\n- }\n-\n- if ((this.contentDiv != null) &&\n- (this.contentHTML != null) &&\n- (this.contentHTML != this.contentDiv.innerHTML)) {\n-\n- this.contentDiv.innerHTML = this.contentHTML;\n-\n- if (this.autoSize) {\n-\n- //if popup has images, listen for when they finish\n- // loading and resize accordingly\n- this.registerImageListeners();\n-\n- //auto size the popup to its current contents\n- this.updateSize();\n- }\n- }\n-\n- },\n-\n- /**\n- * Method: registerImageListeners\n- * Called when an image contained by the popup loaded. this function\n- * updates the popup size, then unregisters the image load listener.\n- */\n- registerImageListeners: function() {\n-\n- // As the images load, this function will call updateSize() to \n- // resize the popup to fit the content div (which presumably is now\n- // bigger than when the image was not loaded).\n- // \n- // If the 'panMapIfOutOfView' property is set, we will pan the newly\n- // resized popup back into view.\n- // \n- // Note that this function, when called, will have 'popup' and \n- // 'img' properties in the context.\n- //\n- var onImgLoad = function() {\n- if (this.popup.id === null) { // this.popup has been destroyed!\n- return;\n- }\n- this.popup.updateSize();\n-\n- if (this.popup.visible() && this.popup.panMapIfOutOfView) {\n- this.popup.panIntoView();\n- }\n-\n- OpenLayers.Event.stopObserving(\n- this.img, \"load\", this.img._onImgLoad\n- );\n-\n- };\n-\n- //cycle through the images and if their size is 0x0, that means that \n- // they haven't been loaded yet, so we attach the listener, which \n- // will fire when the images finish loading and will resize the \n- // popup accordingly to its new size.\n- var images = this.contentDiv.getElementsByTagName(\"img\");\n- for (var i = 0, len = images.length; i < len; i++) {\n- var img = images[i];\n- if (img.width == 0 || img.height == 0) {\n-\n- var context = {\n- 'popup': this,\n- 'img': img\n- };\n-\n- //expando this function to the image itself before registering\n- // it. This way we can easily and properly unregister it.\n- img._onImgLoad = OpenLayers.Function.bind(onImgLoad, context);\n-\n- OpenLayers.Event.observe(img, 'load', img._onImgLoad);\n- }\n- }\n- },\n-\n- /**\n- * APIMethod: getSafeContentSize\n- * \n- * Parameters:\n- * size - {} Desired size to make the popup.\n- * \n- * Returns:\n- * {} A size to make the popup which is neither smaller\n- * than the specified minimum size, nor bigger than the maximum \n- * size (which is calculated relative to the size of the viewport).\n+ * lazy - {Boolean} Optional. Set to true if DescribeProcess should not be\n+ * requested until a process is fully configured. Default is false.\n */\n- getSafeContentSize: function(size) {\n-\n- var safeContentSize = size.clone();\n-\n- // if our contentDiv has a css 'padding' set on it by a stylesheet, we \n- // must add that to the desired \"size\". \n- var contentDivPadding = this.getContentDivPadding();\n- var wPadding = contentDivPadding.left + contentDivPadding.right;\n- var hPadding = contentDivPadding.top + contentDivPadding.bottom;\n-\n- // take into account the popup's 'padding' property\n- this.fixPadding();\n- wPadding += this.padding.left + this.padding.right;\n- hPadding += this.padding.top + this.padding.bottom;\n-\n- if (this.closeDiv) {\n- var closeDivWidth = parseInt(this.closeDiv.style.width);\n- wPadding += closeDivWidth + contentDivPadding.right;\n- }\n-\n- // prevent the popup from being smaller than a specified minimal size\n- if (this.minSize) {\n- safeContentSize.w = Math.max(safeContentSize.w,\n- (this.minSize.w - wPadding));\n- safeContentSize.h = Math.max(safeContentSize.h,\n- (this.minSize.h - hPadding));\n- }\n-\n- // prevent the popup from being bigger than a specified maximum size\n- if (this.maxSize) {\n- safeContentSize.w = Math.min(safeContentSize.w,\n- (this.maxSize.w - wPadding));\n- safeContentSize.h = Math.min(safeContentSize.h,\n- (this.maxSize.h - hPadding));\n- }\n-\n- //make sure the desired size to set doesn't result in a popup that \n- // is bigger than the map's viewport.\n- //\n- if (this.map && this.map.size) {\n-\n- var extraX = 0,\n- extraY = 0;\n- if (this.keepInMap && !this.panMapIfOutOfView) {\n- var px = this.map.getPixelFromLonLat(this.lonlat);\n- switch (this.relativePosition) {\n- case \"tr\":\n- extraX = px.x;\n- extraY = this.map.size.h - px.y;\n- break;\n- case \"tl\":\n- extraX = this.map.size.w - px.x;\n- extraY = this.map.size.h - px.y;\n- break;\n- case \"bl\":\n- extraX = this.map.size.w - px.x;\n- extraY = px.y;\n- break;\n- case \"br\":\n- extraX = px.x;\n- extraY = px.y;\n- break;\n- default:\n- extraX = px.x;\n- extraY = this.map.size.h - px.y;\n- break;\n- }\n- }\n-\n- var maxY = this.map.size.h -\n- this.map.paddingForPopups.top -\n- this.map.paddingForPopups.bottom -\n- hPadding - extraY;\n-\n- var maxX = this.map.size.w -\n- this.map.paddingForPopups.left -\n- this.map.paddingForPopups.right -\n- wPadding - extraX;\n-\n- safeContentSize.w = Math.min(safeContentSize.w, maxX);\n- safeContentSize.h = Math.min(safeContentSize.h, maxY);\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.events = new OpenLayers.Events(this);\n+ this.servers = {};\n+ for (var s in options.servers) {\n+ this.servers[s] = typeof options.servers[s] == 'string' ? {\n+ url: options.servers[s],\n+ version: this.version,\n+ processDescription: {}\n+ } : options.servers[s];\n }\n-\n- return safeContentSize;\n },\n \n /**\n- * Method: getContentDivPadding\n- * Glorious, oh glorious hack in order to determine the css 'padding' of \n- * the contentDiv. IE/Opera return null here unless we actually add the \n- * popup's main 'div' element (which contains contentDiv) to the DOM. \n- * So we make it invisible and then add it to the document temporarily. \n- *\n- * Once we've taken the padding readings we need, we then remove it \n- * from the DOM (it will actually get added to the DOM in \n- * Map.js's addPopup)\n+ * APIMethod: execute\n+ * Shortcut to execute a process with a single function call. This is\n+ * equivalent to using and then calling execute on the\n+ * process.\n *\n- * Returns:\n- * {}\n- */\n- getContentDivPadding: function() {\n-\n- //use cached value if we have it\n- var contentDivPadding = this._contentDivPadding;\n- if (!contentDivPadding) {\n-\n- if (this.div.parentNode == null) {\n- //make the div invisible and add it to the page \n- this.div.style.display = \"none\";\n- document.body.appendChild(this.div);\n- }\n-\n- //read the padding settings from css, put them in an OL.Bounds \n- contentDivPadding = new OpenLayers.Bounds(\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-left\"),\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-bottom\"),\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-right\"),\n- OpenLayers.Element.getStyle(this.contentDiv, \"padding-top\")\n- );\n-\n- //cache the value\n- this._contentDivPadding = contentDivPadding;\n-\n- if (this.div.parentNode == document.body) {\n- //remove the div from the page and make it visible again\n- document.body.removeChild(this.div);\n- this.div.style.display = \"\";\n- }\n- }\n- return contentDivPadding;\n- },\n-\n- /**\n- * Method: addCloseBox\n- * \n * Parameters:\n- * callback - {Function} The callback to be called when the close button\n- * is clicked.\n- */\n- addCloseBox: function(callback) {\n-\n- this.closeDiv = OpenLayers.Util.createDiv(\n- this.id + \"_close\", null, {\n- w: 17,\n- h: 17\n- }\n- );\n- this.closeDiv.className = \"olPopupCloseBox\";\n-\n- // use the content div's css padding to determine if we should\n- // padd the close div\n- var contentDivPadding = this.getContentDivPadding();\n-\n- this.closeDiv.style.right = contentDivPadding.right + \"px\";\n- this.closeDiv.style.top = contentDivPadding.top + \"px\";\n- this.groupDiv.appendChild(this.closeDiv);\n-\n- var closePopup = callback || function(e) {\n- this.hide();\n- OpenLayers.Event.stop(e);\n- };\n- OpenLayers.Event.observe(this.closeDiv, \"touchend\",\n- OpenLayers.Function.bindAsEventListener(closePopup, this));\n- OpenLayers.Event.observe(this.closeDiv, \"click\",\n- OpenLayers.Function.bindAsEventListener(closePopup, this));\n- },\n-\n- /**\n- * Method: panIntoView\n- * Pans the map such that the popup is totaly viewable (if necessary)\n- */\n- panIntoView: function() {\n-\n- var mapSize = this.map.getSize();\n-\n- //start with the top left corner of the popup, in px, \n- // relative to the viewport\n- var origTL = this.map.getViewPortPxFromLayerPx(new OpenLayers.Pixel(\n- parseInt(this.div.style.left),\n- parseInt(this.div.style.top)\n- ));\n- var newTL = origTL.clone();\n-\n- //new left (compare to margins, using this.size to calculate right)\n- if (origTL.x < this.map.paddingForPopups.left) {\n- newTL.x = this.map.paddingForPopups.left;\n- } else\n- if ((origTL.x + this.size.w) > (mapSize.w - this.map.paddingForPopups.right)) {\n- newTL.x = mapSize.w - this.map.paddingForPopups.right - this.size.w;\n- }\n-\n- //new top (compare to margins, using this.size to calculate bottom)\n- if (origTL.y < this.map.paddingForPopups.top) {\n- newTL.y = this.map.paddingForPopups.top;\n- } else\n- if ((origTL.y + this.size.h) > (mapSize.h - this.map.paddingForPopups.bottom)) {\n- newTL.y = mapSize.h - this.map.paddingForPopups.bottom - this.size.h;\n- }\n-\n- var dx = origTL.x - newTL.x;\n- var dy = origTL.y - newTL.y;\n-\n- this.map.pan(dx, dy);\n- },\n-\n- /** \n- * Method: registerEvents\n- * Registers events on the popup.\n+ * options - {Object} Options for the execute operation.\n *\n- * Do this in a separate function so that subclasses can \n- * choose to override it if they wish to deal differently\n- * with mouse events\n- * \n- * Note in the following handler functions that some special\n- * care is needed to deal correctly with mousing and popups. \n- * \n- * Because the user might select the zoom-rectangle option and\n- * then drag it over a popup, we need a safe way to allow the\n- * mousemove and mouseup events to pass through the popup when\n- * they are initiated from outside. The same procedure is needed for\n- * touchmove and touchend events.\n- * \n- * Otherwise, we want to essentially kill the event propagation\n- * for all other events, though we have to do so carefully, \n- * without disabling basic html functionality, like clicking on \n- * hyperlinks or drag-selecting text.\n+ * Available options:\n+ * server - {String} Mandatory. One of the local identifiers of the\n+ * configured servers.\n+ * process - {String} Mandatory. A process identifier known to the\n+ * server.\n+ * inputs - {Object} The inputs for the process, keyed by input identifier.\n+ * For spatial data inputs, the value of an input is usually an\n+ * , an or an array of\n+ * geometries or features.\n+ * output - {String} The identifier of an output to parse. Optional. If not\n+ * provided, the first output will be parsed.\n+ * success - {Function} Callback to call when the process is complete.\n+ * This function is called with an outputs object as argument, which\n+ * will have a property with the identifier of the requested output\n+ * (e.g. 'result'). For processes that generate spatial output, the\n+ * value will either be a single or an\n+ * array of features.\n+ * scope - {Object} Optional scope for the success callback.\n */\n- registerEvents: function() {\n- this.events = new OpenLayers.Events(this, this.div, null, true);\n-\n- function onTouchstart(evt) {\n- OpenLayers.Event.stop(evt, true);\n- }\n- this.events.on({\n- \"mousedown\": this.onmousedown,\n- \"mousemove\": this.onmousemove,\n- \"mouseup\": this.onmouseup,\n- \"click\": this.onclick,\n- \"mouseout\": this.onmouseout,\n- \"dblclick\": this.ondblclick,\n- \"touchstart\": onTouchstart,\n- scope: this\n+ execute: function(options) {\n+ var process = this.getProcess(options.server, options.process);\n+ process.execute({\n+ inputs: options.inputs,\n+ success: options.success,\n+ scope: options.scope\n });\n-\n- },\n-\n- /** \n- * Method: onmousedown \n- * When mouse goes down within the popup, make a note of\n- * it locally, and then do not propagate the mousedown \n- * (but do so safely so that user can select text inside)\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmousedown: function(evt) {\n- this.mousedown = true;\n- OpenLayers.Event.stop(evt, true);\n- },\n-\n- /** \n- * Method: onmousemove\n- * If the drag was started within the popup, then \n- * do not propagate the mousemove (but do so safely\n- * so that user can select text inside)\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmousemove: function(evt) {\n- if (this.mousedown) {\n- OpenLayers.Event.stop(evt, true);\n- }\n- },\n-\n- /** \n- * Method: onmouseup\n- * When mouse comes up within the popup, after going down \n- * in it, reset the flag, and then (once again) do not \n- * propagate the event, but do so safely so that user can \n- * select text inside\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmouseup: function(evt) {\n- if (this.mousedown) {\n- this.mousedown = false;\n- OpenLayers.Event.stop(evt, true);\n- }\n- },\n-\n- /**\n- * Method: onclick\n- * Ignore clicks, but allowing default browser handling\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onclick: function(evt) {\n- OpenLayers.Event.stop(evt, true);\n- },\n-\n- /** \n- * Method: onmouseout\n- * When mouse goes out of the popup set the flag to false so that\n- * if they let go and then drag back in, we won't be confused.\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- onmouseout: function(evt) {\n- this.mousedown = false;\n- },\n-\n- /** \n- * Method: ondblclick\n- * Ignore double-clicks, but allowing default browser handling\n- * \n- * Parameters:\n- * evt - {Event} \n- */\n- ondblclick: function(evt) {\n- OpenLayers.Event.stop(evt, true);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Popup\"\n-});\n-\n-OpenLayers.Popup.WIDTH = 200;\n-OpenLayers.Popup.HEIGHT = 200;\n-OpenLayers.Popup.COLOR = \"white\";\n-OpenLayers.Popup.OPACITY = 1;\n-OpenLayers.Popup.BORDER = \"0px\";\n-/* ======================================================================\n- OpenLayers/StyleMap.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Style.js\n- * @requires OpenLayers/Feature/Vector.js\n- */\n-\n-/**\n- * Class: OpenLayers.StyleMap\n- */\n-OpenLayers.StyleMap = OpenLayers.Class({\n-\n- /**\n- * Property: styles\n- * {Object} Hash of {}, keyed by names of well known\n- * rendering intents (e.g. \"default\", \"temporary\", \"select\", \"delete\").\n- */\n- styles: null,\n-\n- /**\n- * Property: extendDefault\n- * {Boolean} if true, every render intent will extend the symbolizers\n- * specified for the \"default\" intent at rendering time. Otherwise, every\n- * rendering intent will be treated as a completely independent style.\n- */\n- extendDefault: true,\n-\n- /**\n- * Constructor: OpenLayers.StyleMap\n- * \n- * Parameters:\n- * style - {Object} Optional. Either a style hash, or a style object, or\n- * a hash of style objects (style hashes) keyed by rendering\n- * intent. If just one style hash or style object is passed,\n- * this will be used for all known render intents (default,\n- * select, temporary)\n- * options - {Object} optional hash of additional options for this\n- * instance\n- */\n- initialize: function(style, options) {\n- this.styles = {\n- \"default\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"default\"]),\n- \"select\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"select\"]),\n- \"temporary\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"temporary\"]),\n- \"delete\": new OpenLayers.Style(\n- OpenLayers.Feature.Vector.style[\"delete\"])\n- };\n-\n- // take whatever the user passed as style parameter and convert it\n- // into parts of stylemap.\n- if (style instanceof OpenLayers.Style) {\n- // user passed a style object\n- this.styles[\"default\"] = style;\n- this.styles[\"select\"] = style;\n- this.styles[\"temporary\"] = style;\n- this.styles[\"delete\"] = style;\n- } else if (typeof style == \"object\") {\n- for (var key in style) {\n- if (style[key] instanceof OpenLayers.Style) {\n- // user passed a hash of style objects\n- this.styles[key] = style[key];\n- } else if (typeof style[key] == \"object\") {\n- // user passsed a hash of style hashes\n- this.styles[key] = new OpenLayers.Style(style[key]);\n- } else {\n- // user passed a style hash (i.e. symbolizer)\n- this.styles[\"default\"] = new OpenLayers.Style(style);\n- this.styles[\"select\"] = new OpenLayers.Style(style);\n- this.styles[\"temporary\"] = new OpenLayers.Style(style);\n- this.styles[\"delete\"] = new OpenLayers.Style(style);\n- break;\n- }\n- }\n- }\n- OpenLayers.Util.extend(this, options);\n- },\n-\n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- for (var key in this.styles) {\n- this.styles[key].destroy();\n- }\n- this.styles = null;\n- },\n-\n- /**\n- * Method: createSymbolizer\n- * Creates the symbolizer for a feature for a render intent.\n- * \n- * Parameters:\n- * feature - {} The feature to evaluate the rules\n- * of the intended style against.\n- * intent - {String} The intent determines the symbolizer that will be\n- * used to draw the feature. Well known intents are \"default\"\n- * (for just drawing the features), \"select\" (for selected\n- * features) and \"temporary\" (for drawing features).\n- * \n- * Returns:\n- * {Object} symbolizer hash\n- */\n- createSymbolizer: function(feature, intent) {\n- if (!feature) {\n- feature = new OpenLayers.Feature.Vector();\n- }\n- if (!this.styles[intent]) {\n- intent = \"default\";\n- }\n- feature.renderIntent = intent;\n- var defaultSymbolizer = {};\n- if (this.extendDefault && intent != \"default\") {\n- defaultSymbolizer = this.styles[\"default\"].createSymbolizer(feature);\n- }\n- return OpenLayers.Util.extend(defaultSymbolizer,\n- this.styles[intent].createSymbolizer(feature));\n- },\n-\n- /**\n- * Method: addUniqueValueRules\n- * Convenience method to create comparison rules for unique values of a\n- * property. The rules will be added to the style object for a specified\n- * rendering intent. This method is a shortcut for creating something like\n- * the \"unique value legends\" familiar from well known desktop GIS systems\n- * \n- * Parameters:\n- * renderIntent - {String} rendering intent to add the rules to\n- * property - {String} values of feature attributes to create the\n- * rules for\n- * symbolizers - {Object} Hash of symbolizers, keyed by the desired\n- * property values \n- * context - {Object} An optional object with properties that\n- * symbolizers' property values should be evaluated\n- * against. If no context is specified, feature.attributes\n- * will be used\n- */\n- addUniqueValueRules: function(renderIntent, property, symbolizers, context) {\n- var rules = [];\n- for (var value in symbolizers) {\n- rules.push(new OpenLayers.Rule({\n- symbolizer: symbolizers[value],\n- context: context,\n- filter: new OpenLayers.Filter.Comparison({\n- type: OpenLayers.Filter.Comparison.EQUAL_TO,\n- property: property,\n- value: value\n- })\n- }));\n- }\n- this.styles[renderIntent].addRules(rules);\n },\n \n- CLASS_NAME: \"OpenLayers.StyleMap\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Events.js\n- */\n-\n-/**\n- * Class: OpenLayers.Handler\n- * Base class to construct a higher-level handler for event sequences. All\n- * handlers have activate and deactivate methods. In addition, they have\n- * methods named like browser events. When a handler is activated, any\n- * additional methods named like a browser event is registered as a\n- * listener for the corresponding event. When a handler is deactivated,\n- * those same methods are unregistered as event listeners.\n- *\n- * Handlers also typically have a callbacks object with keys named like\n- * the abstracted events or event sequences that they are in charge of\n- * handling. The controls that wrap handlers define the methods that\n- * correspond to these abstract events - so instead of listening for\n- * individual browser events, they only listen for the abstract events\n- * defined by the handler.\n- * \n- * Handlers are created by controls, which ultimately have the responsibility\n- * of making changes to the the state of the application. Handlers\n- * themselves may make temporary changes, but in general are expected to\n- * return the application in the same state that they found it.\n- */\n-OpenLayers.Handler = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String}\n- */\n- id: null,\n-\n- /**\n- * APIProperty: control\n- * {}. The control that initialized this handler. The\n- * control is assumed to have a valid map property - that map is used\n- * in the handler's own setMap method.\n- */\n- control: null,\n-\n- /**\n- * Property: map\n- * {}\n- */\n- map: null,\n-\n- /**\n- * APIProperty: keyMask\n- * {Integer} Use bitwise operators and one or more of the OpenLayers.Handler\n- * constants to construct a keyMask. The keyMask is used by\n- * . If the keyMask matches the combination of keys\n- * down on an event, checkModifiers returns true.\n- *\n- * Example:\n- * (code)\n- * // handler only responds if the Shift key is down\n- * handler.keyMask = OpenLayers.Handler.MOD_SHIFT;\n- *\n- * // handler only responds if Ctrl-Shift is down\n- * handler.keyMask = OpenLayers.Handler.MOD_SHIFT |\n- * OpenLayers.Handler.MOD_CTRL;\n- * (end)\n- */\n- keyMask: null,\n-\n- /**\n- * Property: active\n- * {Boolean}\n- */\n- active: false,\n-\n- /**\n- * Property: evt\n- * {Event} This property references the last event handled by the handler.\n- * Note that this property is not part of the stable API. Use of the\n- * evt property should be restricted to controls in the library\n- * or other applications that are willing to update with changes to\n- * the OpenLayers code.\n- */\n- evt: null,\n-\n- /**\n- * Property: touch\n- * {Boolean} Indicates the support of touch events. When touch events are \n- * started touch will be true and all mouse related listeners will do \n- * nothing.\n- */\n- touch: false,\n-\n /**\n- * Constructor: OpenLayers.Handler\n- * Construct a handler.\n+ * APIMethod: getProcess\n+ * Creates an .\n *\n * Parameters:\n- * control - {} The control that initialized this\n- * handler. The control is assumed to have a valid map property; that\n- * map is used in the handler's own setMap method. If a map property\n- * is present in the options argument it will be used instead.\n- * callbacks - {Object} An object whose properties correspond to abstracted\n- * events or sequences of browser events. The values for these\n- * properties are functions defined by the control that get called by\n- * the handler.\n- * options - {Object} An optional object whose properties will be set on\n- * the handler.\n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Util.extend(this, options);\n- this.control = control;\n- this.callbacks = callbacks;\n-\n- var map = this.map || control.map;\n- if (map) {\n- this.setMap(map);\n- }\n-\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /**\n- * Method: setMap\n- */\n- setMap: function(map) {\n- this.map = map;\n- },\n-\n- /**\n- * Method: checkModifiers\n- * Check the keyMask on the handler. If no is set, this always\n- * returns true. If a is set and it matches the combination\n- * of keys down on an event, this returns true.\n+ * serverID - {String} Local identifier from the servers that this instance\n+ * was constructed with.\n+ * processID - {String} Process identifier known to the server.\n *\n * Returns:\n- * {Boolean} The keyMask matches the keys down on an event.\n- */\n- checkModifiers: function(evt) {\n- if (this.keyMask == null) {\n- return true;\n- }\n- /* calculate the keyboard modifier mask for this event */\n- var keyModifiers =\n- (evt.shiftKey ? OpenLayers.Handler.MOD_SHIFT : 0) |\n- (evt.ctrlKey ? OpenLayers.Handler.MOD_CTRL : 0) |\n- (evt.altKey ? OpenLayers.Handler.MOD_ALT : 0) |\n- (evt.metaKey ? OpenLayers.Handler.MOD_META : 0);\n-\n- /* if it differs from the handler object's key mask,\n- bail out of the event handler */\n- return (keyModifiers == this.keyMask);\n- },\n-\n- /**\n- * APIMethod: activate\n- * Turn on the handler. Returns false if the handler was already active.\n- * \n- * Returns: \n- * {Boolean} The handler was activated.\n- */\n- activate: function() {\n- if (this.active) {\n- return false;\n- }\n- // register for event handlers defined on this class.\n- var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n- for (var i = 0, len = events.length; i < len; i++) {\n- if (this[events[i]]) {\n- this.register(events[i], this[events[i]]);\n- }\n- }\n- this.active = true;\n- return true;\n- },\n-\n- /**\n- * APIMethod: deactivate\n- * Turn off the handler. Returns false if the handler was already inactive.\n- * \n- * Returns:\n- * {Boolean} The handler was deactivated.\n- */\n- deactivate: function() {\n- if (!this.active) {\n- return false;\n- }\n- // unregister event handlers defined on this class.\n- var events = OpenLayers.Events.prototype.BROWSER_EVENTS;\n- for (var i = 0, len = events.length; i < len; i++) {\n- if (this[events[i]]) {\n- this.unregister(events[i], this[events[i]]);\n- }\n- }\n- this.touch = false;\n- this.active = false;\n- return true;\n- },\n-\n- /**\n- * Method: startTouch\n- * Start touch events, this method must be called by subclasses in \n- * \"touchstart\" method. When touch events are started will be\n- * true and all mouse related listeners will do nothing.\n+ * {}\n */\n- startTouch: function() {\n- if (!this.touch) {\n- this.touch = true;\n- var events = [\n- \"mousedown\", \"mouseup\", \"mousemove\", \"click\", \"dblclick\",\n- \"mouseout\"\n- ];\n- for (var i = 0, len = events.length; i < len; i++) {\n- if (this[events[i]]) {\n- this.unregister(events[i], this[events[i]]);\n- }\n- }\n+ getProcess: function(serverID, processID) {\n+ var process = new OpenLayers.WPSProcess({\n+ client: this,\n+ server: serverID,\n+ identifier: processID\n+ });\n+ if (!this.lazy) {\n+ process.describe();\n }\n+ return process;\n },\n \n /**\n- * Method: callback\n- * Trigger the control's named callback with the given arguments\n+ * Method: describeProcess\n *\n * Parameters:\n- * name - {String} The key for the callback that is one of the properties\n- * of the handler's callbacks object.\n- * args - {Array(*)} An array of arguments (any type) with which to call \n- * the callback (defined by the control).\n+ * serverID - {String} Identifier of the server\n+ * processID - {String} Identifier of the requested process\n+ * callback - {Function} Callback to call when the description is available\n+ * scope - {Object} Optional execution scope for the callback function\n */\n- callback: function(name, args) {\n- if (name && this.callbacks[name]) {\n- this.callbacks[name].apply(this.control, args);\n+ describeProcess: function(serverID, processID, callback, scope) {\n+ var server = this.servers[serverID];\n+ if (!server.processDescription[processID]) {\n+ if (!(processID in server.processDescription)) {\n+ // set to null so we know a describeFeature request is pending\n+ server.processDescription[processID] = null;\n+ OpenLayers.Request.GET({\n+ url: server.url,\n+ params: {\n+ SERVICE: 'WPS',\n+ VERSION: server.version,\n+ REQUEST: 'DescribeProcess',\n+ IDENTIFIER: processID\n+ },\n+ success: function(response) {\n+ server.processDescription[processID] = response.responseText;\n+ this.events.triggerEvent('describeprocess', {\n+ identifier: processID,\n+ raw: response.responseText\n+ });\n+ },\n+ scope: this\n+ });\n+ } else {\n+ // pending request\n+ this.events.register('describeprocess', this, function describe(evt) {\n+ if (evt.identifier === processID) {\n+ this.events.unregister('describeprocess', this, describe);\n+ callback.call(scope, evt.raw);\n+ }\n+ });\n+ }\n+ } else {\n+ window.setTimeout(function() {\n+ callback.call(scope, server.processDescription[processID]);\n+ }, 0);\n }\n },\n \n /**\n- * Method: register\n- * register an event on the map\n- */\n- register: function(name, method) {\n- // TODO: deal with registerPriority in 3.0\n- this.map.events.registerPriority(name, this, method);\n- this.map.events.registerPriority(name, this, this.setEvent);\n- },\n-\n- /**\n- * Method: unregister\n- * unregister an event from the map\n- */\n- unregister: function(name, method) {\n- this.map.events.unregister(name, this, method);\n- this.map.events.unregister(name, this, this.setEvent);\n- },\n-\n- /**\n- * Method: setEvent\n- * With each registered browser event, the handler sets its own evt\n- * property. This property can be accessed by controls if needed\n- * to get more information about the event that the handler is\n- * processing.\n- *\n- * This allows modifier keys on the event to be checked (alt, shift, ctrl,\n- * and meta cannot be checked with the keyboard handler). For a\n- * control to determine which modifier keys are associated with the\n- * event that a handler is currently processing, it should access\n- * (code)handler.evt.altKey || handler.evt.shiftKey ||\n- * handler.evt.ctrlKey || handler.evt.metaKey(end).\n- *\n- * Parameters:\n- * evt - {Event} The browser event.\n- */\n- setEvent: function(evt) {\n- this.evt = evt;\n- return true;\n- },\n-\n- /**\n * Method: destroy\n- * Deconstruct the handler.\n */\n destroy: function() {\n- // unregister event listeners\n- this.deactivate();\n- // eliminate circular references\n- this.control = this.map = null;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler\"\n-});\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_NONE\n- * If set as the , returns false if any key is down.\n- */\n-OpenLayers.Handler.MOD_NONE = 0;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_SHIFT\n- * If set as the , returns false if Shift is down.\n- */\n-OpenLayers.Handler.MOD_SHIFT = 1;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_CTRL\n- * If set as the , returns false if Ctrl is down.\n- */\n-OpenLayers.Handler.MOD_CTRL = 2;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_ALT\n- * If set as the , returns false if Alt is down.\n- */\n-OpenLayers.Handler.MOD_ALT = 4;\n-\n-/**\n- * Constant: OpenLayers.Handler.MOD_META\n- * If set as the , returns false if Cmd is down.\n- */\n-OpenLayers.Handler.MOD_META = 8;\n-\n-\n-/* ======================================================================\n- OpenLayers/Spherical.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n-\n-/**\n- * Namespace: Spherical\n- * The OpenLayers.Spherical namespace includes utility functions for\n- * calculations on the basis of a spherical earth (ignoring ellipsoidal\n- * effects), which is accurate enough for most purposes.\n- *\n- * Relevant links:\n- * * http://www.movable-type.co.uk/scripts/latlong.html\n- * * http://code.google.com/apis/maps/documentation/javascript/reference.html#spherical\n- */\n-\n-OpenLayers.Spherical = OpenLayers.Spherical || {};\n-\n-OpenLayers.Spherical.DEFAULT_RADIUS = 6378137;\n-\n-/**\n- * APIFunction: computeDistanceBetween\n- * Computes the distance between two LonLats.\n- *\n- * Parameters:\n- * from - {} or {Object} Starting point. A LonLat or\n- * a JavaScript literal with lon lat properties.\n- * to - {} or {Object} Ending point. A LonLat or a\n- * JavaScript literal with lon lat properties.\n- * radius - {Float} The radius. Optional. Defaults to 6378137 meters.\n- *\n- * Returns:\n- * {Float} The distance in meters.\n- */\n-OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) {\n- var R = radius || OpenLayers.Spherical.DEFAULT_RADIUS;\n- var sinHalfDeltaLon = Math.sin(Math.PI * (to.lon - from.lon) / 360);\n- var sinHalfDeltaLat = Math.sin(Math.PI * (to.lat - from.lat) / 360);\n- var a = sinHalfDeltaLat * sinHalfDeltaLat +\n- sinHalfDeltaLon * sinHalfDeltaLon * Math.cos(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180);\n- return 2 * R * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n-};\n-\n-\n-/**\n- * APIFunction: computeHeading\n- * Computes the heading from one LonLat to another LonLat.\n- *\n- * Parameters:\n- * from - {} or {Object} Starting point. A LonLat or\n- * a JavaScript literal with lon lat properties.\n- * to - {} or {Object} Ending point. A LonLat or a\n- * JavaScript literal with lon lat properties.\n- *\n- * Returns:\n- * {Float} The heading in degrees.\n- */\n-OpenLayers.Spherical.computeHeading = function(from, to) {\n- var y = Math.sin(Math.PI * (from.lon - to.lon) / 180) * Math.cos(Math.PI * to.lat / 180);\n- var x = Math.cos(Math.PI * from.lat / 180) * Math.sin(Math.PI * to.lat / 180) -\n- Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (from.lon - to.lon) / 180);\n- return 180 * Math.atan2(y, x) / Math.PI;\n-};\n-/* ======================================================================\n- OpenLayers/Symbolizer.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Symbolizer\n- * Base class representing a symbolizer used for feature rendering.\n- */\n-OpenLayers.Symbolizer = OpenLayers.Class({\n-\n-\n- /**\n- * APIProperty: zIndex\n- * {Number} The zIndex determines the rendering order for a symbolizer.\n- * Symbolizers with larger zIndex values are rendered over symbolizers\n- * with smaller zIndex values. Default is 0.\n- */\n- zIndex: 0,\n-\n- /**\n- * Constructor: OpenLayers.Symbolizer\n- * Instances of this class are not useful. See one of the subclasses.\n- *\n- * Parameters:\n- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\n- *\n- * Returns:\n- * A new symbolizer.\n- */\n- initialize: function(config) {\n- OpenLayers.Util.extend(this, config);\n- },\n-\n- /** \n- * APIMethod: clone\n- * Create a copy of this symbolizer.\n- *\n- * Returns a symbolizer of the same type with the same properties.\n- */\n- clone: function() {\n- var Type = eval(this.CLASS_NAME);\n- return new Type(OpenLayers.Util.extend({}, this));\n+ this.events.destroy();\n+ this.events = null;\n+ this.servers = null;\n },\n \n- CLASS_NAME: \"OpenLayers.Symbolizer\"\n+ CLASS_NAME: 'OpenLayers.WPSClient'\n \n });\n-\n /* ======================================================================\n OpenLayers/Rule.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n@@ -32399,14 +32274,139 @@\n options.context = this.context && OpenLayers.Util.extend({}, this.context);\n return new OpenLayers.Rule(options);\n },\n \n CLASS_NAME: \"OpenLayers.Rule\"\n });\n /* ======================================================================\n+ OpenLayers/Strategy.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Strategy\n+ * Abstract vector layer strategy class. Not to be instantiated directly. Use\n+ * one of the strategy subclasses instead.\n+ */\n+OpenLayers.Strategy = OpenLayers.Class({\n+\n+ /**\n+ * Property: layer\n+ * {} The layer this strategy belongs to.\n+ */\n+ layer: null,\n+\n+ /**\n+ * Property: options\n+ * {Object} Any options sent to the constructor.\n+ */\n+ options: null,\n+\n+ /** \n+ * Property: active \n+ * {Boolean} The control is active.\n+ */\n+ active: null,\n+\n+ /**\n+ * Property: autoActivate\n+ * {Boolean} The creator of the strategy can set autoActivate to false\n+ * to fully control when the protocol is activated and deactivated.\n+ * Defaults to true.\n+ */\n+ autoActivate: true,\n+\n+ /**\n+ * Property: autoDestroy\n+ * {Boolean} The creator of the strategy can set autoDestroy to false\n+ * to fully control when the strategy is destroyed. Defaults to\n+ * true.\n+ */\n+ autoDestroy: true,\n+\n+ /**\n+ * Constructor: OpenLayers.Strategy\n+ * Abstract class for vector strategies. Create instances of a subclass.\n+ *\n+ * Parameters:\n+ * options - {Object} Optional object whose properties will be set on the\n+ * instance.\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.options = options;\n+ // set the active property here, so that user cannot override it\n+ this.active = false;\n+ },\n+\n+ /**\n+ * APIMethod: destroy\n+ * Clean up the strategy.\n+ */\n+ destroy: function() {\n+ this.deactivate();\n+ this.layer = null;\n+ this.options = null;\n+ },\n+\n+ /**\n+ * Method: setLayer\n+ * Called to set the property.\n+ *\n+ * Parameters:\n+ * layer - {}\n+ */\n+ setLayer: function(layer) {\n+ this.layer = layer;\n+ },\n+\n+ /**\n+ * Method: activate\n+ * Activate the strategy. Register any listeners, do appropriate setup.\n+ *\n+ * Returns:\n+ * {Boolean} True if the strategy was successfully activated or false if\n+ * the strategy was already active.\n+ */\n+ activate: function() {\n+ if (!this.active) {\n+ this.active = true;\n+ return true;\n+ }\n+ return false;\n+ },\n+\n+ /**\n+ * Method: deactivate\n+ * Deactivate the strategy. Unregister any listeners, do appropriate\n+ * tear-down.\n+ *\n+ * Returns:\n+ * {Boolean} True if the strategy was successfully deactivated or false if\n+ * the strategy was already inactive.\n+ */\n+ deactivate: function() {\n+ if (this.active) {\n+ this.active = false;\n+ return true;\n+ }\n+ return false;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Strategy\"\n+});\n+/* ======================================================================\n OpenLayers/Symbolizer/Point.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -33710,690 +33710,14 @@\n }\n return deactivated;\n },\n \n CLASS_NAME: \"OpenLayers.Handler.Click\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Drag.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Handler.js\n- */\n-\n-/**\n- * Class: OpenLayers.Handler.Drag\n- * The drag handler is used to deal with sequences of browser events related\n- * to dragging. The handler is used by controls that want to know when\n- * a drag sequence begins, when a drag is happening, and when it has\n- * finished.\n- *\n- * Controls that use the drag handler typically construct it with callbacks\n- * for 'down', 'move', and 'done'. Callbacks for these keys are called\n- * when the drag begins, with each move, and when the drag is done. In\n- * addition, controls can have callbacks keyed to 'up' and 'out' if they\n- * care to differentiate between the types of events that correspond with\n- * the end of a drag sequence. If no drag actually occurs (no mouse move)\n- * the 'down' and 'up' callbacks will be called, but not the 'done'\n- * callback.\n- *\n- * Create a new drag handler with the constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {\n-\n- /** \n- * Property: started\n- * {Boolean} When a mousedown or touchstart event is received, we want to\n- * record it, but not set 'dragging' until the mouse moves after starting.\n- */\n- started: false,\n-\n- /**\n- * Property: stopDown\n- * {Boolean} Stop propagation of mousedown events from getting to listeners\n- * on the same element. Default is true.\n- */\n- stopDown: true,\n-\n- /** \n- * Property: dragging \n- * {Boolean} \n- */\n- dragging: false,\n-\n- /** \n- * Property: last\n- * {} The last pixel location of the drag.\n- */\n- last: null,\n-\n- /** \n- * Property: start\n- * {} The first pixel location of the drag.\n- */\n- start: null,\n-\n- /**\n- * Property: lastMoveEvt\n- * {Object} The last mousemove event that occurred. Used to\n- * position the map correctly when our \"delay drag\"\n- * timeout expired.\n- */\n- lastMoveEvt: null,\n-\n- /**\n- * Property: oldOnselectstart\n- * {Function}\n- */\n- oldOnselectstart: null,\n-\n- /**\n- * Property: interval\n- * {Integer} In order to increase performance, an interval (in \n- * milliseconds) can be set to reduce the number of drag events \n- * called. If set, a new drag event will not be set until the \n- * interval has passed. \n- * Defaults to 0, meaning no interval. \n- */\n- interval: 0,\n-\n- /**\n- * Property: timeoutId\n- * {String} The id of the timeout used for the mousedown interval.\n- * This is \"private\", and should be left alone.\n- */\n- timeoutId: null,\n-\n- /**\n- * APIProperty: documentDrag\n- * {Boolean} If set to true, the handler will also handle mouse moves when\n- * the cursor has moved out of the map viewport. Default is false.\n- */\n- documentDrag: false,\n-\n- /**\n- * Property: documentEvents\n- * {Boolean} Are we currently observing document events?\n- */\n- documentEvents: null,\n-\n- /**\n- * Constructor: OpenLayers.Handler.Drag\n- * Returns OpenLayers.Handler.Drag\n- * \n- * Parameters:\n- * control - {} The control that is making use of\n- * this handler. If a handler is being used without a control, the\n- * handlers setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object containing a single function to be\n- * called when the drag operation is finished. The callback should\n- * expect to recieve a single argument, the pixel location of the event.\n- * Callbacks for 'move' and 'done' are supported. You can also speficy\n- * callbacks for 'down', 'up', and 'out' to respond to those events.\n- * options - {Object} \n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n-\n- if (this.documentDrag === true) {\n- var me = this;\n- this._docMove = function(evt) {\n- me.mousemove({\n- xy: {\n- x: evt.clientX,\n- y: evt.clientY\n- },\n- element: document\n- });\n- };\n- this._docUp = function(evt) {\n- me.mouseup({\n- xy: {\n- x: evt.clientX,\n- y: evt.clientY\n- }\n- });\n- };\n- }\n- },\n-\n-\n- /**\n- * Method: dragstart\n- * This private method is factorized from mousedown and touchstart methods\n- *\n- * Parameters:\n- * evt - {Event} The event\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- dragstart: function(evt) {\n- var propagate = true;\n- this.dragging = false;\n- if (this.checkModifiers(evt) &&\n- (OpenLayers.Event.isLeftClick(evt) ||\n- OpenLayers.Event.isSingleTouch(evt))) {\n- this.started = true;\n- this.start = evt.xy;\n- this.last = evt.xy;\n- OpenLayers.Element.addClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- this.down(evt);\n- this.callback(\"down\", [evt.xy]);\n-\n- // prevent document dragging\n- OpenLayers.Event.preventDefault(evt);\n-\n- if (!this.oldOnselectstart) {\n- this.oldOnselectstart = document.onselectstart ?\n- document.onselectstart : OpenLayers.Function.True;\n- }\n- document.onselectstart = OpenLayers.Function.False;\n-\n- propagate = !this.stopDown;\n- } else {\n- this.started = false;\n- this.start = null;\n- this.last = null;\n- }\n- return propagate;\n- },\n-\n- /**\n- * Method: dragmove\n- * This private method is factorized from mousemove and touchmove methods\n- *\n- * Parameters:\n- * evt - {Event} The event\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- dragmove: function(evt) {\n- this.lastMoveEvt = evt;\n- if (this.started && !this.timeoutId && (evt.xy.x != this.last.x ||\n- evt.xy.y != this.last.y)) {\n- if (this.documentDrag === true && this.documentEvents) {\n- if (evt.element === document) {\n- this.adjustXY(evt);\n- // do setEvent manually because the documentEvents are not\n- // registered with the map\n- this.setEvent(evt);\n- } else {\n- this.removeDocumentEvents();\n- }\n- }\n- if (this.interval > 0) {\n- this.timeoutId = setTimeout(\n- OpenLayers.Function.bind(this.removeTimeout, this),\n- this.interval);\n- }\n- this.dragging = true;\n-\n- this.move(evt);\n- this.callback(\"move\", [evt.xy]);\n- if (!this.oldOnselectstart) {\n- this.oldOnselectstart = document.onselectstart;\n- document.onselectstart = OpenLayers.Function.False;\n- }\n- this.last = evt.xy;\n- }\n- return true;\n- },\n-\n- /**\n- * Method: dragend\n- * This private method is factorized from mouseup and touchend methods\n- *\n- * Parameters:\n- * evt - {Event} The event\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- dragend: function(evt) {\n- if (this.started) {\n- if (this.documentDrag === true && this.documentEvents) {\n- this.adjustXY(evt);\n- this.removeDocumentEvents();\n- }\n- var dragged = (this.start != this.last);\n- this.started = false;\n- this.dragging = false;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- this.up(evt);\n- this.callback(\"up\", [evt.xy]);\n- if (dragged) {\n- this.callback(\"done\", [evt.xy]);\n- }\n- document.onselectstart = this.oldOnselectstart;\n- }\n- return true;\n- },\n-\n- /**\n- * The four methods below (down, move, up, and out) are used by subclasses\n- * to do their own processing related to these mouse events.\n- */\n-\n- /**\n- * Method: down\n- * This method is called during the handling of the mouse down event.\n- * Subclasses can do their own processing here.\n- *\n- * Parameters:\n- * evt - {Event} The mouse down event\n- */\n- down: function(evt) {},\n-\n- /**\n- * Method: move\n- * This method is called during the handling of the mouse move event.\n- * Subclasses can do their own processing here.\n- *\n- * Parameters:\n- * evt - {Event} The mouse move event\n- *\n- */\n- move: function(evt) {},\n-\n- /**\n- * Method: up\n- * This method is called during the handling of the mouse up event.\n- * Subclasses can do their own processing here.\n- *\n- * Parameters:\n- * evt - {Event} The mouse up event\n- */\n- up: function(evt) {},\n-\n- /**\n- * Method: out\n- * This method is called during the handling of the mouse out event.\n- * Subclasses can do their own processing here.\n- *\n- * Parameters:\n- * evt - {Event} The mouse out event\n- */\n- out: function(evt) {},\n-\n- /**\n- * The methods below are part of the magic of event handling. Because\n- * they are named like browser events, they are registered as listeners\n- * for the events they represent.\n- */\n-\n- /**\n- * Method: mousedown\n- * Handle mousedown events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- mousedown: function(evt) {\n- return this.dragstart(evt);\n- },\n-\n- /**\n- * Method: touchstart\n- * Handle touchstart events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- touchstart: function(evt) {\n- this.startTouch();\n- return this.dragstart(evt);\n- },\n-\n- /**\n- * Method: mousemove\n- * Handle mousemove events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- mousemove: function(evt) {\n- return this.dragmove(evt);\n- },\n-\n- /**\n- * Method: touchmove\n- * Handle touchmove events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- touchmove: function(evt) {\n- return this.dragmove(evt);\n- },\n-\n- /**\n- * Method: removeTimeout\n- * Private. Called by mousemove() to remove the drag timeout.\n- */\n- removeTimeout: function() {\n- this.timeoutId = null;\n- // if timeout expires while we're still dragging (mouseup\n- // hasn't occurred) then call mousemove to move to the\n- // correct position\n- if (this.dragging) {\n- this.mousemove(this.lastMoveEvt);\n- }\n- },\n-\n- /**\n- * Method: mouseup\n- * Handle mouseup events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- mouseup: function(evt) {\n- return this.dragend(evt);\n- },\n-\n- /**\n- * Method: touchend\n- * Handle touchend events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- touchend: function(evt) {\n- // override evt.xy with last position since touchend does not have\n- // any touch position\n- evt.xy = this.last;\n- return this.dragend(evt);\n- },\n-\n- /**\n- * Method: mouseout\n- * Handle mouseout events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- mouseout: function(evt) {\n- if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n- if (this.documentDrag === true) {\n- this.addDocumentEvents();\n- } else {\n- var dragged = (this.start != this.last);\n- this.started = false;\n- this.dragging = false;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- this.out(evt);\n- this.callback(\"out\", []);\n- if (dragged) {\n- this.callback(\"done\", [evt.xy]);\n- }\n- if (document.onselectstart) {\n- document.onselectstart = this.oldOnselectstart;\n- }\n- }\n- }\n- return true;\n- },\n-\n- /**\n- * Method: click\n- * The drag handler captures the click event. If something else registers\n- * for clicks on the same element, its listener will not be called \n- * after a drag.\n- * \n- * Parameters: \n- * evt - {Event} \n- * \n- * Returns:\n- * {Boolean} Let the event propagate.\n- */\n- click: function(evt) {\n- // let the click event propagate only if the mouse moved\n- return (this.start == this.last);\n- },\n-\n- /**\n- * Method: activate\n- * Activate the handler.\n- * \n- * Returns:\n- * {Boolean} The handler was successfully activated.\n- */\n- activate: function() {\n- var activated = false;\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.dragging = false;\n- activated = true;\n- }\n- return activated;\n- },\n-\n- /**\n- * Method: deactivate \n- * Deactivate the handler.\n- * \n- * Returns:\n- * {Boolean} The handler was successfully deactivated.\n- */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.started = false;\n- this.dragging = false;\n- this.start = null;\n- this.last = null;\n- deactivated = true;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDragDown\"\n- );\n- }\n- return deactivated;\n- },\n-\n- /**\n- * Method: adjustXY\n- * Converts event coordinates that are relative to the document body to\n- * ones that are relative to the map viewport. The latter is the default in\n- * OpenLayers.\n- * \n- * Parameters:\n- * evt - {Object}\n- */\n- adjustXY: function(evt) {\n- var pos = OpenLayers.Util.pagePosition(this.map.viewPortDiv);\n- evt.xy.x -= pos[0];\n- evt.xy.y -= pos[1];\n- },\n-\n- /**\n- * Method: addDocumentEvents\n- * Start observing document events when documentDrag is true and the mouse\n- * cursor leaves the map viewport while dragging.\n- */\n- addDocumentEvents: function() {\n- OpenLayers.Element.addClass(document.body, \"olDragDown\");\n- this.documentEvents = true;\n- OpenLayers.Event.observe(document, \"mousemove\", this._docMove);\n- OpenLayers.Event.observe(document, \"mouseup\", this._docUp);\n- },\n-\n- /**\n- * Method: removeDocumentEvents\n- * Stops observing document events when documentDrag is true and the mouse\n- * cursor re-enters the map viewport while dragging.\n- */\n- removeDocumentEvents: function() {\n- OpenLayers.Element.removeClass(document.body, \"olDragDown\");\n- this.documentEvents = false;\n- OpenLayers.Event.stopObserving(document, \"mousemove\", this._docMove);\n- OpenLayers.Event.stopObserving(document, \"mouseup\", this._docUp);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler.Drag\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler/Keyboard.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/Handler.js\n- * @requires OpenLayers/Events.js\n- */\n-\n-/**\n- * Class: OpenLayers.handler.Keyboard\n- * A handler for keyboard events. Create a new instance with the\n- * constructor.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {\n-\n- /* http://www.quirksmode.org/js/keys.html explains key x-browser\n- key handling quirks in pretty nice detail */\n-\n- /** \n- * Constant: KEY_EVENTS\n- * keydown, keypress, keyup\n- */\n- KEY_EVENTS: [\"keydown\", \"keyup\"],\n-\n- /** \n- * Property: eventListener\n- * {Function}\n- */\n- eventListener: null,\n-\n- /**\n- * Property: observeElement\n- * {DOMElement|String} The DOM element on which we listen for\n- * key events. Default to the document.\n- */\n- observeElement: null,\n-\n- /**\n- * Constructor: OpenLayers.Handler.Keyboard\n- * Returns a new keyboard handler.\n- * \n- * Parameters:\n- * control - {} The control that is making use of\n- * this handler. If a handler is being used without a control, the\n- * handlers setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object containing a single function to be\n- * called when the drag operation is finished. The callback should\n- * expect to recieve a single argument, the pixel location of the event.\n- * Callbacks for 'keydown', 'keypress', and 'keyup' are supported.\n- * options - {Object} Optional object whose properties will be set on the\n- * handler.\n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n- // cache the bound event listener method so it can be unobserved later\n- this.eventListener = OpenLayers.Function.bindAsEventListener(\n- this.handleKeyEvent, this\n- );\n- },\n-\n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- this.deactivate();\n- this.eventListener = null;\n- OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * Method: activate\n- */\n- activate: function() {\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.observeElement = this.observeElement || document;\n- for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n- OpenLayers.Event.observe(\n- this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n- }\n- return true;\n- } else {\n- return false;\n- }\n- },\n-\n- /**\n- * Method: deactivate\n- */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n- OpenLayers.Event.stopObserving(\n- this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n- }\n- deactivated = true;\n- }\n- return deactivated;\n- },\n-\n- /**\n- * Method: handleKeyEvent \n- */\n- handleKeyEvent: function(evt) {\n- if (this.checkModifiers(evt)) {\n- this.callback(evt.type, [evt]);\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler.Keyboard\"\n-});\n-/* ======================================================================\n OpenLayers/Handler/Point.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -35498,14 +34822,333 @@\n }\n return false;\n },\n \n CLASS_NAME: \"OpenLayers.Handler.Path\"\n });\n /* ======================================================================\n+ OpenLayers/Handler/Polygon.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+\n+/**\n+ * @requires OpenLayers/Handler/Path.js\n+ * @requires OpenLayers/Geometry/Polygon.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Handler.Polygon\n+ * Handler to draw a polygon on the map. Polygon is displayed on mouse down,\n+ * moves on mouse move, and is finished on mouse up.\n+ *\n+ * Inherits from:\n+ * - \n+ * - \n+ */\n+OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {\n+\n+ /** \n+ * APIProperty: holeModifier\n+ * {String} Key modifier to trigger hole digitizing. Acceptable values are\n+ * \"altKey\", \"shiftKey\", or \"ctrlKey\". If not set, no hole digitizing\n+ * will take place. Default is null.\n+ */\n+ holeModifier: null,\n+\n+ /**\n+ * Property: drawingHole\n+ * {Boolean} Currently drawing an interior ring.\n+ */\n+ drawingHole: false,\n+\n+ /**\n+ * Property: polygon\n+ * {}\n+ */\n+ polygon: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Handler.Polygon\n+ * Create a Polygon Handler.\n+ *\n+ * Parameters:\n+ * control - {} The control that owns this handler\n+ * callbacks - {Object} An object with a properties whose values are\n+ * functions. Various callbacks described below.\n+ * options - {Object} An optional object with properties to be set on the\n+ * handler\n+ *\n+ * Named callbacks:\n+ * create - Called when a sketch is first created. Callback called with\n+ * the creation point geometry and sketch feature.\n+ * modify - Called with each move of a vertex with the vertex (point)\n+ * geometry and the sketch feature.\n+ * point - Called as each point is added. Receives the new point geometry.\n+ * done - Called when the point drawing is finished. The callback will\n+ * recieve a single argument, the polygon geometry.\n+ * cancel - Called when the handler is deactivated while drawing. The\n+ * cancel callback will receive a geometry.\n+ */\n+\n+ /**\n+ * Method: createFeature\n+ * Add temporary geometries\n+ *\n+ * Parameters:\n+ * pixel - {} The initial pixel location for the new\n+ * feature.\n+ */\n+ createFeature: function(pixel) {\n+ var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n+ var geometry = new OpenLayers.Geometry.Point(\n+ lonlat.lon, lonlat.lat\n+ );\n+ this.point = new OpenLayers.Feature.Vector(geometry);\n+ this.line = new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.LinearRing([this.point.geometry])\n+ );\n+ this.polygon = new OpenLayers.Feature.Vector(\n+ new OpenLayers.Geometry.Polygon([this.line.geometry])\n+ );\n+ this.callback(\"create\", [this.point.geometry, this.getSketch()]);\n+ this.point.geometry.clearBounds();\n+ this.layer.addFeatures([this.polygon, this.point], {\n+ silent: true\n+ });\n+ },\n+\n+ /**\n+ * Method: addPoint\n+ * Add point to geometry.\n+ *\n+ * Parameters:\n+ * pixel - {} The pixel location for the new point.\n+ */\n+ addPoint: function(pixel) {\n+ if (!this.drawingHole && this.holeModifier &&\n+ this.evt && this.evt[this.holeModifier]) {\n+ var geometry = this.point.geometry;\n+ var features = this.control.layer.features;\n+ var candidate, polygon;\n+ // look for intersections, last drawn gets priority\n+ for (var i = features.length - 1; i >= 0; --i) {\n+ candidate = features[i].geometry;\n+ if ((candidate instanceof OpenLayers.Geometry.Polygon ||\n+ candidate instanceof OpenLayers.Geometry.MultiPolygon) &&\n+ candidate.intersects(geometry)) {\n+ polygon = features[i];\n+ this.control.layer.removeFeatures([polygon], {\n+ silent: true\n+ });\n+ this.control.layer.events.registerPriority(\n+ \"sketchcomplete\", this, this.finalizeInteriorRing\n+ );\n+ this.control.layer.events.registerPriority(\n+ \"sketchmodified\", this, this.enforceTopology\n+ );\n+ polygon.geometry.addComponent(this.line.geometry);\n+ this.polygon = polygon;\n+ this.drawingHole = true;\n+ break;\n+ }\n+ }\n+ }\n+ OpenLayers.Handler.Path.prototype.addPoint.apply(this, arguments);\n+ },\n+\n+ /**\n+ * Method: getCurrentPointIndex\n+ * \n+ * Returns:\n+ * {Number} The index of the most recently drawn point.\n+ */\n+ getCurrentPointIndex: function() {\n+ return this.line.geometry.components.length - 2;\n+ },\n+\n+ /**\n+ * Method: enforceTopology\n+ * Simple topology enforcement for drawing interior rings. Ensures vertices\n+ * of interior rings are contained by exterior ring. Other topology \n+ * rules are enforced in to allow drawing of \n+ * rings that intersect only during the sketch (e.g. a \"C\" shaped ring\n+ * that nearly encloses another ring).\n+ */\n+ enforceTopology: function(event) {\n+ var point = event.vertex;\n+ var components = this.line.geometry.components;\n+ // ensure that vertices of interior ring are contained by exterior ring\n+ if (!this.polygon.geometry.intersects(point)) {\n+ var last = components[components.length - 3];\n+ point.x = last.x;\n+ point.y = last.y;\n+ }\n+ },\n+\n+ /**\n+ * Method: finishGeometry\n+ * Finish the geometry and send it back to the control.\n+ */\n+ finishGeometry: function() {\n+ var index = this.line.geometry.components.length - 2;\n+ this.line.geometry.removeComponent(this.line.geometry.components[index]);\n+ this.removePoint();\n+ this.finalize();\n+ },\n+\n+ /**\n+ * Method: finalizeInteriorRing\n+ * Enforces that new ring has some area and doesn't contain vertices of any\n+ * other rings.\n+ */\n+ finalizeInteriorRing: function() {\n+ var ring = this.line.geometry;\n+ // ensure that ring has some area\n+ var modified = (ring.getArea() !== 0);\n+ if (modified) {\n+ // ensure that new ring doesn't intersect any other rings\n+ var rings = this.polygon.geometry.components;\n+ for (var i = rings.length - 2; i >= 0; --i) {\n+ if (ring.intersects(rings[i])) {\n+ modified = false;\n+ break;\n+ }\n+ }\n+ if (modified) {\n+ // ensure that new ring doesn't contain any other rings\n+ var target;\n+ outer: for (var i = rings.length - 2; i > 0; --i) {\n+ var points = rings[i].components;\n+ for (var j = 0, jj = points.length; j < jj; ++j) {\n+ if (ring.containsPoint(points[j])) {\n+ modified = false;\n+ break outer;\n+ }\n+ }\n+ }\n+ }\n+ }\n+ if (modified) {\n+ if (this.polygon.state !== OpenLayers.State.INSERT) {\n+ this.polygon.state = OpenLayers.State.UPDATE;\n+ }\n+ } else {\n+ this.polygon.geometry.removeComponent(ring);\n+ }\n+ this.restoreFeature();\n+ return false;\n+ },\n+\n+ /**\n+ * APIMethod: cancel\n+ * Finish the geometry and call the \"cancel\" callback.\n+ */\n+ cancel: function() {\n+ if (this.drawingHole) {\n+ this.polygon.geometry.removeComponent(this.line.geometry);\n+ this.restoreFeature(true);\n+ }\n+ return OpenLayers.Handler.Path.prototype.cancel.apply(this, arguments);\n+ },\n+\n+ /**\n+ * Method: restoreFeature\n+ * Move the feature from the sketch layer to the target layer.\n+ *\n+ * Properties: \n+ * cancel - {Boolean} Cancel drawing. If falsey, the \"sketchcomplete\" event\n+ * will be fired.\n+ */\n+ restoreFeature: function(cancel) {\n+ this.control.layer.events.unregister(\n+ \"sketchcomplete\", this, this.finalizeInteriorRing\n+ );\n+ this.control.layer.events.unregister(\n+ \"sketchmodified\", this, this.enforceTopology\n+ );\n+ this.layer.removeFeatures([this.polygon], {\n+ silent: true\n+ });\n+ this.control.layer.addFeatures([this.polygon], {\n+ silent: true\n+ });\n+ this.drawingHole = false;\n+ if (!cancel) {\n+ // Re-trigger \"sketchcomplete\" so other listeners can do their\n+ // business. While this is somewhat sloppy (if a listener is \n+ // registered with registerPriority - not common - between the start\n+ // and end of a single ring drawing - very uncommon - it will be \n+ // called twice).\n+ // TODO: In 3.0, collapse sketch handlers into geometry specific\n+ // drawing controls.\n+ this.control.layer.events.triggerEvent(\n+ \"sketchcomplete\", {\n+ feature: this.polygon\n+ }\n+ );\n+ }\n+ },\n+\n+ /**\n+ * Method: destroyFeature\n+ * Destroy temporary geometries\n+ *\n+ * Parameters:\n+ * force - {Boolean} Destroy even if persist is true.\n+ */\n+ destroyFeature: function(force) {\n+ OpenLayers.Handler.Path.prototype.destroyFeature.call(\n+ this, force);\n+ this.polygon = null;\n+ },\n+\n+ /**\n+ * Method: drawFeature\n+ * Render geometries on the temporary layer.\n+ */\n+ drawFeature: function() {\n+ this.layer.drawFeature(this.polygon, this.style);\n+ this.layer.drawFeature(this.point, this.style);\n+ },\n+\n+ /**\n+ * Method: getSketch\n+ * Return the sketch feature.\n+ *\n+ * Returns:\n+ * {}\n+ */\n+ getSketch: function() {\n+ return this.polygon;\n+ },\n+\n+ /**\n+ * Method: getGeometry\n+ * Return the sketch geometry. If is true, this will return\n+ * a multi-part geometry.\n+ *\n+ * Returns:\n+ * {}\n+ */\n+ getGeometry: function() {\n+ var geometry = this.polygon && this.polygon.geometry;\n+ if (geometry && this.multi) {\n+ geometry = new OpenLayers.Geometry.MultiPolygon([geometry]);\n+ }\n+ return geometry;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Polygon\"\n+});\n+/* ======================================================================\n OpenLayers/Handler/MouseWheel.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n@@ -35766,787 +35409,1000 @@\n return false;\n }\n },\n \n CLASS_NAME: \"OpenLayers.Handler.MouseWheel\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Feature.js\n+ OpenLayers/Handler/Hover.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Feature \n- * Handler to respond to mouse events related to a drawn feature. Callbacks\n- * with the following keys will be notified of the following events\n- * associated with features: click, clickout, over, out, and dblclick.\n- *\n- * This handler stops event propagation for mousedown and mouseup if those\n- * browser events target features that can be selected.\n- *\n+ * Class: OpenLayers.Handler.Hover\n+ * The hover handler is to be used to emulate mouseovers on objects\n+ * on the map that aren't DOM elements. For example one can use\n+ * this handler to send WMS/GetFeatureInfo requests as the user\n+ * moves the mouve over the map.\n+ * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.Handler.Hover = OpenLayers.Class(OpenLayers.Handler, {\n \n /**\n- * Property: EVENTMAP\n- * {Object} A object mapping the browser events to objects with callback\n- * keys for in and out.\n+ * APIProperty: delay\n+ * {Integer} - Number of milliseconds between mousemoves before\n+ * the event is considered a hover. Default is 500.\n */\n- EVENTMAP: {\n- 'click': {\n- 'in': 'click',\n- 'out': 'clickout'\n- },\n- 'mousemove': {\n- 'in': 'over',\n- 'out': 'out'\n- },\n- 'dblclick': {\n- 'in': 'dblclick',\n- 'out': null\n- },\n- 'mousedown': {\n- 'in': null,\n- 'out': null\n- },\n- 'mouseup': {\n- 'in': null,\n- 'out': null\n- },\n- 'touchstart': {\n- 'in': 'click',\n- 'out': 'clickout'\n- }\n- },\n+ delay: 500,\n \n /**\n- * Property: feature\n- * {} The last feature that was hovered.\n+ * APIProperty: pixelTolerance\n+ * {Integer} - Maximum number of pixels between mousemoves for\n+ * an event to be considered a hover. Default is null.\n */\n- feature: null,\n+ pixelTolerance: null,\n \n /**\n- * Property: lastFeature\n- * {} The last feature that was handled.\n+ * APIProperty: stopMove\n+ * {Boolean} - Stop other listeners from being notified on mousemoves.\n+ * Default is false.\n */\n- lastFeature: null,\n+ stopMove: false,\n \n /**\n- * Property: down\n- * {} The location of the last mousedown.\n+ * Property: px\n+ * {} - The location of the last mousemove, expressed\n+ * in pixels.\n */\n- down: null,\n+ px: null,\n \n /**\n- * Property: up\n- * {} The location of the last mouseup.\n+ * Property: timerId\n+ * {Number} - The id of the timer.\n */\n- up: null,\n+ timerId: null,\n \n /**\n- * Property: clickTolerance\n- * {Number} The number of pixels the mouse can move between mousedown\n- * and mouseup for the event to still be considered a click.\n- * Dragging the map should not trigger the click and clickout callbacks\n- * unless the map is moved by less than this tolerance. Defaults to 4.\n+ * Constructor: OpenLayers.Handler.Hover\n+ * Construct a hover handler.\n+ *\n+ * Parameters:\n+ * control - {} The control that initialized this\n+ * handler. The control is assumed to have a valid map property; that\n+ * map is used in the handler's own setMap method.\n+ * callbacks - {Object} An object with keys corresponding to callbacks\n+ * that will be called by the handler. The callbacks should\n+ * expect to receive a single argument, the event. Callbacks for\n+ * 'move', the mouse is moving, and 'pause', the mouse is pausing,\n+ * are supported.\n+ * options - {Object} An optional object whose properties will be set on\n+ * the handler.\n */\n- clickTolerance: 4,\n \n /**\n- * Property: geometryTypes\n- * To restrict dragging to a limited set of geometry types, send a list\n- * of strings corresponding to the geometry class names.\n- * \n- * @type Array(String)\n+ * Method: mousemove\n+ * Called when the mouse moves on the map.\n+ *\n+ * Parameters:\n+ * evt - {}\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n */\n- geometryTypes: null,\n+ mousemove: function(evt) {\n+ if (this.passesTolerance(evt.xy)) {\n+ this.clearTimer();\n+ this.callback('move', [evt]);\n+ this.px = evt.xy;\n+ // clone the evt so original properties can be accessed even\n+ // if the browser deletes them during the delay\n+ evt = OpenLayers.Util.extend({}, evt);\n+ this.timerId = window.setTimeout(\n+ OpenLayers.Function.bind(this.delayedCall, this, evt),\n+ this.delay\n+ );\n+ }\n+ return !this.stopMove;\n+ },\n \n /**\n- * Property: stopClick\n- * {Boolean} If stopClick is set to true, handled clicks do not\n- * propagate to other click listeners. Otherwise, handled clicks\n- * do propagate. Unhandled clicks always propagate, whatever the\n- * value of stopClick. Defaults to true.\n+ * Method: mouseout\n+ * Called when the mouse goes out of the map.\n+ *\n+ * Parameters:\n+ * evt - {}\n+ *\n+ * Returns:\n+ * {Boolean} Continue propagating this event.\n */\n- stopClick: true,\n+ mouseout: function(evt) {\n+ if (OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n+ this.clearTimer();\n+ this.callback('move', [evt]);\n+ }\n+ return true;\n+ },\n+\n+ /**\n+ * Method: passesTolerance\n+ * Determine whether the mouse move is within the optional pixel tolerance.\n+ *\n+ * Parameters:\n+ * px - {}\n+ *\n+ * Returns:\n+ * {Boolean} The mouse move is within the pixel tolerance.\n+ */\n+ passesTolerance: function(px) {\n+ var passes = true;\n+ if (this.pixelTolerance && this.px) {\n+ var dpx = Math.sqrt(\n+ Math.pow(this.px.x - px.x, 2) +\n+ Math.pow(this.px.y - px.y, 2)\n+ );\n+ if (dpx < this.pixelTolerance) {\n+ passes = false;\n+ }\n+ }\n+ return passes;\n+ },\n+\n+ /**\n+ * Method: clearTimer\n+ * Clear the timer and set to null.\n+ */\n+ clearTimer: function() {\n+ if (this.timerId != null) {\n+ window.clearTimeout(this.timerId);\n+ this.timerId = null;\n+ }\n+ },\n+\n+ /**\n+ * Method: delayedCall\n+ * Triggers pause callback.\n+ *\n+ * Parameters:\n+ * evt - {}\n+ */\n+ delayedCall: function(evt) {\n+ this.callback('pause', [evt]);\n+ },\n+\n+ /**\n+ * APIMethod: deactivate\n+ * Deactivate the handler.\n+ *\n+ * Returns:\n+ * {Boolean} The handler was successfully deactivated.\n+ */\n+ deactivate: function() {\n+ var deactivated = false;\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ this.clearTimer();\n+ deactivated = true;\n+ }\n+ return deactivated;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Hover\"\n+});\n+/* ======================================================================\n+ OpenLayers/Handler/Drag.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Handler.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Handler.Drag\n+ * The drag handler is used to deal with sequences of browser events related\n+ * to dragging. The handler is used by controls that want to know when\n+ * a drag sequence begins, when a drag is happening, and when it has\n+ * finished.\n+ *\n+ * Controls that use the drag handler typically construct it with callbacks\n+ * for 'down', 'move', and 'done'. Callbacks for these keys are called\n+ * when the drag begins, with each move, and when the drag is done. In\n+ * addition, controls can have callbacks keyed to 'up' and 'out' if they\n+ * care to differentiate between the types of events that correspond with\n+ * the end of a drag sequence. If no drag actually occurs (no mouse move)\n+ * the 'down' and 'up' callbacks will be called, but not the 'done'\n+ * callback.\n+ *\n+ * Create a new drag handler with the constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {\n+\n+ /** \n+ * Property: started\n+ * {Boolean} When a mousedown or touchstart event is received, we want to\n+ * record it, but not set 'dragging' until the mouse moves after starting.\n+ */\n+ started: false,\n \n /**\n * Property: stopDown\n- * {Boolean} If stopDown is set to true, handled mousedowns do not\n- * propagate to other mousedown listeners. Otherwise, handled\n- * mousedowns do propagate. Unhandled mousedowns always propagate,\n- * whatever the value of stopDown. Defaults to true.\n+ * {Boolean} Stop propagation of mousedown events from getting to listeners\n+ * on the same element. Default is true.\n */\n stopDown: true,\n \n+ /** \n+ * Property: dragging \n+ * {Boolean} \n+ */\n+ dragging: false,\n+\n+ /** \n+ * Property: last\n+ * {} The last pixel location of the drag.\n+ */\n+ last: null,\n+\n+ /** \n+ * Property: start\n+ * {} The first pixel location of the drag.\n+ */\n+ start: null,\n+\n /**\n- * Property: stopUp\n- * {Boolean} If stopUp is set to true, handled mouseups do not\n- * propagate to other mouseup listeners. Otherwise, handled mouseups\n- * do propagate. Unhandled mouseups always propagate, whatever the\n- * value of stopUp. Defaults to false.\n+ * Property: lastMoveEvt\n+ * {Object} The last mousemove event that occurred. Used to\n+ * position the map correctly when our \"delay drag\"\n+ * timeout expired.\n */\n- stopUp: false,\n+ lastMoveEvt: null,\n \n /**\n- * Constructor: OpenLayers.Handler.Feature\n- *\n+ * Property: oldOnselectstart\n+ * {Function}\n+ */\n+ oldOnselectstart: null,\n+\n+ /**\n+ * Property: interval\n+ * {Integer} In order to increase performance, an interval (in \n+ * milliseconds) can be set to reduce the number of drag events \n+ * called. If set, a new drag event will not be set until the \n+ * interval has passed. \n+ * Defaults to 0, meaning no interval. \n+ */\n+ interval: 0,\n+\n+ /**\n+ * Property: timeoutId\n+ * {String} The id of the timeout used for the mousedown interval.\n+ * This is \"private\", and should be left alone.\n+ */\n+ timeoutId: null,\n+\n+ /**\n+ * APIProperty: documentDrag\n+ * {Boolean} If set to true, the handler will also handle mouse moves when\n+ * the cursor has moved out of the map viewport. Default is false.\n+ */\n+ documentDrag: false,\n+\n+ /**\n+ * Property: documentEvents\n+ * {Boolean} Are we currently observing document events?\n+ */\n+ documentEvents: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Handler.Drag\n+ * Returns OpenLayers.Handler.Drag\n+ * \n * Parameters:\n- * control - {} \n- * layer - {}\n- * callbacks - {Object} An object with a 'over' property whos value is\n- * a function to be called when the mouse is over a feature. The \n- * callback should expect to recieve a single argument, the feature.\n+ * control - {} The control that is making use of\n+ * this handler. If a handler is being used without a control, the\n+ * handlers setMap method must be overridden to deal properly with\n+ * the map.\n+ * callbacks - {Object} An object containing a single function to be\n+ * called when the drag operation is finished. The callback should\n+ * expect to recieve a single argument, the pixel location of the event.\n+ * Callbacks for 'move' and 'done' are supported. You can also speficy\n+ * callbacks for 'down', 'up', and 'out' to respond to those events.\n * options - {Object} \n */\n- initialize: function(control, layer, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);\n- this.layer = layer;\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+\n+ if (this.documentDrag === true) {\n+ var me = this;\n+ this._docMove = function(evt) {\n+ me.mousemove({\n+ xy: {\n+ x: evt.clientX,\n+ y: evt.clientY\n+ },\n+ element: document\n+ });\n+ };\n+ this._docUp = function(evt) {\n+ me.mouseup({\n+ xy: {\n+ x: evt.clientX,\n+ y: evt.clientY\n+ }\n+ });\n+ };\n+ }\n },\n \n+\n /**\n- * Method: touchstart\n- * Handle touchstart events\n+ * Method: dragstart\n+ * This private method is factorized from mousedown and touchstart methods\n *\n * Parameters:\n- * evt - {Event}\n+ * evt - {Event} The event\n *\n * Returns:\n * {Boolean} Let the event propagate.\n */\n- touchstart: function(evt) {\n- this.startTouch();\n- return OpenLayers.Event.isMultiTouch(evt) ?\n- true : this.mousedown(evt);\n+ dragstart: function(evt) {\n+ var propagate = true;\n+ this.dragging = false;\n+ if (this.checkModifiers(evt) &&\n+ (OpenLayers.Event.isLeftClick(evt) ||\n+ OpenLayers.Event.isSingleTouch(evt))) {\n+ this.started = true;\n+ this.start = evt.xy;\n+ this.last = evt.xy;\n+ OpenLayers.Element.addClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n+ this.down(evt);\n+ this.callback(\"down\", [evt.xy]);\n+\n+ // prevent document dragging\n+ OpenLayers.Event.preventDefault(evt);\n+\n+ if (!this.oldOnselectstart) {\n+ this.oldOnselectstart = document.onselectstart ?\n+ document.onselectstart : OpenLayers.Function.True;\n+ }\n+ document.onselectstart = OpenLayers.Function.False;\n+\n+ propagate = !this.stopDown;\n+ } else {\n+ this.started = false;\n+ this.start = null;\n+ this.last = null;\n+ }\n+ return propagate;\n },\n \n /**\n- * Method: touchmove\n- * Handle touchmove events. We just prevent the browser default behavior,\n- * for Android Webkit not to select text when moving the finger after\n- * selecting a feature.\n+ * Method: dragmove\n+ * This private method is factorized from mousemove and touchmove methods\n *\n * Parameters:\n- * evt - {Event}\n+ * evt - {Event} The event\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- touchmove: function(evt) {\n- OpenLayers.Event.preventDefault(evt);\n+ dragmove: function(evt) {\n+ this.lastMoveEvt = evt;\n+ if (this.started && !this.timeoutId && (evt.xy.x != this.last.x ||\n+ evt.xy.y != this.last.y)) {\n+ if (this.documentDrag === true && this.documentEvents) {\n+ if (evt.element === document) {\n+ this.adjustXY(evt);\n+ // do setEvent manually because the documentEvents are not\n+ // registered with the map\n+ this.setEvent(evt);\n+ } else {\n+ this.removeDocumentEvents();\n+ }\n+ }\n+ if (this.interval > 0) {\n+ this.timeoutId = setTimeout(\n+ OpenLayers.Function.bind(this.removeTimeout, this),\n+ this.interval);\n+ }\n+ this.dragging = true;\n+\n+ this.move(evt);\n+ this.callback(\"move\", [evt.xy]);\n+ if (!this.oldOnselectstart) {\n+ this.oldOnselectstart = document.onselectstart;\n+ document.onselectstart = OpenLayers.Function.False;\n+ }\n+ this.last = evt.xy;\n+ }\n+ return true;\n },\n \n /**\n- * Method: mousedown\n- * Handle mouse down. Stop propagation if a feature is targeted by this\n- * event (stops map dragging during feature selection).\n- * \n+ * Method: dragend\n+ * This private method is factorized from mouseup and touchend methods\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Event} The event\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- mousedown: function(evt) {\n- // Feature selection is only done with a left click. Other handlers may stop the\n- // propagation of left-click mousedown events but not right-click mousedown events.\n- // This mismatch causes problems when comparing the location of the down and up\n- // events in the click function so it is important ignore right-clicks.\n- if (OpenLayers.Event.isLeftClick(evt) || OpenLayers.Event.isSingleTouch(evt)) {\n- this.down = evt.xy;\n+ dragend: function(evt) {\n+ if (this.started) {\n+ if (this.documentDrag === true && this.documentEvents) {\n+ this.adjustXY(evt);\n+ this.removeDocumentEvents();\n+ }\n+ var dragged = (this.start != this.last);\n+ this.started = false;\n+ this.dragging = false;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n+ this.up(evt);\n+ this.callback(\"up\", [evt.xy]);\n+ if (dragged) {\n+ this.callback(\"done\", [evt.xy]);\n+ }\n+ document.onselectstart = this.oldOnselectstart;\n }\n- return this.handle(evt) ? !this.stopDown : true;\n+ return true;\n },\n \n /**\n- * Method: mouseup\n- * Handle mouse up. Stop propagation if a feature is targeted by this\n- * event.\n- * \n+ * The four methods below (down, move, up, and out) are used by subclasses\n+ * to do their own processing related to these mouse events.\n+ */\n+\n+ /**\n+ * Method: down\n+ * This method is called during the handling of the mouse down event.\n+ * Subclasses can do their own processing here.\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Event} The mouse down event\n */\n- mouseup: function(evt) {\n- this.up = evt.xy;\n- return this.handle(evt) ? !this.stopUp : true;\n+ down: function(evt) {},\n+\n+ /**\n+ * Method: move\n+ * This method is called during the handling of the mouse move event.\n+ * Subclasses can do their own processing here.\n+ *\n+ * Parameters:\n+ * evt - {Event} The mouse move event\n+ *\n+ */\n+ move: function(evt) {},\n+\n+ /**\n+ * Method: up\n+ * This method is called during the handling of the mouse up event.\n+ * Subclasses can do their own processing here.\n+ *\n+ * Parameters:\n+ * evt - {Event} The mouse up event\n+ */\n+ up: function(evt) {},\n+\n+ /**\n+ * Method: out\n+ * This method is called during the handling of the mouse out event.\n+ * Subclasses can do their own processing here.\n+ *\n+ * Parameters:\n+ * evt - {Event} The mouse out event\n+ */\n+ out: function(evt) {},\n+\n+ /**\n+ * The methods below are part of the magic of event handling. Because\n+ * they are named like browser events, they are registered as listeners\n+ * for the events they represent.\n+ */\n+\n+ /**\n+ * Method: mousedown\n+ * Handle mousedown events\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n+ */\n+ mousedown: function(evt) {\n+ return this.dragstart(evt);\n },\n \n /**\n- * Method: click\n- * Handle click. Call the \"click\" callback if click on a feature,\n- * or the \"clickout\" callback if click outside any feature.\n- * \n+ * Method: touchstart\n+ * Handle touchstart events\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Event}\n *\n * Returns:\n- * {Boolean}\n+ * {Boolean} Let the event propagate.\n */\n- click: function(evt) {\n- return this.handle(evt) ? !this.stopClick : true;\n+ touchstart: function(evt) {\n+ this.startTouch();\n+ return this.dragstart(evt);\n },\n \n /**\n * Method: mousemove\n- * Handle mouse moves. Call the \"over\" callback if moving in to a feature,\n- * or the \"out\" callback if moving out of a feature.\n- * \n+ * Handle mousemove events\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Event}\n *\n * Returns:\n- * {Boolean}\n+ * {Boolean} Let the event propagate.\n */\n mousemove: function(evt) {\n- if (!this.callbacks['over'] && !this.callbacks['out']) {\n- return true;\n- }\n- this.handle(evt);\n- return true;\n+ return this.dragmove(evt);\n },\n \n /**\n- * Method: dblclick\n- * Handle dblclick. Call the \"dblclick\" callback if dblclick on a feature.\n+ * Method: touchmove\n+ * Handle touchmove events\n *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Event}\n *\n * Returns:\n- * {Boolean}\n+ * {Boolean} Let the event propagate.\n */\n- dblclick: function(evt) {\n- return !this.handle(evt);\n+ touchmove: function(evt) {\n+ return this.dragmove(evt);\n },\n \n /**\n- * Method: geometryTypeMatches\n- * Return true if the geometry type of the passed feature matches\n- * one of the geometry types in the geometryTypes array.\n+ * Method: removeTimeout\n+ * Private. Called by mousemove() to remove the drag timeout.\n+ */\n+ removeTimeout: function() {\n+ this.timeoutId = null;\n+ // if timeout expires while we're still dragging (mouseup\n+ // hasn't occurred) then call mousemove to move to the\n+ // correct position\n+ if (this.dragging) {\n+ this.mousemove(this.lastMoveEvt);\n+ }\n+ },\n+\n+ /**\n+ * Method: mouseup\n+ * Handle mouseup events\n *\n * Parameters:\n- * feature - {}\n+ * evt - {Event}\n *\n * Returns:\n- * {Boolean}\n+ * {Boolean} Let the event propagate.\n */\n- geometryTypeMatches: function(feature) {\n- return this.geometryTypes == null ||\n- OpenLayers.Util.indexOf(this.geometryTypes,\n- feature.geometry.CLASS_NAME) > -1;\n+ mouseup: function(evt) {\n+ return this.dragend(evt);\n },\n \n /**\n- * Method: handle\n+ * Method: touchend\n+ * Handle touchend events\n *\n * Parameters:\n * evt - {Event}\n *\n * Returns:\n- * {Boolean} The event occurred over a relevant feature.\n+ * {Boolean} Let the event propagate.\n */\n- handle: function(evt) {\n- if (this.feature && !this.feature.layer) {\n- // feature has been destroyed\n- this.feature = null;\n- }\n- var type = evt.type;\n- var handled = false;\n- var previouslyIn = !!(this.feature); // previously in a feature\n- var click = (type == \"click\" || type == \"dblclick\" || type == \"touchstart\");\n- this.feature = this.layer.getFeatureFromEvent(evt);\n- if (this.feature && !this.feature.layer) {\n- // feature has been destroyed\n- this.feature = null;\n- }\n- if (this.lastFeature && !this.lastFeature.layer) {\n- // last feature has been destroyed\n- this.lastFeature = null;\n- }\n- if (this.feature) {\n- if (type === \"touchstart\") {\n- // stop the event to prevent Android Webkit from\n- // \"flashing\" the map div\n- OpenLayers.Event.preventDefault(evt);\n- }\n- var inNew = (this.feature != this.lastFeature);\n- if (this.geometryTypeMatches(this.feature)) {\n- // in to a feature\n- if (previouslyIn && inNew) {\n- // out of last feature and in to another\n- if (this.lastFeature) {\n- this.triggerCallback(type, 'out', [this.lastFeature]);\n- }\n- this.triggerCallback(type, 'in', [this.feature]);\n- } else if (!previouslyIn || click) {\n- // in feature for the first time\n- this.triggerCallback(type, 'in', [this.feature]);\n- }\n- this.lastFeature = this.feature;\n- handled = true;\n- } else {\n- // not in to a feature\n- if (this.lastFeature && (previouslyIn && inNew || click)) {\n- // out of last feature for the first time\n- this.triggerCallback(type, 'out', [this.lastFeature]);\n- }\n- // next time the mouse goes in a feature whose geometry type\n- // doesn't match we don't want to call the 'out' callback\n- // again, so let's set this.feature to null so that\n- // previouslyIn will evaluate to false the next time\n- // we enter handle. Yes, a bit hackish...\n- this.feature = null;\n- }\n- } else if (this.lastFeature && (previouslyIn || click)) {\n- this.triggerCallback(type, 'out', [this.lastFeature]);\n- }\n- return handled;\n+ touchend: function(evt) {\n+ // override evt.xy with last position since touchend does not have\n+ // any touch position\n+ evt.xy = this.last;\n+ return this.dragend(evt);\n },\n \n /**\n- * Method: triggerCallback\n- * Call the callback keyed in the event map with the supplied arguments.\n- * For click and clickout, the is checked first.\n+ * Method: mouseout\n+ * Handle mouseout events\n *\n * Parameters:\n- * type - {String}\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} Let the event propagate.\n */\n- triggerCallback: function(type, mode, args) {\n- var key = this.EVENTMAP[type][mode];\n- if (key) {\n- if (type == 'click' && this.up && this.down) {\n- // for click/clickout, only trigger callback if tolerance is met\n- var dpx = Math.sqrt(\n- Math.pow(this.up.x - this.down.x, 2) +\n- Math.pow(this.up.y - this.down.y, 2)\n+ mouseout: function(evt) {\n+ if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n+ if (this.documentDrag === true) {\n+ this.addDocumentEvents();\n+ } else {\n+ var dragged = (this.start != this.last);\n+ this.started = false;\n+ this.dragging = false;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n );\n- if (dpx <= this.clickTolerance) {\n- this.callback(key, args);\n+ this.out(evt);\n+ this.callback(\"out\", []);\n+ if (dragged) {\n+ this.callback(\"done\", [evt.xy]);\n+ }\n+ if (document.onselectstart) {\n+ document.onselectstart = this.oldOnselectstart;\n }\n- // we're done with this set of events now: clear the cached\n- // positions so we can't trip over them later (this can occur\n- // if one of the up/down events gets eaten before it gets to us\n- // but we still get the click)\n- this.up = this.down = null;\n- } else {\n- this.callback(key, args);\n }\n }\n+ return true;\n },\n \n /**\n- * Method: activate \n- * Turn on the handler. Returns false if the handler was already active.\n- *\n+ * Method: click\n+ * The drag handler captures the click event. If something else registers\n+ * for clicks on the same element, its listener will not be called \n+ * after a drag.\n+ * \n+ * Parameters: \n+ * evt - {Event} \n+ * \n * Returns:\n- * {Boolean}\n+ * {Boolean} Let the event propagate.\n+ */\n+ click: function(evt) {\n+ // let the click event propagate only if the mouse moved\n+ return (this.start == this.last);\n+ },\n+\n+ /**\n+ * Method: activate\n+ * Activate the handler.\n+ * \n+ * Returns:\n+ * {Boolean} The handler was successfully activated.\n */\n activate: function() {\n var activated = false;\n if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.moveLayerToTop();\n- this.map.events.on({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n+ this.dragging = false;\n activated = true;\n }\n return activated;\n },\n \n /**\n * Method: deactivate \n- * Turn off the handler. Returns false if the handler was already active.\n- *\n- * Returns: \n- * {Boolean}\n+ * Deactivate the handler.\n+ * \n+ * Returns:\n+ * {Boolean} The handler was successfully deactivated.\n */\n deactivate: function() {\n var deactivated = false;\n if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.moveLayerBack();\n- this.feature = null;\n- this.lastFeature = null;\n- this.down = null;\n- this.up = null;\n- this.map.events.un({\n- \"removelayer\": this.handleMapEvents,\n- \"changelayer\": this.handleMapEvents,\n- scope: this\n- });\n+ this.started = false;\n+ this.dragging = false;\n+ this.start = null;\n+ this.last = null;\n deactivated = true;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDragDown\"\n+ );\n }\n return deactivated;\n },\n \n /**\n- * Method: handleMapEvents\n+ * Method: adjustXY\n+ * Converts event coordinates that are relative to the document body to\n+ * ones that are relative to the map viewport. The latter is the default in\n+ * OpenLayers.\n * \n * Parameters:\n * evt - {Object}\n */\n- handleMapEvents: function(evt) {\n- if (evt.type == \"removelayer\" || evt.property == \"order\") {\n- this.moveLayerToTop();\n- }\n+ adjustXY: function(evt) {\n+ var pos = OpenLayers.Util.pagePosition(this.map.viewPortDiv);\n+ evt.xy.x -= pos[0];\n+ evt.xy.y -= pos[1];\n },\n \n /**\n- * Method: moveLayerToTop\n- * Moves the layer for this handler to the top, so mouse events can reach\n- * it.\n+ * Method: addDocumentEvents\n+ * Start observing document events when documentDrag is true and the mouse\n+ * cursor leaves the map viewport while dragging.\n */\n- moveLayerToTop: function() {\n- var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,\n- this.layer.getZIndex()) + 1;\n- this.layer.setZIndex(index);\n-\n+ addDocumentEvents: function() {\n+ OpenLayers.Element.addClass(document.body, \"olDragDown\");\n+ this.documentEvents = true;\n+ OpenLayers.Event.observe(document, \"mousemove\", this._docMove);\n+ OpenLayers.Event.observe(document, \"mouseup\", this._docUp);\n },\n \n /**\n- * Method: moveLayerBack\n- * Moves the layer back to the position determined by the map's layers\n- * array.\n+ * Method: removeDocumentEvents\n+ * Stops observing document events when documentDrag is true and the mouse\n+ * cursor re-enters the map viewport while dragging.\n */\n- moveLayerBack: function() {\n- var index = this.layer.getZIndex() - 1;\n- if (index >= this.map.Z_INDEX_BASE['Feature']) {\n- this.layer.setZIndex(index);\n- } else {\n- this.map.setLayerZIndex(this.layer,\n- this.map.getLayerIndex(this.layer));\n- }\n+ removeDocumentEvents: function() {\n+ OpenLayers.Element.removeClass(document.body, \"olDragDown\");\n+ this.documentEvents = false;\n+ OpenLayers.Event.stopObserving(document, \"mousemove\", this._docMove);\n+ OpenLayers.Event.stopObserving(document, \"mouseup\", this._docUp);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Feature\"\n+ CLASS_NAME: \"OpenLayers.Handler.Drag\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Polygon.js\n+ OpenLayers/Handler/Box.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Handler/Path.js\n- * @requires OpenLayers/Geometry/Polygon.js\n+ * @requires OpenLayers/Handler.js\n+ * @requires OpenLayers/Handler/Drag.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Polygon\n- * Handler to draw a polygon on the map. Polygon is displayed on mouse down,\n- * moves on mouse move, and is finished on mouse up.\n+ * Class: OpenLayers.Handler.Box\n+ * Handler for dragging a rectangle across the map. Box is displayed \n+ * on mouse down, moves on mouse move, and is finished on mouse up.\n *\n * Inherits from:\n- * - \n- * - \n+ * - \n */\n-OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {\n+OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {\n \n /** \n- * APIProperty: holeModifier\n- * {String} Key modifier to trigger hole digitizing. Acceptable values are\n- * \"altKey\", \"shiftKey\", or \"ctrlKey\". If not set, no hole digitizing\n- * will take place. Default is null.\n+ * Property: dragHandler \n+ * {} \n */\n- holeModifier: null,\n+ dragHandler: null,\n \n /**\n- * Property: drawingHole\n- * {Boolean} Currently drawing an interior ring.\n+ * APIProperty: boxDivClassName\n+ * {String} The CSS class to use for drawing the box. Default is\n+ * olHandlerBoxZoomBox\n */\n- drawingHole: false,\n+ boxDivClassName: 'olHandlerBoxZoomBox',\n \n /**\n- * Property: polygon\n- * {}\n+ * Property: boxOffsets\n+ * {Object} Caches box offsets from css. This is used by the getBoxOffsets\n+ * method.\n */\n- polygon: null,\n+ boxOffsets: null,\n \n /**\n- * Constructor: OpenLayers.Handler.Polygon\n- * Create a Polygon Handler.\n+ * Constructor: OpenLayers.Handler.Box\n *\n * Parameters:\n- * control - {} The control that owns this handler\n+ * control - {} \n * callbacks - {Object} An object with a properties whose values are\n * functions. Various callbacks described below.\n- * options - {Object} An optional object with properties to be set on the\n- * handler\n+ * options - {Object} \n *\n * Named callbacks:\n- * create - Called when a sketch is first created. Callback called with\n- * the creation point geometry and sketch feature.\n- * modify - Called with each move of a vertex with the vertex (point)\n- * geometry and the sketch feature.\n- * point - Called as each point is added. Receives the new point geometry.\n- * done - Called when the point drawing is finished. The callback will\n- * recieve a single argument, the polygon geometry.\n- * cancel - Called when the handler is deactivated while drawing. The\n- * cancel callback will receive a geometry.\n- */\n-\n- /**\n- * Method: createFeature\n- * Add temporary geometries\n- *\n- * Parameters:\n- * pixel - {} The initial pixel location for the new\n- * feature.\n+ * start - Called when the box drag operation starts.\n+ * done - Called when the box drag operation is finished.\n+ * The callback should expect to receive a single argument, the box \n+ * bounds or a pixel. If the box dragging didn't span more than a 5 \n+ * pixel distance, a pixel will be returned instead of a bounds object.\n */\n- createFeature: function(pixel) {\n- var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n- var geometry = new OpenLayers.Geometry.Point(\n- lonlat.lon, lonlat.lat\n- );\n- this.point = new OpenLayers.Feature.Vector(geometry);\n- this.line = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.LinearRing([this.point.geometry])\n- );\n- this.polygon = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Polygon([this.line.geometry])\n+ initialize: function(control, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+ this.dragHandler = new OpenLayers.Handler.Drag(\n+ this, {\n+ down: this.startBox,\n+ move: this.moveBox,\n+ out: this.removeBox,\n+ up: this.endBox\n+ }, {\n+ keyMask: this.keyMask\n+ }\n );\n- this.callback(\"create\", [this.point.geometry, this.getSketch()]);\n- this.point.geometry.clearBounds();\n- this.layer.addFeatures([this.polygon, this.point], {\n- silent: true\n- });\n },\n \n /**\n- * Method: addPoint\n- * Add point to geometry.\n- *\n- * Parameters:\n- * pixel - {} The pixel location for the new point.\n+ * Method: destroy\n */\n- addPoint: function(pixel) {\n- if (!this.drawingHole && this.holeModifier &&\n- this.evt && this.evt[this.holeModifier]) {\n- var geometry = this.point.geometry;\n- var features = this.control.layer.features;\n- var candidate, polygon;\n- // look for intersections, last drawn gets priority\n- for (var i = features.length - 1; i >= 0; --i) {\n- candidate = features[i].geometry;\n- if ((candidate instanceof OpenLayers.Geometry.Polygon ||\n- candidate instanceof OpenLayers.Geometry.MultiPolygon) &&\n- candidate.intersects(geometry)) {\n- polygon = features[i];\n- this.control.layer.removeFeatures([polygon], {\n- silent: true\n- });\n- this.control.layer.events.registerPriority(\n- \"sketchcomplete\", this, this.finalizeInteriorRing\n- );\n- this.control.layer.events.registerPriority(\n- \"sketchmodified\", this, this.enforceTopology\n- );\n- polygon.geometry.addComponent(this.line.geometry);\n- this.polygon = polygon;\n- this.drawingHole = true;\n- break;\n- }\n- }\n+ destroy: function() {\n+ OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n+ if (this.dragHandler) {\n+ this.dragHandler.destroy();\n+ this.dragHandler = null;\n }\n- OpenLayers.Handler.Path.prototype.addPoint.apply(this, arguments);\n },\n \n /**\n- * Method: getCurrentPointIndex\n- * \n- * Returns:\n- * {Number} The index of the most recently drawn point.\n+ * Method: setMap\n */\n- getCurrentPointIndex: function() {\n- return this.line.geometry.components.length - 2;\n+ setMap: function(map) {\n+ OpenLayers.Handler.prototype.setMap.apply(this, arguments);\n+ if (this.dragHandler) {\n+ this.dragHandler.setMap(map);\n+ }\n },\n \n /**\n- * Method: enforceTopology\n- * Simple topology enforcement for drawing interior rings. Ensures vertices\n- * of interior rings are contained by exterior ring. Other topology \n- * rules are enforced in to allow drawing of \n- * rings that intersect only during the sketch (e.g. a \"C\" shaped ring\n- * that nearly encloses another ring).\n- */\n- enforceTopology: function(event) {\n- var point = event.vertex;\n- var components = this.line.geometry.components;\n- // ensure that vertices of interior ring are contained by exterior ring\n- if (!this.polygon.geometry.intersects(point)) {\n- var last = components[components.length - 3];\n- point.x = last.x;\n- point.y = last.y;\n- }\n+ * Method: startBox\n+ *\n+ * Parameters:\n+ * xy - {}\n+ */\n+ startBox: function(xy) {\n+ this.callback(\"start\", []);\n+ this.zoomBox = OpenLayers.Util.createDiv('zoomBox', {\n+ x: -9999,\n+ y: -9999\n+ });\n+ this.zoomBox.className = this.boxDivClassName;\n+ this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE[\"Popup\"] - 1;\n+\n+ this.map.viewPortDiv.appendChild(this.zoomBox);\n+\n+ OpenLayers.Element.addClass(\n+ this.map.viewPortDiv, \"olDrawBox\"\n+ );\n },\n \n /**\n- * Method: finishGeometry\n- * Finish the geometry and send it back to the control.\n+ * Method: moveBox\n */\n- finishGeometry: function() {\n- var index = this.line.geometry.components.length - 2;\n- this.line.geometry.removeComponent(this.line.geometry.components[index]);\n- this.removePoint();\n- this.finalize();\n+ moveBox: function(xy) {\n+ var startX = this.dragHandler.start.x;\n+ var startY = this.dragHandler.start.y;\n+ var deltaX = Math.abs(startX - xy.x);\n+ var deltaY = Math.abs(startY - xy.y);\n+\n+ var offset = this.getBoxOffsets();\n+ this.zoomBox.style.width = (deltaX + offset.width + 1) + \"px\";\n+ this.zoomBox.style.height = (deltaY + offset.height + 1) + \"px\";\n+ this.zoomBox.style.left = (xy.x < startX ?\n+ startX - deltaX - offset.left : startX - offset.left) + \"px\";\n+ this.zoomBox.style.top = (xy.y < startY ?\n+ startY - deltaY - offset.top : startY - offset.top) + \"px\";\n },\n \n /**\n- * Method: finalizeInteriorRing\n- * Enforces that new ring has some area and doesn't contain vertices of any\n- * other rings.\n+ * Method: endBox\n */\n- finalizeInteriorRing: function() {\n- var ring = this.line.geometry;\n- // ensure that ring has some area\n- var modified = (ring.getArea() !== 0);\n- if (modified) {\n- // ensure that new ring doesn't intersect any other rings\n- var rings = this.polygon.geometry.components;\n- for (var i = rings.length - 2; i >= 0; --i) {\n- if (ring.intersects(rings[i])) {\n- modified = false;\n- break;\n- }\n- }\n- if (modified) {\n- // ensure that new ring doesn't contain any other rings\n- var target;\n- outer: for (var i = rings.length - 2; i > 0; --i) {\n- var points = rings[i].components;\n- for (var j = 0, jj = points.length; j < jj; ++j) {\n- if (ring.containsPoint(points[j])) {\n- modified = false;\n- break outer;\n- }\n- }\n- }\n- }\n- }\n- if (modified) {\n- if (this.polygon.state !== OpenLayers.State.INSERT) {\n- this.polygon.state = OpenLayers.State.UPDATE;\n- }\n+ endBox: function(end) {\n+ var result;\n+ if (Math.abs(this.dragHandler.start.x - end.x) > 5 ||\n+ Math.abs(this.dragHandler.start.y - end.y) > 5) {\n+ var start = this.dragHandler.start;\n+ var top = Math.min(start.y, end.y);\n+ var bottom = Math.max(start.y, end.y);\n+ var left = Math.min(start.x, end.x);\n+ var right = Math.max(start.x, end.x);\n+ result = new OpenLayers.Bounds(left, bottom, right, top);\n } else {\n- this.polygon.geometry.removeComponent(ring);\n+ result = this.dragHandler.start.clone(); // i.e. OL.Pixel\n }\n- this.restoreFeature();\n- return false;\n- },\n+ this.removeBox();\n \n- /**\n- * APIMethod: cancel\n- * Finish the geometry and call the \"cancel\" callback.\n- */\n- cancel: function() {\n- if (this.drawingHole) {\n- this.polygon.geometry.removeComponent(this.line.geometry);\n- this.restoreFeature(true);\n- }\n- return OpenLayers.Handler.Path.prototype.cancel.apply(this, arguments);\n+ this.callback(\"done\", [result]);\n },\n \n /**\n- * Method: restoreFeature\n- * Move the feature from the sketch layer to the target layer.\n- *\n- * Properties: \n- * cancel - {Boolean} Cancel drawing. If falsey, the \"sketchcomplete\" event\n- * will be fired.\n+ * Method: removeBox\n+ * Remove the zoombox from the screen and nullify our reference to it.\n */\n- restoreFeature: function(cancel) {\n- this.control.layer.events.unregister(\n- \"sketchcomplete\", this, this.finalizeInteriorRing\n- );\n- this.control.layer.events.unregister(\n- \"sketchmodified\", this, this.enforceTopology\n+ removeBox: function() {\n+ this.map.viewPortDiv.removeChild(this.zoomBox);\n+ this.zoomBox = null;\n+ this.boxOffsets = null;\n+ OpenLayers.Element.removeClass(\n+ this.map.viewPortDiv, \"olDrawBox\"\n );\n- this.layer.removeFeatures([this.polygon], {\n- silent: true\n- });\n- this.control.layer.addFeatures([this.polygon], {\n- silent: true\n- });\n- this.drawingHole = false;\n- if (!cancel) {\n- // Re-trigger \"sketchcomplete\" so other listeners can do their\n- // business. While this is somewhat sloppy (if a listener is \n- // registered with registerPriority - not common - between the start\n- // and end of a single ring drawing - very uncommon - it will be \n- // called twice).\n- // TODO: In 3.0, collapse sketch handlers into geometry specific\n- // drawing controls.\n- this.control.layer.events.triggerEvent(\n- \"sketchcomplete\", {\n- feature: this.polygon\n- }\n- );\n- }\n- },\n \n- /**\n- * Method: destroyFeature\n- * Destroy temporary geometries\n- *\n- * Parameters:\n- * force - {Boolean} Destroy even if persist is true.\n- */\n- destroyFeature: function(force) {\n- OpenLayers.Handler.Path.prototype.destroyFeature.call(\n- this, force);\n- this.polygon = null;\n },\n \n /**\n- * Method: drawFeature\n- * Render geometries on the temporary layer.\n+ * Method: activate\n */\n- drawFeature: function() {\n- this.layer.drawFeature(this.polygon, this.style);\n- this.layer.drawFeature(this.point, this.style);\n+ activate: function() {\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.dragHandler.activate();\n+ return true;\n+ } else {\n+ return false;\n+ }\n },\n \n /**\n- * Method: getSketch\n- * Return the sketch feature.\n- *\n- * Returns:\n- * {}\n+ * Method: deactivate\n */\n- getSketch: function() {\n- return this.polygon;\n+ deactivate: function() {\n+ if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n+ if (this.dragHandler.deactivate()) {\n+ if (this.zoomBox) {\n+ this.removeBox();\n+ }\n+ }\n+ return true;\n+ } else {\n+ return false;\n+ }\n },\n \n /**\n- * Method: getGeometry\n- * Return the sketch geometry. If is true, this will return\n- * a multi-part geometry.\n- *\n+ * Method: getBoxOffsets\n+ * Determines border offsets for a box, according to the box model.\n+ * \n * Returns:\n- * {}\n+ * {Object} an object with the following offsets:\n+ * - left\n+ * - right\n+ * - top\n+ * - bottom\n+ * - width\n+ * - height\n */\n- getGeometry: function() {\n- var geometry = this.polygon && this.polygon.geometry;\n- if (geometry && this.multi) {\n- geometry = new OpenLayers.Geometry.MultiPolygon([geometry]);\n+ getBoxOffsets: function() {\n+ if (!this.boxOffsets) {\n+ // Determine the box model. If the testDiv's clientWidth is 3, then\n+ // the borders are outside and we are dealing with the w3c box\n+ // model. Otherwise, the browser uses the traditional box model and\n+ // the borders are inside the box bounds, leaving us with a\n+ // clientWidth of 1.\n+ var testDiv = document.createElement(\"div\");\n+ //testDiv.style.visibility = \"hidden\";\n+ testDiv.style.position = \"absolute\";\n+ testDiv.style.border = \"1px solid black\";\n+ testDiv.style.width = \"3px\";\n+ document.body.appendChild(testDiv);\n+ var w3cBoxModel = testDiv.clientWidth == 3;\n+ document.body.removeChild(testDiv);\n+\n+ var left = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n+ \"border-left-width\"));\n+ var right = parseInt(OpenLayers.Element.getStyle(\n+ this.zoomBox, \"border-right-width\"));\n+ var top = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n+ \"border-top-width\"));\n+ var bottom = parseInt(OpenLayers.Element.getStyle(\n+ this.zoomBox, \"border-bottom-width\"));\n+ this.boxOffsets = {\n+ left: left,\n+ right: right,\n+ top: top,\n+ bottom: bottom,\n+ width: w3cBoxModel === false ? left + right : 0,\n+ height: w3cBoxModel === false ? top + bottom : 0\n+ };\n }\n- return geometry;\n+ return this.boxOffsets;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Polygon\"\n+ CLASS_NAME: \"OpenLayers.Handler.Box\"\n });\n /* ======================================================================\n OpenLayers/Handler/RegularPolygon.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n@@ -36976,12645 +36832,10741 @@\n this.clear();\n }\n },\n \n CLASS_NAME: \"OpenLayers.Handler.RegularPolygon\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Box.js\n+ OpenLayers/Handler/Keyboard.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/Handler.js\n- * @requires OpenLayers/Handler/Drag.js\n+ * @requires OpenLayers/Events.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Box\n- * Handler for dragging a rectangle across the map. Box is displayed \n- * on mouse down, moves on mouse move, and is finished on mouse up.\n- *\n+ * Class: OpenLayers.handler.Keyboard\n+ * A handler for keyboard events. Create a new instance with the\n+ * constructor.\n+ * \n * Inherits from:\n * - \n */\n-OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.Handler.Keyboard = OpenLayers.Class(OpenLayers.Handler, {\n+\n+ /* http://www.quirksmode.org/js/keys.html explains key x-browser\n+ key handling quirks in pretty nice detail */\n \n /** \n- * Property: dragHandler \n- * {} \n+ * Constant: KEY_EVENTS\n+ * keydown, keypress, keyup\n */\n- dragHandler: null,\n+ KEY_EVENTS: [\"keydown\", \"keyup\"],\n \n- /**\n- * APIProperty: boxDivClassName\n- * {String} The CSS class to use for drawing the box. Default is\n- * olHandlerBoxZoomBox\n+ /** \n+ * Property: eventListener\n+ * {Function}\n */\n- boxDivClassName: 'olHandlerBoxZoomBox',\n+ eventListener: null,\n \n /**\n- * Property: boxOffsets\n- * {Object} Caches box offsets from css. This is used by the getBoxOffsets\n- * method.\n+ * Property: observeElement\n+ * {DOMElement|String} The DOM element on which we listen for\n+ * key events. Default to the document.\n */\n- boxOffsets: null,\n+ observeElement: null,\n \n /**\n- * Constructor: OpenLayers.Handler.Box\n- *\n+ * Constructor: OpenLayers.Handler.Keyboard\n+ * Returns a new keyboard handler.\n+ * \n * Parameters:\n- * control - {} \n- * callbacks - {Object} An object with a properties whose values are\n- * functions. Various callbacks described below.\n- * options - {Object} \n- *\n- * Named callbacks:\n- * start - Called when the box drag operation starts.\n- * done - Called when the box drag operation is finished.\n- * The callback should expect to receive a single argument, the box \n- * bounds or a pixel. If the box dragging didn't span more than a 5 \n- * pixel distance, a pixel will be returned instead of a bounds object.\n+ * control - {} The control that is making use of\n+ * this handler. If a handler is being used without a control, the\n+ * handlers setMap method must be overridden to deal properly with\n+ * the map.\n+ * callbacks - {Object} An object containing a single function to be\n+ * called when the drag operation is finished. The callback should\n+ * expect to recieve a single argument, the pixel location of the event.\n+ * Callbacks for 'keydown', 'keypress', and 'keyup' are supported.\n+ * options - {Object} Optional object whose properties will be set on the\n+ * handler.\n */\n initialize: function(control, callbacks, options) {\n OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n- this.dragHandler = new OpenLayers.Handler.Drag(\n- this, {\n- down: this.startBox,\n- move: this.moveBox,\n- out: this.removeBox,\n- up: this.endBox\n- }, {\n- keyMask: this.keyMask\n- }\n+ // cache the bound event listener method so it can be unobserved later\n+ this.eventListener = OpenLayers.Function.bindAsEventListener(\n+ this.handleKeyEvent, this\n );\n },\n \n /**\n * Method: destroy\n */\n destroy: function() {\n+ this.deactivate();\n+ this.eventListener = null;\n OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- if (this.dragHandler) {\n- this.dragHandler.destroy();\n- this.dragHandler = null;\n- }\n- },\n-\n- /**\n- * Method: setMap\n- */\n- setMap: function(map) {\n- OpenLayers.Handler.prototype.setMap.apply(this, arguments);\n- if (this.dragHandler) {\n- this.dragHandler.setMap(map);\n- }\n- },\n-\n- /**\n- * Method: startBox\n- *\n- * Parameters:\n- * xy - {}\n- */\n- startBox: function(xy) {\n- this.callback(\"start\", []);\n- this.zoomBox = OpenLayers.Util.createDiv('zoomBox', {\n- x: -9999,\n- y: -9999\n- });\n- this.zoomBox.className = this.boxDivClassName;\n- this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE[\"Popup\"] - 1;\n-\n- this.map.viewPortDiv.appendChild(this.zoomBox);\n-\n- OpenLayers.Element.addClass(\n- this.map.viewPortDiv, \"olDrawBox\"\n- );\n- },\n-\n- /**\n- * Method: moveBox\n- */\n- moveBox: function(xy) {\n- var startX = this.dragHandler.start.x;\n- var startY = this.dragHandler.start.y;\n- var deltaX = Math.abs(startX - xy.x);\n- var deltaY = Math.abs(startY - xy.y);\n-\n- var offset = this.getBoxOffsets();\n- this.zoomBox.style.width = (deltaX + offset.width + 1) + \"px\";\n- this.zoomBox.style.height = (deltaY + offset.height + 1) + \"px\";\n- this.zoomBox.style.left = (xy.x < startX ?\n- startX - deltaX - offset.left : startX - offset.left) + \"px\";\n- this.zoomBox.style.top = (xy.y < startY ?\n- startY - deltaY - offset.top : startY - offset.top) + \"px\";\n- },\n-\n- /**\n- * Method: endBox\n- */\n- endBox: function(end) {\n- var result;\n- if (Math.abs(this.dragHandler.start.x - end.x) > 5 ||\n- Math.abs(this.dragHandler.start.y - end.y) > 5) {\n- var start = this.dragHandler.start;\n- var top = Math.min(start.y, end.y);\n- var bottom = Math.max(start.y, end.y);\n- var left = Math.min(start.x, end.x);\n- var right = Math.max(start.x, end.x);\n- result = new OpenLayers.Bounds(left, bottom, right, top);\n- } else {\n- result = this.dragHandler.start.clone(); // i.e. OL.Pixel\n- }\n- this.removeBox();\n-\n- this.callback(\"done\", [result]);\n- },\n-\n- /**\n- * Method: removeBox\n- * Remove the zoombox from the screen and nullify our reference to it.\n- */\n- removeBox: function() {\n- this.map.viewPortDiv.removeChild(this.zoomBox);\n- this.zoomBox = null;\n- this.boxOffsets = null;\n- OpenLayers.Element.removeClass(\n- this.map.viewPortDiv, \"olDrawBox\"\n- );\n-\n },\n \n /**\n * Method: activate\n */\n activate: function() {\n if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- this.dragHandler.activate();\n+ this.observeElement = this.observeElement || document;\n+ for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n+ OpenLayers.Event.observe(\n+ this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n+ }\n return true;\n } else {\n return false;\n }\n },\n \n /**\n * Method: deactivate\n */\n deactivate: function() {\n+ var deactivated = false;\n if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- if (this.dragHandler.deactivate()) {\n- if (this.zoomBox) {\n- this.removeBox();\n- }\n+ for (var i = 0, len = this.KEY_EVENTS.length; i < len; i++) {\n+ OpenLayers.Event.stopObserving(\n+ this.observeElement, this.KEY_EVENTS[i], this.eventListener);\n }\n- return true;\n- } else {\n- return false;\n+ deactivated = true;\n }\n+ return deactivated;\n },\n \n /**\n- * Method: getBoxOffsets\n- * Determines border offsets for a box, according to the box model.\n- * \n- * Returns:\n- * {Object} an object with the following offsets:\n- * - left\n- * - right\n- * - top\n- * - bottom\n- * - width\n- * - height\n+ * Method: handleKeyEvent \n */\n- getBoxOffsets: function() {\n- if (!this.boxOffsets) {\n- // Determine the box model. If the testDiv's clientWidth is 3, then\n- // the borders are outside and we are dealing with the w3c box\n- // model. Otherwise, the browser uses the traditional box model and\n- // the borders are inside the box bounds, leaving us with a\n- // clientWidth of 1.\n- var testDiv = document.createElement(\"div\");\n- //testDiv.style.visibility = \"hidden\";\n- testDiv.style.position = \"absolute\";\n- testDiv.style.border = \"1px solid black\";\n- testDiv.style.width = \"3px\";\n- document.body.appendChild(testDiv);\n- var w3cBoxModel = testDiv.clientWidth == 3;\n- document.body.removeChild(testDiv);\n-\n- var left = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n- \"border-left-width\"));\n- var right = parseInt(OpenLayers.Element.getStyle(\n- this.zoomBox, \"border-right-width\"));\n- var top = parseInt(OpenLayers.Element.getStyle(this.zoomBox,\n- \"border-top-width\"));\n- var bottom = parseInt(OpenLayers.Element.getStyle(\n- this.zoomBox, \"border-bottom-width\"));\n- this.boxOffsets = {\n- left: left,\n- right: right,\n- top: top,\n- bottom: bottom,\n- width: w3cBoxModel === false ? left + right : 0,\n- height: w3cBoxModel === false ? top + bottom : 0\n- };\n+ handleKeyEvent: function(evt) {\n+ if (this.checkModifiers(evt)) {\n+ this.callback(evt.type, [evt]);\n }\n- return this.boxOffsets;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Box\"\n+ CLASS_NAME: \"OpenLayers.Handler.Keyboard\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Hover.js\n+ OpenLayers/Handler/Feature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/Handler.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Hover\n- * The hover handler is to be used to emulate mouseovers on objects\n- * on the map that aren't DOM elements. For example one can use\n- * this handler to send WMS/GetFeatureInfo requests as the user\n- * moves the mouve over the map.\n- * \n+ * Class: OpenLayers.Handler.Feature \n+ * Handler to respond to mouse events related to a drawn feature. Callbacks\n+ * with the following keys will be notified of the following events\n+ * associated with features: click, clickout, over, out, and dblclick.\n+ *\n+ * This handler stops event propagation for mousedown and mouseup if those\n+ * browser events target features that can be selected.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Handler.Hover = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {\n \n /**\n- * APIProperty: delay\n- * {Integer} - Number of milliseconds between mousemoves before\n- * the event is considered a hover. Default is 500.\n+ * Property: EVENTMAP\n+ * {Object} A object mapping the browser events to objects with callback\n+ * keys for in and out.\n */\n- delay: 500,\n+ EVENTMAP: {\n+ 'click': {\n+ 'in': 'click',\n+ 'out': 'clickout'\n+ },\n+ 'mousemove': {\n+ 'in': 'over',\n+ 'out': 'out'\n+ },\n+ 'dblclick': {\n+ 'in': 'dblclick',\n+ 'out': null\n+ },\n+ 'mousedown': {\n+ 'in': null,\n+ 'out': null\n+ },\n+ 'mouseup': {\n+ 'in': null,\n+ 'out': null\n+ },\n+ 'touchstart': {\n+ 'in': 'click',\n+ 'out': 'clickout'\n+ }\n+ },\n \n /**\n- * APIProperty: pixelTolerance\n- * {Integer} - Maximum number of pixels between mousemoves for\n- * an event to be considered a hover. Default is null.\n+ * Property: feature\n+ * {} The last feature that was hovered.\n */\n- pixelTolerance: null,\n+ feature: null,\n \n /**\n- * APIProperty: stopMove\n- * {Boolean} - Stop other listeners from being notified on mousemoves.\n- * Default is false.\n+ * Property: lastFeature\n+ * {} The last feature that was handled.\n */\n- stopMove: false,\n+ lastFeature: null,\n \n /**\n- * Property: px\n- * {} - The location of the last mousemove, expressed\n- * in pixels.\n+ * Property: down\n+ * {} The location of the last mousedown.\n */\n- px: null,\n+ down: null,\n \n /**\n- * Property: timerId\n- * {Number} - The id of the timer.\n+ * Property: up\n+ * {} The location of the last mouseup.\n */\n- timerId: null,\n+ up: null,\n \n /**\n- * Constructor: OpenLayers.Handler.Hover\n- * Construct a hover handler.\n+ * Property: clickTolerance\n+ * {Number} The number of pixels the mouse can move between mousedown\n+ * and mouseup for the event to still be considered a click.\n+ * Dragging the map should not trigger the click and clickout callbacks\n+ * unless the map is moved by less than this tolerance. Defaults to 4.\n+ */\n+ clickTolerance: 4,\n+\n+ /**\n+ * Property: geometryTypes\n+ * To restrict dragging to a limited set of geometry types, send a list\n+ * of strings corresponding to the geometry class names.\n+ * \n+ * @type Array(String)\n+ */\n+ geometryTypes: null,\n+\n+ /**\n+ * Property: stopClick\n+ * {Boolean} If stopClick is set to true, handled clicks do not\n+ * propagate to other click listeners. Otherwise, handled clicks\n+ * do propagate. Unhandled clicks always propagate, whatever the\n+ * value of stopClick. Defaults to true.\n+ */\n+ stopClick: true,\n+\n+ /**\n+ * Property: stopDown\n+ * {Boolean} If stopDown is set to true, handled mousedowns do not\n+ * propagate to other mousedown listeners. Otherwise, handled\n+ * mousedowns do propagate. Unhandled mousedowns always propagate,\n+ * whatever the value of stopDown. Defaults to true.\n+ */\n+ stopDown: true,\n+\n+ /**\n+ * Property: stopUp\n+ * {Boolean} If stopUp is set to true, handled mouseups do not\n+ * propagate to other mouseup listeners. Otherwise, handled mouseups\n+ * do propagate. Unhandled mouseups always propagate, whatever the\n+ * value of stopUp. Defaults to false.\n+ */\n+ stopUp: false,\n+\n+ /**\n+ * Constructor: OpenLayers.Handler.Feature\n *\n * Parameters:\n- * control - {} The control that initialized this\n- * handler. The control is assumed to have a valid map property; that\n- * map is used in the handler's own setMap method.\n- * callbacks - {Object} An object with keys corresponding to callbacks\n- * that will be called by the handler. The callbacks should\n- * expect to receive a single argument, the event. Callbacks for\n- * 'move', the mouse is moving, and 'pause', the mouse is pausing,\n- * are supported.\n- * options - {Object} An optional object whose properties will be set on\n- * the handler.\n+ * control - {} \n+ * layer - {}\n+ * callbacks - {Object} An object with a 'over' property whos value is\n+ * a function to be called when the mouse is over a feature. The \n+ * callback should expect to recieve a single argument, the feature.\n+ * options - {Object} \n */\n+ initialize: function(control, layer, callbacks, options) {\n+ OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);\n+ this.layer = layer;\n+ },\n \n /**\n- * Method: mousemove\n- * Called when the mouse moves on the map.\n+ * Method: touchstart\n+ * Handle touchstart events\n *\n * Parameters:\n- * evt - {}\n+ * evt - {Event}\n *\n * Returns:\n- * {Boolean} Continue propagating this event.\n+ * {Boolean} Let the event propagate.\n */\n- mousemove: function(evt) {\n- if (this.passesTolerance(evt.xy)) {\n- this.clearTimer();\n- this.callback('move', [evt]);\n- this.px = evt.xy;\n- // clone the evt so original properties can be accessed even\n- // if the browser deletes them during the delay\n- evt = OpenLayers.Util.extend({}, evt);\n- this.timerId = window.setTimeout(\n- OpenLayers.Function.bind(this.delayedCall, this, evt),\n- this.delay\n- );\n+ touchstart: function(evt) {\n+ this.startTouch();\n+ return OpenLayers.Event.isMultiTouch(evt) ?\n+ true : this.mousedown(evt);\n+ },\n+\n+ /**\n+ * Method: touchmove\n+ * Handle touchmove events. We just prevent the browser default behavior,\n+ * for Android Webkit not to select text when moving the finger after\n+ * selecting a feature.\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ */\n+ touchmove: function(evt) {\n+ OpenLayers.Event.preventDefault(evt);\n+ },\n+\n+ /**\n+ * Method: mousedown\n+ * Handle mouse down. Stop propagation if a feature is targeted by this\n+ * event (stops map dragging during feature selection).\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ mousedown: function(evt) {\n+ // Feature selection is only done with a left click. Other handlers may stop the\n+ // propagation of left-click mousedown events but not right-click mousedown events.\n+ // This mismatch causes problems when comparing the location of the down and up\n+ // events in the click function so it is important ignore right-clicks.\n+ if (OpenLayers.Event.isLeftClick(evt) || OpenLayers.Event.isSingleTouch(evt)) {\n+ this.down = evt.xy;\n }\n- return !this.stopMove;\n+ return this.handle(evt) ? !this.stopDown : true;\n },\n \n /**\n- * Method: mouseout\n- * Called when the mouse goes out of the map.\n+ * Method: mouseup\n+ * Handle mouse up. Stop propagation if a feature is targeted by this\n+ * event.\n+ * \n+ * Parameters:\n+ * evt - {Event} \n+ */\n+ mouseup: function(evt) {\n+ this.up = evt.xy;\n+ return this.handle(evt) ? !this.stopUp : true;\n+ },\n+\n+ /**\n+ * Method: click\n+ * Handle click. Call the \"click\" callback if click on a feature,\n+ * or the \"clickout\" callback if click outside any feature.\n+ * \n+ * Parameters:\n+ * evt - {Event} \n *\n+ * Returns:\n+ * {Boolean}\n+ */\n+ click: function(evt) {\n+ return this.handle(evt) ? !this.stopClick : true;\n+ },\n+\n+ /**\n+ * Method: mousemove\n+ * Handle mouse moves. Call the \"over\" callback if moving in to a feature,\n+ * or the \"out\" callback if moving out of a feature.\n+ * \n * Parameters:\n- * evt - {}\n+ * evt - {Event} \n *\n * Returns:\n- * {Boolean} Continue propagating this event.\n+ * {Boolean}\n */\n- mouseout: function(evt) {\n- if (OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n- this.clearTimer();\n- this.callback('move', [evt]);\n+ mousemove: function(evt) {\n+ if (!this.callbacks['over'] && !this.callbacks['out']) {\n+ return true;\n }\n+ this.handle(evt);\n return true;\n },\n \n /**\n- * Method: passesTolerance\n- * Determine whether the mouse move is within the optional pixel tolerance.\n+ * Method: dblclick\n+ * Handle dblclick. Call the \"dblclick\" callback if dblclick on a feature.\n *\n * Parameters:\n- * px - {}\n+ * evt - {Event} \n *\n * Returns:\n- * {Boolean} The mouse move is within the pixel tolerance.\n+ * {Boolean}\n */\n- passesTolerance: function(px) {\n- var passes = true;\n- if (this.pixelTolerance && this.px) {\n- var dpx = Math.sqrt(\n- Math.pow(this.px.x - px.x, 2) +\n- Math.pow(this.px.y - px.y, 2)\n- );\n- if (dpx < this.pixelTolerance) {\n- passes = false;\n- }\n- }\n- return passes;\n+ dblclick: function(evt) {\n+ return !this.handle(evt);\n },\n \n /**\n- * Method: clearTimer\n- * Clear the timer and set to null.\n+ * Method: geometryTypeMatches\n+ * Return true if the geometry type of the passed feature matches\n+ * one of the geometry types in the geometryTypes array.\n+ *\n+ * Parameters:\n+ * feature - {}\n+ *\n+ * Returns:\n+ * {Boolean}\n */\n- clearTimer: function() {\n- if (this.timerId != null) {\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n+ geometryTypeMatches: function(feature) {\n+ return this.geometryTypes == null ||\n+ OpenLayers.Util.indexOf(this.geometryTypes,\n+ feature.geometry.CLASS_NAME) > -1;\n+ },\n+\n+ /**\n+ * Method: handle\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ *\n+ * Returns:\n+ * {Boolean} The event occurred over a relevant feature.\n+ */\n+ handle: function(evt) {\n+ if (this.feature && !this.feature.layer) {\n+ // feature has been destroyed\n+ this.feature = null;\n+ }\n+ var type = evt.type;\n+ var handled = false;\n+ var previouslyIn = !!(this.feature); // previously in a feature\n+ var click = (type == \"click\" || type == \"dblclick\" || type == \"touchstart\");\n+ this.feature = this.layer.getFeatureFromEvent(evt);\n+ if (this.feature && !this.feature.layer) {\n+ // feature has been destroyed\n+ this.feature = null;\n+ }\n+ if (this.lastFeature && !this.lastFeature.layer) {\n+ // last feature has been destroyed\n+ this.lastFeature = null;\n+ }\n+ if (this.feature) {\n+ if (type === \"touchstart\") {\n+ // stop the event to prevent Android Webkit from\n+ // \"flashing\" the map div\n+ OpenLayers.Event.preventDefault(evt);\n+ }\n+ var inNew = (this.feature != this.lastFeature);\n+ if (this.geometryTypeMatches(this.feature)) {\n+ // in to a feature\n+ if (previouslyIn && inNew) {\n+ // out of last feature and in to another\n+ if (this.lastFeature) {\n+ this.triggerCallback(type, 'out', [this.lastFeature]);\n+ }\n+ this.triggerCallback(type, 'in', [this.feature]);\n+ } else if (!previouslyIn || click) {\n+ // in feature for the first time\n+ this.triggerCallback(type, 'in', [this.feature]);\n+ }\n+ this.lastFeature = this.feature;\n+ handled = true;\n+ } else {\n+ // not in to a feature\n+ if (this.lastFeature && (previouslyIn && inNew || click)) {\n+ // out of last feature for the first time\n+ this.triggerCallback(type, 'out', [this.lastFeature]);\n+ }\n+ // next time the mouse goes in a feature whose geometry type\n+ // doesn't match we don't want to call the 'out' callback\n+ // again, so let's set this.feature to null so that\n+ // previouslyIn will evaluate to false the next time\n+ // we enter handle. Yes, a bit hackish...\n+ this.feature = null;\n+ }\n+ } else if (this.lastFeature && (previouslyIn || click)) {\n+ this.triggerCallback(type, 'out', [this.lastFeature]);\n }\n+ return handled;\n },\n \n /**\n- * Method: delayedCall\n- * Triggers pause callback.\n+ * Method: triggerCallback\n+ * Call the callback keyed in the event map with the supplied arguments.\n+ * For click and clickout, the is checked first.\n *\n * Parameters:\n- * evt - {}\n+ * type - {String}\n */\n- delayedCall: function(evt) {\n- this.callback('pause', [evt]);\n+ triggerCallback: function(type, mode, args) {\n+ var key = this.EVENTMAP[type][mode];\n+ if (key) {\n+ if (type == 'click' && this.up && this.down) {\n+ // for click/clickout, only trigger callback if tolerance is met\n+ var dpx = Math.sqrt(\n+ Math.pow(this.up.x - this.down.x, 2) +\n+ Math.pow(this.up.y - this.down.y, 2)\n+ );\n+ if (dpx <= this.clickTolerance) {\n+ this.callback(key, args);\n+ }\n+ // we're done with this set of events now: clear the cached\n+ // positions so we can't trip over them later (this can occur\n+ // if one of the up/down events gets eaten before it gets to us\n+ // but we still get the click)\n+ this.up = this.down = null;\n+ } else {\n+ this.callback(key, args);\n+ }\n+ }\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the handler.\n+ * Method: activate \n+ * Turn on the handler. Returns false if the handler was already active.\n *\n * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * {Boolean}\n+ */\n+ activate: function() {\n+ var activated = false;\n+ if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n+ this.moveLayerToTop();\n+ this.map.events.on({\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n+ scope: this\n+ });\n+ activated = true;\n+ }\n+ return activated;\n+ },\n+\n+ /**\n+ * Method: deactivate \n+ * Turn off the handler. Returns false if the handler was already active.\n+ *\n+ * Returns: \n+ * {Boolean}\n */\n deactivate: function() {\n var deactivated = false;\n if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.clearTimer();\n+ this.moveLayerBack();\n+ this.feature = null;\n+ this.lastFeature = null;\n+ this.down = null;\n+ this.up = null;\n+ this.map.events.un({\n+ \"removelayer\": this.handleMapEvents,\n+ \"changelayer\": this.handleMapEvents,\n+ scope: this\n+ });\n deactivated = true;\n }\n return deactivated;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Hover\"\n+ /**\n+ * Method: handleMapEvents\n+ * \n+ * Parameters:\n+ * evt - {Object}\n+ */\n+ handleMapEvents: function(evt) {\n+ if (evt.type == \"removelayer\" || evt.property == \"order\") {\n+ this.moveLayerToTop();\n+ }\n+ },\n+\n+ /**\n+ * Method: moveLayerToTop\n+ * Moves the layer for this handler to the top, so mouse events can reach\n+ * it.\n+ */\n+ moveLayerToTop: function() {\n+ var index = Math.max(this.map.Z_INDEX_BASE['Feature'] - 1,\n+ this.layer.getZIndex()) + 1;\n+ this.layer.setZIndex(index);\n+\n+ },\n+\n+ /**\n+ * Method: moveLayerBack\n+ * Moves the layer back to the position determined by the map's layers\n+ * array.\n+ */\n+ moveLayerBack: function() {\n+ var index = this.layer.getZIndex() - 1;\n+ if (index >= this.map.Z_INDEX_BASE['Feature']) {\n+ this.layer.setZIndex(index);\n+ } else {\n+ this.map.setLayerZIndex(this.layer,\n+ this.map.getLayerIndex(this.layer));\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Handler.Feature\"\n });\n /* ======================================================================\n- OpenLayers/Layer/Vector.js\n+ OpenLayers/Control/DrawFeature.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Layer.js\n- * @requires OpenLayers/Renderer.js\n- * @requires OpenLayers/StyleMap.js\n+ * @requires OpenLayers/Control.js\n * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Console.js\n- * @requires OpenLayers/Lang.js\n */\n \n /**\n- * Class: OpenLayers.Layer.Vector\n- * Instances of OpenLayers.Layer.Vector are used to render vector data from\n- * a variety of sources. Create a new vector layer with the\n- * constructor.\n+ * Class: OpenLayers.Control.DrawFeature\n+ * The DrawFeature control draws point, line or polygon features on a vector\n+ * layer when active.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {\n+OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /**\n+ * Property: layer\n+ * {}\n+ */\n+ layer: null,\n \n /**\n+ * Property: callbacks\n+ * {Object} The functions that are sent to the handler for callback\n+ */\n+ callbacks: null,\n+\n+ /** \n * APIProperty: events\n- * {}\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n *\n * Register a listener for a particular event with the following syntax:\n * (code)\n- * layer.events.register(type, obj, listener);\n+ * control.events.register(type, obj, listener);\n * (end)\n *\n- * Listeners will be called with a reference to an event object. The\n- * properties of this event depends on exactly what happened.\n- *\n- * All event objects have at least the following properties:\n- * object - {Object} A reference to layer.events.object.\n- * element - {DOMElement} A reference to layer.events.element.\n- *\n- * Supported map event types (in addition to those from ):\n- * beforefeatureadded - Triggered before a feature is added. Listeners\n- * will receive an object with a *feature* property referencing the\n- * feature to be added. To stop the feature from being added, a\n- * listener should return false.\n- * beforefeaturesadded - Triggered before an array of features is added.\n- * Listeners will receive an object with a *features* property\n- * referencing the feature to be added. To stop the features from\n- * being added, a listener should return false.\n- * featureadded - Triggered after a feature is added. The event\n- * object passed to listeners will have a *feature* property with a\n- * reference to the added feature.\n- * featuresadded - Triggered after features are added. The event\n- * object passed to listeners will have a *features* property with a\n- * reference to an array of added features.\n- * beforefeatureremoved - Triggered before a feature is removed. Listeners\n- * will receive an object with a *feature* property referencing the\n- * feature to be removed.\n- * beforefeaturesremoved - Triggered before multiple features are removed. \n- * Listeners will receive an object with a *features* property\n- * referencing the features to be removed.\n- * featureremoved - Triggerd after a feature is removed. The event\n- * object passed to listeners will have a *feature* property with a\n- * reference to the removed feature.\n- * featuresremoved - Triggered after features are removed. The event\n- * object passed to listeners will have a *features* property with a\n- * reference to an array of removed features.\n- * beforefeatureselected - Triggered before a feature is selected. Listeners\n- * will receive an object with a *feature* property referencing the\n- * feature to be selected. To stop the feature from being selectd, a\n- * listener should return false.\n- * featureselected - Triggered after a feature is selected. Listeners\n- * will receive an object with a *feature* property referencing the\n- * selected feature.\n- * featureunselected - Triggered after a feature is unselected.\n- * Listeners will receive an object with a *feature* property\n- * referencing the unselected feature.\n- * beforefeaturemodified - Triggered when a feature is selected to \n- * be modified. Listeners will receive an object with a *feature* \n- * property referencing the selected feature.\n- * featuremodified - Triggered when a feature has been modified.\n- * Listeners will receive an object with a *feature* property referencing \n- * the modified feature.\n- * afterfeaturemodified - Triggered when a feature is finished being modified.\n- * Listeners will receive an object with a *feature* property referencing \n- * the modified feature.\n- * vertexmodified - Triggered when a vertex within any feature geometry\n- * has been modified. Listeners will receive an object with a\n- * *feature* property referencing the modified feature, a *vertex*\n- * property referencing the vertex modified (always a point geometry),\n- * and a *pixel* property referencing the pixel location of the\n- * modification.\n- * vertexremoved - Triggered when a vertex within any feature geometry\n- * has been deleted. Listeners will receive an object with a\n- * *feature* property referencing the modified feature, a *vertex*\n- * property referencing the vertex modified (always a point geometry),\n- * and a *pixel* property referencing the pixel location of the\n- * removal.\n- * sketchstarted - Triggered when a feature sketch bound for this layer\n- * is started. Listeners will receive an object with a *feature*\n- * property referencing the new sketch feature and a *vertex* property\n- * referencing the creation point.\n- * sketchmodified - Triggered when a feature sketch bound for this layer\n- * is modified. Listeners will receive an object with a *vertex*\n- * property referencing the modified vertex and a *feature* property\n- * referencing the sketch feature.\n- * sketchcomplete - Triggered when a feature sketch bound for this layer\n- * is complete. Listeners will receive an object with a *feature*\n- * property referencing the sketch feature. By returning false, a\n- * listener can stop the sketch feature from being added to the layer.\n- * refresh - Triggered when something wants a strategy to ask the protocol\n- * for a new set of features.\n+ * Supported event types (in addition to those from ):\n+ * featureadded - Triggered when a feature is added\n */\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} The layer is a base layer. Default is false. Set this property\n- * in the layer options.\n+ * APIProperty: multi\n+ * {Boolean} Cast features to multi-part geometries before passing to the\n+ * layer. Default is false.\n */\n- isBaseLayer: false,\n+ multi: false,\n \n- /** \n- * APIProperty: isFixed\n- * {Boolean} Whether the layer remains in one place while dragging the\n- * map. Note that setting this to true will move the layer to the bottom\n- * of the layer stack.\n+ /**\n+ * APIProperty: featureAdded\n+ * {Function} Called after each feature is added\n */\n- isFixed: false,\n+ featureAdded: function() {},\n \n- /** \n- * APIProperty: features\n- * {Array()} \n+ /**\n+ * APIProperty: handlerOptions\n+ * {Object} Used to set non-default properties on the control's handler\n */\n- features: null,\n \n- /** \n- * Property: filter\n- * {} The filter set in this layer,\n- * a strategy launching read requests can combined\n- * this filter with its own filter.\n+ /**\n+ * Constructor: OpenLayers.Control.DrawFeature\n+ * \n+ * Parameters:\n+ * layer - {} \n+ * handler - {} \n+ * options - {Object} \n */\n- filter: null,\n+ initialize: function(layer, handler, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.callbacks = OpenLayers.Util.extend({\n+ done: this.drawFeature,\n+ modify: function(vertex, feature) {\n+ this.layer.events.triggerEvent(\n+ \"sketchmodified\", {\n+ vertex: vertex,\n+ feature: feature\n+ }\n+ );\n+ },\n+ create: function(vertex, feature) {\n+ this.layer.events.triggerEvent(\n+ \"sketchstarted\", {\n+ vertex: vertex,\n+ feature: feature\n+ }\n+ );\n+ }\n+ },\n+ this.callbacks\n+ );\n+ this.layer = layer;\n+ this.handlerOptions = this.handlerOptions || {};\n+ this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(\n+ this.handlerOptions.layerOptions, {\n+ renderers: layer.renderers,\n+ rendererOptions: layer.rendererOptions\n+ }\n+ );\n+ if (!(\"multi\" in this.handlerOptions)) {\n+ this.handlerOptions.multi = this.multi;\n+ }\n+ var sketchStyle = this.layer.styleMap && this.layer.styleMap.styles.temporary;\n+ if (sketchStyle) {\n+ this.handlerOptions.layerOptions = OpenLayers.Util.applyDefaults(\n+ this.handlerOptions.layerOptions, {\n+ styleMap: new OpenLayers.StyleMap({\n+ \"default\": sketchStyle\n+ })\n+ }\n+ );\n+ }\n+ this.handler = new handler(this, this.callbacks, this.handlerOptions);\n+ },\n \n- /** \n- * Property: selectedFeatures\n- * {Array()} \n+ /**\n+ * Method: drawFeature\n */\n- selectedFeatures: null,\n+ drawFeature: function(geometry) {\n+ var feature = new OpenLayers.Feature.Vector(geometry);\n+ var proceed = this.layer.events.triggerEvent(\n+ \"sketchcomplete\", {\n+ feature: feature\n+ }\n+ );\n+ if (proceed !== false) {\n+ feature.state = OpenLayers.State.INSERT;\n+ this.layer.addFeatures([feature]);\n+ this.featureAdded(feature);\n+ this.events.triggerEvent(\"featureadded\", {\n+ feature: feature\n+ });\n+ }\n+ },\n \n /**\n- * Property: unrenderedFeatures\n- * {Object} hash of features, keyed by feature.id, that the renderer\n- * failed to draw\n+ * APIMethod: insertXY\n+ * Insert a point in the current sketch given x & y coordinates.\n+ *\n+ * Parameters:\n+ * x - {Number} The x-coordinate of the point.\n+ * y - {Number} The y-coordinate of the point.\n */\n- unrenderedFeatures: null,\n+ insertXY: function(x, y) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertXY(x, y);\n+ }\n+ },\n \n /**\n- * APIProperty: reportError\n- * {Boolean} report friendly error message when loading of renderer\n- * fails.\n+ * APIMethod: insertDeltaXY\n+ * Insert a point given offsets from the previously inserted point.\n+ *\n+ * Parameters:\n+ * dx - {Number} The x-coordinate offset of the point.\n+ * dy - {Number} The y-coordinate offset of the point.\n */\n- reportError: true,\n+ insertDeltaXY: function(dx, dy) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertDeltaXY(dx, dy);\n+ }\n+ },\n \n- /** \n- * APIProperty: style\n- * {Object} Default style for the layer\n+ /**\n+ * APIMethod: insertDirectionLength\n+ * Insert a point in the current sketch given a direction and a length.\n+ *\n+ * Parameters:\n+ * direction - {Number} Degrees clockwise from the positive x-axis.\n+ * length - {Number} Distance from the previously drawn point.\n */\n- style: null,\n+ insertDirectionLength: function(direction, length) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertDirectionLength(direction, length);\n+ }\n+ },\n \n /**\n- * Property: styleMap\n- * {}\n+ * APIMethod: insertDeflectionLength\n+ * Insert a point in the current sketch given a deflection and a length.\n+ * The deflection should be degrees clockwise from the previously \n+ * digitized segment.\n+ *\n+ * Parameters:\n+ * deflection - {Number} Degrees clockwise from the previous segment.\n+ * length - {Number} Distance from the previously drawn point.\n */\n- styleMap: null,\n+ insertDeflectionLength: function(deflection, length) {\n+ if (this.handler && this.handler.line) {\n+ this.handler.insertDeflectionLength(deflection, length);\n+ }\n+ },\n \n /**\n- * Property: strategies\n- * {Array(})} Optional list of strategies for the layer.\n+ * APIMethod: undo\n+ * Remove the most recently added point in the current sketch geometry.\n+ *\n+ * Returns: \n+ * {Boolean} An edit was undone.\n */\n- strategies: null,\n+ undo: function() {\n+ return this.handler.undo && this.handler.undo();\n+ },\n \n /**\n- * Property: protocol\n- * {} Optional protocol for the layer.\n+ * APIMethod: redo\n+ * Reinsert the most recently removed point resulting from an call.\n+ * The undo stack is deleted whenever a point is added by other means.\n+ *\n+ * Returns: \n+ * {Boolean} An edit was redone.\n */\n- protocol: null,\n+ redo: function() {\n+ return this.handler.redo && this.handler.redo();\n+ },\n \n /**\n- * Property: renderers\n- * {Array(String)} List of supported Renderer classes. Add to this list to\n- * add support for additional renderers. This list is ordered:\n- * the first renderer which returns true for the 'supported()'\n- * method will be used, if not defined in the 'renderer' option.\n+ * APIMethod: finishSketch\n+ * Finishes the sketch without including the currently drawn point.\n+ * This method can be called to terminate drawing programmatically\n+ * instead of waiting for the user to end the sketch.\n */\n- renderers: ['SVG', 'VML', 'Canvas'],\n+ finishSketch: function() {\n+ this.handler.finishGeometry();\n+ },\n \n- /** \n- * Property: renderer\n- * {}\n+ /**\n+ * APIMethod: cancel\n+ * Cancel the current sketch. This removes the current sketch and keeps\n+ * the drawing control active.\n */\n- renderer: null,\n+ cancel: function() {\n+ this.handler.cancel();\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Control.DrawFeature\"\n+});\n+/* ======================================================================\n+ OpenLayers/Events/buttonclick.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Events.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Events.buttonclick\n+ * Extension event type for handling buttons on top of a dom element. This\n+ * event type fires \"buttonclick\" on its when a button was\n+ * clicked. Buttons are detected by the \"olButton\" class.\n+ *\n+ * This event type makes sure that button clicks do not interfere with other\n+ * events that are registered on the same .\n+ *\n+ * Event types provided by this extension:\n+ * - *buttonclick* Triggered when a button is clicked. Listeners receive an\n+ * object with a *buttonElement* property referencing the dom element of\n+ * the clicked button, and an *buttonXY* property with the click position\n+ * relative to the button.\n+ */\n+OpenLayers.Events.buttonclick = OpenLayers.Class({\n \n /**\n- * APIProperty: rendererOptions\n- * {Object} Options for the renderer. See {} for\n- * supported options.\n+ * Property: target\n+ * {} The events instance that the buttonclick event will\n+ * be triggered on.\n */\n- rendererOptions: null,\n+ target: null,\n \n- /** \n- * APIProperty: geometryType\n- * {String} geometryType allows you to limit the types of geometries this\n- * layer supports. This should be set to something like\n- * \"OpenLayers.Geometry.Point\" to limit types.\n+ /**\n+ * Property: events\n+ * {Array} Events to observe and conditionally stop from propagating when\n+ * an element with the olButton class (or its olAlphaImg child) is\n+ * clicked.\n */\n- geometryType: null,\n+ events: [\n+ 'mousedown', 'mouseup', 'click', 'dblclick',\n+ 'touchstart', 'touchmove', 'touchend', 'keydown'\n+ ],\n \n- /** \n- * Property: drawn\n- * {Boolean} Whether the Vector Layer features have been drawn yet.\n+ /**\n+ * Property: startRegEx\n+ * {RegExp} Regular expression to test Event.type for events that start\n+ * a buttonclick sequence.\n */\n- drawn: false,\n+ startRegEx: /^mousedown|touchstart$/,\n \n- /** \n- * APIProperty: ratio\n- * {Float} This specifies the ratio of the size of the visiblity of the Vector Layer features to the size of the map.\n+ /**\n+ * Property: cancelRegEx\n+ * {RegExp} Regular expression to test Event.type for events that cancel\n+ * a buttonclick sequence.\n */\n- ratio: 1,\n+ cancelRegEx: /^touchmove$/,\n \n /**\n- * Constructor: OpenLayers.Layer.Vector\n- * Create a new vector layer\n- *\n- * Parameters:\n- * name - {String} A name for the layer\n- * options - {Object} Optional object with non-default properties to set on\n- * the layer.\n- *\n- * Returns:\n- * {} A new vector layer\n+ * Property: completeRegEx\n+ * {RegExp} Regular expression to test Event.type for events that complete\n+ * a buttonclick sequence.\n */\n- initialize: function(name, options) {\n- OpenLayers.Layer.prototype.initialize.apply(this, arguments);\n-\n- // allow user-set renderer, otherwise assign one\n- if (!this.renderer || !this.renderer.supported()) {\n- this.assignRenderer();\n- }\n-\n- // if no valid renderer found, display error\n- if (!this.renderer || !this.renderer.supported()) {\n- this.renderer = null;\n- this.displayError();\n- }\n-\n- if (!this.styleMap) {\n- this.styleMap = new OpenLayers.StyleMap();\n- }\n+ completeRegEx: /^mouseup|touchend$/,\n \n- this.features = [];\n- this.selectedFeatures = [];\n- this.unrenderedFeatures = {};\n+ /**\n+ * Property: startEvt\n+ * {Event} The event that started the click sequence\n+ */\n \n- // Allow for custom layer behavior\n- if (this.strategies) {\n- for (var i = 0, len = this.strategies.length; i < len; i++) {\n- this.strategies[i].setLayer(this);\n- }\n+ /**\n+ * Constructor: OpenLayers.Events.buttonclick\n+ * Construct a buttonclick event type. Applications are not supposed to\n+ * create instances of this class - they are created on demand by\n+ * instances.\n+ *\n+ * Parameters:\n+ * target - {} The events instance that the buttonclick\n+ * event will be triggered on.\n+ */\n+ initialize: function(target) {\n+ this.target = target;\n+ for (var i = this.events.length - 1; i >= 0; --i) {\n+ this.target.register(this.events[i], this, this.buttonClick, {\n+ extension: true\n+ });\n }\n-\n },\n \n /**\n- * APIMethod: destroy\n- * Destroy this layer\n+ * Method: destroy\n */\n destroy: function() {\n- if (this.strategies) {\n- var strategy, i, len;\n- for (i = 0, len = this.strategies.length; i < len; i++) {\n- strategy = this.strategies[i];\n- if (strategy.autoDestroy) {\n- strategy.destroy();\n- }\n- }\n- this.strategies = null;\n- }\n- if (this.protocol) {\n- if (this.protocol.autoDestroy) {\n- this.protocol.destroy();\n- }\n- this.protocol = null;\n- }\n- this.destroyFeatures();\n- this.features = null;\n- this.selectedFeatures = null;\n- this.unrenderedFeatures = null;\n- if (this.renderer) {\n- this.renderer.destroy();\n+ for (var i = this.events.length - 1; i >= 0; --i) {\n+ this.target.unregister(this.events[i], this, this.buttonClick);\n }\n- this.renderer = null;\n- this.geometryType = null;\n- this.drawn = null;\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n+ delete this.target;\n },\n \n /**\n- * Method: clone\n- * Create a clone of this layer.\n- * \n- * Note: Features of the layer are also cloned.\n+ * Method: getPressedButton\n+ * Get the pressed button, if any. Returns undefined if no button\n+ * was pressed.\n+ *\n+ * Arguments:\n+ * element - {DOMElement} The event target.\n *\n * Returns:\n- * {} An exact clone of this layer\n+ * {DOMElement} The button element, or undefined.\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.Vector(this.name, this.getOptions());\n- }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n- var features = this.features;\n- var len = features.length;\n- var clonedFeatures = new Array(len);\n- for (var i = 0; i < len; ++i) {\n- clonedFeatures[i] = features[i].clone();\n- }\n- obj.features = clonedFeatures;\n-\n- return obj;\n+ getPressedButton: function(element) {\n+ var depth = 3, // limit the search depth\n+ button;\n+ do {\n+ if (OpenLayers.Element.hasClass(element, \"olButton\")) {\n+ // hit!\n+ button = element;\n+ break;\n+ }\n+ element = element.parentNode;\n+ } while (--depth > 0 && element);\n+ return button;\n },\n \n /**\n- * Method: refresh\n- * Ask the layer to request features again and redraw them. Triggers\n- * the refresh event if the layer is in range and visible.\n+ * Method: ignore\n+ * Check for event target elements that should be ignored by OpenLayers.\n *\n * Parameters:\n- * obj - {Object} Optional object with properties for any listener of\n- * the refresh event.\n+ * element - {DOMElement} The event target.\n */\n- refresh: function(obj) {\n- if (this.calculateInRange() && this.visibility) {\n- this.events.triggerEvent(\"refresh\", obj);\n- }\n+ ignore: function(element) {\n+ var depth = 3,\n+ ignore = false;\n+ do {\n+ if (element.nodeName.toLowerCase() === 'a') {\n+ ignore = true;\n+ break;\n+ }\n+ element = element.parentNode;\n+ } while (--depth > 0 && element);\n+ return ignore;\n },\n \n- /** \n- * Method: assignRenderer\n- * Iterates through the available renderer implementations and selects \n- * and assigns the first one whose \"supported()\" function returns true.\n+ /**\n+ * Method: buttonClick\n+ * Check if a button was clicked, and fire the buttonclick event\n+ *\n+ * Parameters:\n+ * evt - {Event}\n */\n- assignRenderer: function() {\n- for (var i = 0, len = this.renderers.length; i < len; i++) {\n- var rendererClass = this.renderers[i];\n- var renderer = (typeof rendererClass == \"function\") ?\n- rendererClass :\n- OpenLayers.Renderer[rendererClass];\n- if (renderer && renderer.prototype.supported()) {\n- this.renderer = new renderer(this.div, this.rendererOptions);\n- break;\n+ buttonClick: function(evt) {\n+ var propagate = true,\n+ element = OpenLayers.Event.element(evt);\n+ if (element && (OpenLayers.Event.isLeftClick(evt) || !~evt.type.indexOf(\"mouse\"))) {\n+ // was a button pressed?\n+ var button = this.getPressedButton(element);\n+ if (button) {\n+ if (evt.type === \"keydown\") {\n+ switch (evt.keyCode) {\n+ case OpenLayers.Event.KEY_RETURN:\n+ case OpenLayers.Event.KEY_SPACE:\n+ this.target.triggerEvent(\"buttonclick\", {\n+ buttonElement: button\n+ });\n+ OpenLayers.Event.stop(evt);\n+ propagate = false;\n+ break;\n+ }\n+ } else if (this.startEvt) {\n+ if (this.completeRegEx.test(evt.type)) {\n+ var pos = OpenLayers.Util.pagePosition(button);\n+ var viewportElement = OpenLayers.Util.getViewportElement();\n+ var scrollTop = window.pageYOffset || viewportElement.scrollTop;\n+ var scrollLeft = window.pageXOffset || viewportElement.scrollLeft;\n+ pos[0] = pos[0] - scrollLeft;\n+ pos[1] = pos[1] - scrollTop;\n+\n+ this.target.triggerEvent(\"buttonclick\", {\n+ buttonElement: button,\n+ buttonXY: {\n+ x: this.startEvt.clientX - pos[0],\n+ y: this.startEvt.clientY - pos[1]\n+ }\n+ });\n+ }\n+ if (this.cancelRegEx.test(evt.type)) {\n+ delete this.startEvt;\n+ }\n+ OpenLayers.Event.stop(evt);\n+ propagate = false;\n+ }\n+ if (this.startRegEx.test(evt.type)) {\n+ this.startEvt = evt;\n+ OpenLayers.Event.stop(evt);\n+ propagate = false;\n+ }\n+ } else {\n+ propagate = !this.ignore(OpenLayers.Event.element(evt));\n+ delete this.startEvt;\n }\n }\n- },\n+ return propagate;\n+ }\n \n- /** \n- * Method: displayError \n- * Let the user know their browser isn't supported.\n+});\n+/* ======================================================================\n+ OpenLayers/Control/LayerSwitcher.js\n+ ====================================================================== */\n+\n+/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n+ * full list of contributors). Published under the 2-clause BSD license.\n+ * See license.txt in the OpenLayers distribution or repository for the\n+ * full text of the license. */\n+\n+/**\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Lang.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Events/buttonclick.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Control.LayerSwitcher\n+ * The LayerSwitcher control displays a table of contents for the map. This\n+ * allows the user interface to switch between BaseLasyers and to show or hide\n+ * Overlays. By default the switcher is shown minimized on the right edge of\n+ * the map, the user may expand it by clicking on the handle.\n+ *\n+ * To create the LayerSwitcher outside of the map, pass the Id of a html div\n+ * as the first argument to the constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Control.LayerSwitcher = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * Property: layerStates \n+ * {Array(Object)} Basically a copy of the \"state\" of the map's layers \n+ * the last time the control was drawn. We have this in order to avoid\n+ * unnecessarily redrawing the control.\n */\n- displayError: function() {\n- if (this.reportError) {\n- OpenLayers.Console.userError(OpenLayers.i18n(\"browserNotSupported\", {\n- renderers: this.renderers.join('\\n')\n- }));\n- }\n- },\n+ layerStates: null,\n \n- /** \n- * Method: setMap\n- * The layer has been added to the map. \n- * \n- * If there is no renderer set, the layer can't be used. Remove it.\n- * Otherwise, give the renderer a reference to the map and set its size.\n- * \n- * Parameters:\n- * map - {} \n+ // DOM Elements\n+\n+ /**\n+ * Property: layersDiv\n+ * {DOMElement}\n */\n- setMap: function(map) {\n- OpenLayers.Layer.prototype.setMap.apply(this, arguments);\n+ layersDiv: null,\n \n- if (!this.renderer) {\n- this.map.removeLayer(this);\n- } else {\n- this.renderer.map = this.map;\n+ /**\n+ * Property: baseLayersDiv\n+ * {DOMElement}\n+ */\n+ baseLayersDiv: null,\n+\n+ /**\n+ * Property: baseLayers\n+ * {Array(Object)}\n+ */\n+ baseLayers: null,\n \n- var newSize = this.map.getSize();\n- newSize.w = newSize.w * this.ratio;\n- newSize.h = newSize.h * this.ratio;\n- this.renderer.setSize(newSize);\n- }\n- },\n \n /**\n- * Method: afterAdd\n- * Called at the end of the map.addLayer sequence. At this point, the map\n- * will have a base layer. Any autoActivate strategies will be\n- * activated here.\n+ * Property: dataLbl\n+ * {DOMElement}\n */\n- afterAdd: function() {\n- if (this.strategies) {\n- var strategy, i, len;\n- for (i = 0, len = this.strategies.length; i < len; i++) {\n- strategy = this.strategies[i];\n- if (strategy.autoActivate) {\n- strategy.activate();\n- }\n- }\n- }\n- },\n+ dataLbl: null,\n \n /**\n- * Method: removeMap\n- * The layer has been removed from the map.\n- *\n- * Parameters:\n- * map - {}\n+ * Property: dataLayersDiv\n+ * {DOMElement}\n */\n- removeMap: function(map) {\n- this.drawn = false;\n- if (this.strategies) {\n- var strategy, i, len;\n- for (i = 0, len = this.strategies.length; i < len; i++) {\n- strategy = this.strategies[i];\n- if (strategy.autoActivate) {\n- strategy.deactivate();\n- }\n- }\n- }\n- },\n+ dataLayersDiv: null,\n \n /**\n- * Method: onMapResize\n- * Notify the renderer of the change in size. \n- * \n+ * Property: dataLayers\n+ * {Array(Object)}\n */\n- onMapResize: function() {\n- OpenLayers.Layer.prototype.onMapResize.apply(this, arguments);\n+ dataLayers: null,\n \n- var newSize = this.map.getSize();\n- newSize.w = newSize.w * this.ratio;\n- newSize.h = newSize.h * this.ratio;\n- this.renderer.setSize(newSize);\n- },\n \n /**\n- * Method: moveTo\n- * Reset the vector layer's div so that it once again is lined up with \n- * the map. Notify the renderer of the change of extent, and in the\n- * case of a change of zoom level (resolution), have the \n- * renderer redraw features.\n- * \n- * If the layer has not yet been drawn, cycle through the layer's \n- * features and draw each one.\n- * \n- * Parameters:\n- * bounds - {} \n- * zoomChanged - {Boolean} \n- * dragging - {Boolean} \n+ * Property: minimizeDiv\n+ * {DOMElement}\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- OpenLayers.Layer.prototype.moveTo.apply(this, arguments);\n+ minimizeDiv: null,\n \n- var coordSysUnchanged = true;\n- if (!dragging) {\n- this.renderer.root.style.visibility = 'hidden';\n+ /**\n+ * Property: maximizeDiv\n+ * {DOMElement}\n+ */\n+ maximizeDiv: null,\n \n- var viewSize = this.map.getSize(),\n- viewWidth = viewSize.w,\n- viewHeight = viewSize.h,\n- offsetLeft = (viewWidth / 2 * this.ratio) - viewWidth / 2,\n- offsetTop = (viewHeight / 2 * this.ratio) - viewHeight / 2;\n- offsetLeft += this.map.layerContainerOriginPx.x;\n- offsetLeft = -Math.round(offsetLeft);\n- offsetTop += this.map.layerContainerOriginPx.y;\n- offsetTop = -Math.round(offsetTop);\n+ /**\n+ * APIProperty: ascending\n+ * {Boolean}\n+ */\n+ ascending: true,\n \n- this.div.style.left = offsetLeft + 'px';\n- this.div.style.top = offsetTop + 'px';\n+ /**\n+ * Constructor: OpenLayers.Control.LayerSwitcher\n+ *\n+ * Parameters:\n+ * options - {Object}\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n+ this.layerStates = [];\n+ },\n \n- var extent = this.map.getExtent().scale(this.ratio);\n- coordSysUnchanged = this.renderer.setExtent(extent, zoomChanged);\n+ /**\n+ * APIMethod: destroy\n+ */\n+ destroy: function() {\n \n- this.renderer.root.style.visibility = 'visible';\n+ //clear out layers info and unregister their events\n+ this.clearLayersArray(\"base\");\n+ this.clearLayersArray(\"data\");\n \n- // Force a reflow on gecko based browsers to prevent jump/flicker.\n- // This seems to happen on only certain configurations; it was originally\n- // noticed in FF 2.0 and Linux.\n- if (OpenLayers.IS_GECKO === true) {\n- this.div.scrollLeft = this.div.scrollLeft;\n- }\n+ this.map.events.un({\n+ buttonclick: this.onButtonClick,\n+ addlayer: this.redraw,\n+ changelayer: this.redraw,\n+ removelayer: this.redraw,\n+ changebaselayer: this.redraw,\n+ scope: this\n+ });\n+ this.events.unregister(\"buttonclick\", this, this.onButtonClick);\n \n- if (!zoomChanged && coordSysUnchanged) {\n- for (var i in this.unrenderedFeatures) {\n- var feature = this.unrenderedFeatures[i];\n- this.drawFeature(feature);\n- }\n- }\n- }\n- if (!this.drawn || zoomChanged || !coordSysUnchanged) {\n- this.drawn = true;\n- var feature;\n- for (var i = 0, len = this.features.length; i < len; i++) {\n- this.renderer.locked = (i !== (len - 1));\n- feature = this.features[i];\n- this.drawFeature(feature);\n- }\n- }\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n- /** \n- * APIMethod: display\n- * Hide or show the Layer\n- * \n- * Parameters:\n- * display - {Boolean}\n+ /**\n+ * Method: setMap\n+ *\n+ * Properties:\n+ * map - {}\n */\n- display: function(display) {\n- OpenLayers.Layer.prototype.display.apply(this, arguments);\n- // we need to set the display style of the root in case it is attached\n- // to a foreign layer\n- var currentDisplay = this.div.style.display;\n- if (currentDisplay != this.renderer.root.style.display) {\n- this.renderer.root.style.display = currentDisplay;\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+\n+ this.map.events.on({\n+ addlayer: this.redraw,\n+ changelayer: this.redraw,\n+ removelayer: this.redraw,\n+ changebaselayer: this.redraw,\n+ scope: this\n+ });\n+ if (this.outsideViewport) {\n+ this.events.attachToElement(this.div);\n+ this.events.register(\"buttonclick\", this, this.onButtonClick);\n+ } else {\n+ this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n }\n },\n \n /**\n- * APIMethod: addFeatures\n- * Add Features to the layer.\n+ * Method: draw\n *\n- * Parameters:\n- * features - {Array()} \n- * options - {Object}\n+ * Returns:\n+ * {DOMElement} A reference to the DIV DOMElement containing the\n+ * switcher tabs.\n */\n- addFeatures: function(features, options) {\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n- }\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this);\n \n- var notify = !options || !options.silent;\n- if (notify) {\n- var event = {\n- features: features\n- };\n- var ret = this.events.triggerEvent(\"beforefeaturesadded\", event);\n- if (ret === false) {\n- return;\n- }\n- features = event.features;\n- }\n+ // create layout divs\n+ this.loadContents();\n \n- // Track successfully added features for featuresadded event, since\n- // beforefeatureadded can veto single features.\n- var featuresAdded = [];\n- for (var i = 0, len = features.length; i < len; i++) {\n- if (i != (features.length - 1)) {\n- this.renderer.locked = true;\n- } else {\n- this.renderer.locked = false;\n- }\n- var feature = features[i];\n+ // set mode to minimize\n+ if (!this.outsideViewport) {\n+ this.minimizeControl();\n+ }\n \n- if (this.geometryType &&\n- !(feature.geometry instanceof this.geometryType)) {\n- throw new TypeError('addFeatures: component should be an ' +\n- this.geometryType.prototype.CLASS_NAME);\n- }\n+ // populate div with current info\n+ this.redraw();\n \n- //give feature reference to its layer\n- feature.layer = this;\n+ return this.div;\n+ },\n \n- if (!feature.style && this.style) {\n- feature.style = OpenLayers.Util.extend({}, this.style);\n+ /**\n+ * Method: onButtonClick\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ */\n+ onButtonClick: function(evt) {\n+ var button = evt.buttonElement;\n+ if (button === this.minimizeDiv) {\n+ this.minimizeControl();\n+ } else if (button === this.maximizeDiv) {\n+ this.maximizeControl();\n+ } else if (button._layerSwitcher === this.id) {\n+ if (button[\"for\"]) {\n+ button = document.getElementById(button[\"for\"]);\n }\n-\n- if (notify) {\n- if (this.events.triggerEvent(\"beforefeatureadded\", {\n- feature: feature\n- }) === false) {\n- continue;\n+ if (!button.disabled) {\n+ if (button.type == \"radio\") {\n+ button.checked = true;\n+ this.map.setBaseLayer(this.map.getLayer(button._layer));\n+ } else {\n+ button.checked = !button.checked;\n+ this.updateMap();\n }\n- this.preFeatureInsert(feature);\n }\n+ }\n+ },\n \n- featuresAdded.push(feature);\n- this.features.push(feature);\n- this.drawFeature(feature);\n+ /**\n+ * Method: clearLayersArray\n+ * User specifies either \"base\" or \"data\". we then clear all the\n+ * corresponding listeners, the div, and reinitialize a new array.\n+ *\n+ * Parameters:\n+ * layersType - {String}\n+ */\n+ clearLayersArray: function(layersType) {\n+ this[layersType + \"LayersDiv\"].innerHTML = \"\";\n+ this[layersType + \"Layers\"] = [];\n+ },\n \n- if (notify) {\n- this.events.triggerEvent(\"featureadded\", {\n- feature: feature\n- });\n- this.onFeatureInsert(feature);\n- }\n+\n+ /**\n+ * Method: checkRedraw\n+ * Checks if the layer state has changed since the last redraw() call.\n+ *\n+ * Returns:\n+ * {Boolean} The layer state changed since the last redraw() call.\n+ */\n+ checkRedraw: function() {\n+ if (!this.layerStates.length ||\n+ (this.map.layers.length != this.layerStates.length)) {\n+ return true;\n }\n \n- if (notify) {\n- this.events.triggerEvent(\"featuresadded\", {\n- features: featuresAdded\n- });\n+ for (var i = 0, len = this.layerStates.length; i < len; i++) {\n+ var layerState = this.layerStates[i];\n+ var layer = this.map.layers[i];\n+ if ((layerState.name != layer.name) ||\n+ (layerState.inRange != layer.inRange) ||\n+ (layerState.id != layer.id) ||\n+ (layerState.visibility != layer.visibility)) {\n+ return true;\n+ }\n }\n- },\n \n+ return false;\n+ },\n \n /**\n- * APIMethod: removeFeatures\n- * Remove features from the layer. This erases any drawn features and\n- * removes them from the layer's control. The beforefeatureremoved\n- * and featureremoved events will be triggered for each feature. The\n- * featuresremoved event will be triggered after all features have\n- * been removed. To supress event triggering, use the silent option.\n- * \n- * Parameters:\n- * features - {Array()} List of features to be\n- * removed.\n- * options - {Object} Optional properties for changing behavior of the\n- * removal.\n+ * Method: redraw\n+ * Goes through and takes the current state of the Map and rebuilds the\n+ * control to display that state. Groups base layers into a\n+ * radio-button group and lists each data layer with a checkbox.\n *\n- * Valid options:\n- * silent - {Boolean} Supress event triggering. Default is false.\n+ * Returns:\n+ * {DOMElement} A reference to the DIV DOMElement containing the control\n */\n- removeFeatures: function(features, options) {\n- if (!features || features.length === 0) {\n- return;\n- }\n- if (features === this.features) {\n- return this.removeAllFeatures(options);\n+ redraw: function() {\n+ //if the state hasn't changed since last redraw, no need\n+ // to do anything. Just return the existing div.\n+ if (!this.checkRedraw()) {\n+ return this.div;\n }\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n+\n+ //clear out previous layers\n+ this.clearLayersArray(\"base\");\n+ this.clearLayersArray(\"data\");\n+\n+ var containsOverlays = false;\n+ var containsBaseLayers = false;\n+\n+ // Save state -- for checking layer if the map state changed.\n+ // We save this before redrawing, because in the process of redrawing\n+ // we will trigger more visibility changes, and we want to not redraw\n+ // and enter an infinite loop.\n+ var len = this.map.layers.length;\n+ this.layerStates = new Array(len);\n+ for (var i = 0; i < len; i++) {\n+ var layer = this.map.layers[i];\n+ this.layerStates[i] = {\n+ 'name': layer.name,\n+ 'visibility': layer.visibility,\n+ 'inRange': layer.inRange,\n+ 'id': layer.id\n+ };\n }\n- if (features === this.selectedFeatures) {\n- features = features.slice();\n+\n+ var layers = this.map.layers.slice();\n+ if (!this.ascending) {\n+ layers.reverse();\n }\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ var layer = layers[i];\n+ var baseLayer = layer.isBaseLayer;\n \n- var notify = !options || !options.silent;\n+ if (layer.displayInLayerSwitcher) {\n \n- if (notify) {\n- this.events.triggerEvent(\n- \"beforefeaturesremoved\", {\n- features: features\n+ if (baseLayer) {\n+ containsBaseLayers = true;\n+ } else {\n+ containsOverlays = true;\n }\n- );\n- }\n \n- for (var i = features.length - 1; i >= 0; i--) {\n- // We remain locked so long as we're not at 0\n- // and the 'next' feature has a geometry. We do the geometry check\n- // because if all the features after the current one are 'null', we\n- // won't call eraseGeometry, so we break the 'renderer functions\n- // will always be called with locked=false *last*' rule. The end result\n- // is a possible gratiutious unlocking to save a loop through the rest \n- // of the list checking the remaining features every time. So long as\n- // null geoms are rare, this is probably okay. \n- if (i != 0 && features[i - 1].geometry) {\n- this.renderer.locked = true;\n- } else {\n- this.renderer.locked = false;\n- }\n+ // only check a baselayer if it is *the* baselayer, check data\n+ // layers if they are visible\n+ var checked = (baseLayer) ? (layer == this.map.baseLayer) :\n+ layer.getVisibility();\n \n- var feature = features[i];\n- delete this.unrenderedFeatures[feature.id];\n+ // create input element\n+ var inputElem = document.createElement(\"input\"),\n+ // The input shall have an id attribute so we can use\n+ // labels to interact with them.\n+ inputId = OpenLayers.Util.createUniqueID(\n+ this.id + \"_input_\"\n+ );\n \n- if (notify) {\n- this.events.triggerEvent(\"beforefeatureremoved\", {\n- feature: feature\n- });\n- }\n+ inputElem.id = inputId;\n+ inputElem.name = (baseLayer) ? this.id + \"_baseLayers\" : layer.name;\n+ inputElem.type = (baseLayer) ? \"radio\" : \"checkbox\";\n+ inputElem.value = layer.name;\n+ inputElem.checked = checked;\n+ inputElem.defaultChecked = checked;\n+ inputElem.className = \"olButton\";\n+ inputElem._layer = layer.id;\n+ inputElem._layerSwitcher = this.id;\n \n- this.features = OpenLayers.Util.removeItem(this.features, feature);\n- // feature has no layer at this point\n- feature.layer = null;\n+ if (!baseLayer && !layer.inRange) {\n+ inputElem.disabled = true;\n+ }\n \n- if (feature.geometry) {\n- this.renderer.eraseFeatures(feature);\n- }\n+ // create span\n+ var labelSpan = document.createElement(\"label\");\n+ // this isn't the DOM attribute 'for', but an arbitrary name we\n+ // use to find the appropriate input element in \n+ labelSpan[\"for\"] = inputElem.id;\n+ OpenLayers.Element.addClass(labelSpan, \"labelSpan olButton\");\n+ labelSpan._layer = layer.id;\n+ labelSpan._layerSwitcher = this.id;\n+ if (!baseLayer && !layer.inRange) {\n+ labelSpan.style.color = \"gray\";\n+ }\n+ labelSpan.innerHTML = layer.name;\n+ labelSpan.style.verticalAlign = (baseLayer) ? \"bottom\" :\n+ \"baseline\";\n+ // create line break\n+ var br = document.createElement(\"br\");\n \n- //in the case that this feature is one of the selected features, \n- // remove it from that array as well.\n- if (OpenLayers.Util.indexOf(this.selectedFeatures, feature) != -1) {\n- OpenLayers.Util.removeItem(this.selectedFeatures, feature);\n- }\n \n- if (notify) {\n- this.events.triggerEvent(\"featureremoved\", {\n- feature: feature\n+ var groupArray = (baseLayer) ? this.baseLayers :\n+ this.dataLayers;\n+ groupArray.push({\n+ 'layer': layer,\n+ 'inputElem': inputElem,\n+ 'labelSpan': labelSpan\n });\n- }\n- }\n \n- if (notify) {\n- this.events.triggerEvent(\"featuresremoved\", {\n- features: features\n- });\n- }\n- },\n \n- /** \n- * APIMethod: removeAllFeatures\n- * Remove all features from the layer.\n- *\n- * Parameters:\n- * options - {Object} Optional properties for changing behavior of the\n- * removal.\n- *\n- * Valid options:\n- * silent - {Boolean} Supress event triggering. Default is false.\n- */\n- removeAllFeatures: function(options) {\n- var notify = !options || !options.silent;\n- var features = this.features;\n- if (notify) {\n- this.events.triggerEvent(\n- \"beforefeaturesremoved\", {\n- features: features\n- }\n- );\n- }\n- var feature;\n- for (var i = features.length - 1; i >= 0; i--) {\n- feature = features[i];\n- if (notify) {\n- this.events.triggerEvent(\"beforefeatureremoved\", {\n- feature: feature\n- });\n- }\n- feature.layer = null;\n- if (notify) {\n- this.events.triggerEvent(\"featureremoved\", {\n- feature: feature\n- });\n+ var groupDiv = (baseLayer) ? this.baseLayersDiv :\n+ this.dataLayersDiv;\n+ groupDiv.appendChild(inputElem);\n+ groupDiv.appendChild(labelSpan);\n+ groupDiv.appendChild(br);\n }\n }\n- this.renderer.clear();\n- this.features = [];\n- this.unrenderedFeatures = {};\n- this.selectedFeatures = [];\n- if (notify) {\n- this.events.triggerEvent(\"featuresremoved\", {\n- features: features\n- });\n- }\n- },\n \n- /**\n- * APIMethod: destroyFeatures\n- * Erase and destroy features on the layer.\n- *\n- * Parameters:\n- * features - {Array()} An optional array of\n- * features to destroy. If not supplied, all features on the layer\n- * will be destroyed.\n- * options - {Object}\n- */\n- destroyFeatures: function(features, options) {\n- var all = (features == undefined); // evaluates to true if\n- // features is null\n- if (all) {\n- features = this.features;\n- }\n- if (features) {\n- this.removeFeatures(features, options);\n- for (var i = features.length - 1; i >= 0; i--) {\n- features[i].destroy();\n- }\n- }\n+ // if no overlays, dont display the overlay label\n+ this.dataLbl.style.display = (containsOverlays) ? \"\" : \"none\";\n+\n+ // if no baselayers, dont display the baselayer label\n+ this.baseLbl.style.display = (containsBaseLayers) ? \"\" : \"none\";\n+\n+ return this.div;\n },\n \n /**\n- * APIMethod: drawFeature\n- * Draw (or redraw) a feature on the layer. If the optional style argument\n- * is included, this style will be used. If no style is included, the\n- * feature's style will be used. If the feature doesn't have a style,\n- * the layer's style will be used.\n- * \n- * This function is not designed to be used when adding features to \n- * the layer (use addFeatures instead). It is meant to be used when\n- * the style of a feature has changed, or in some other way needs to \n- * visually updated *after* it has already been added to a layer. You\n- * must add the feature to the layer for most layer-related events to \n- * happen.\n- *\n- * Parameters: \n- * feature - {} \n- * style - {String | Object} Named render intent or full symbolizer object.\n+ * Method: updateMap\n+ * Cycles through the loaded data and base layer input arrays and makes\n+ * the necessary calls to the Map object such that that the map's\n+ * visual state corresponds to what the user has selected in\n+ * the control.\n */\n- drawFeature: function(feature, style) {\n- // don't try to draw the feature with the renderer if the layer is not \n- // drawn itself\n- if (!this.drawn) {\n- return;\n- }\n- if (typeof style != \"object\") {\n- if (!style && feature.state === OpenLayers.State.DELETE) {\n- style = \"delete\";\n- }\n- var renderIntent = style || feature.renderIntent;\n- style = feature.style || this.style;\n- if (!style) {\n- style = this.styleMap.createSymbolizer(feature, renderIntent);\n+ updateMap: function() {\n+\n+ // set the newly selected base layer\n+ for (var i = 0, len = this.baseLayers.length; i < len; i++) {\n+ var layerEntry = this.baseLayers[i];\n+ if (layerEntry.inputElem.checked) {\n+ this.map.setBaseLayer(layerEntry.layer, false);\n }\n }\n \n- var drawn = this.renderer.drawFeature(feature, style);\n- //TODO remove the check for null when we get rid of Renderer.SVG\n- if (drawn === false || drawn === null) {\n- this.unrenderedFeatures[feature.id] = feature;\n- } else {\n- delete this.unrenderedFeatures[feature.id];\n+ // set the correct visibilities for the overlays\n+ for (var i = 0, len = this.dataLayers.length; i < len; i++) {\n+ var layerEntry = this.dataLayers[i];\n+ layerEntry.layer.setVisibility(layerEntry.inputElem.checked);\n }\n- },\n \n- /**\n- * Method: eraseFeatures\n- * Erase features from the layer.\n- *\n- * Parameters:\n- * features - {Array()} \n- */\n- eraseFeatures: function(features) {\n- this.renderer.eraseFeatures(features);\n },\n \n /**\n- * Method: getFeatureFromEvent\n- * Given an event, return a feature if the event occurred over one.\n- * Otherwise, return null.\n+ * Method: maximizeControl\n+ * Set up the labels and divs for the control\n *\n * Parameters:\n- * evt - {Event} \n- *\n- * Returns:\n- * {} A feature if one was under the event.\n+ * e - {Event}\n */\n- getFeatureFromEvent: function(evt) {\n- if (!this.renderer) {\n- throw new Error('getFeatureFromEvent called on layer with no ' +\n- 'renderer. This usually means you destroyed a ' +\n- 'layer, but not some handler which is associated ' +\n- 'with it.');\n- }\n- var feature = null;\n- var featureId = this.renderer.getFeatureIdFromEvent(evt);\n- if (featureId) {\n- if (typeof featureId === \"string\") {\n- feature = this.getFeatureById(featureId);\n- } else {\n- feature = featureId;\n- }\n+ maximizeControl: function(e) {\n+\n+ // set the div's width and height to empty values, so\n+ // the div dimensions can be controlled by CSS\n+ this.div.style.width = \"\";\n+ this.div.style.height = \"\";\n+\n+ this.showControls(false);\n+\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n }\n- return feature;\n },\n \n /**\n- * APIMethod: getFeatureBy\n- * Given a property value, return the feature if it exists in the features array\n+ * Method: minimizeControl\n+ * Hide all the contents of the control, shrink the size,\n+ * add the maximize icon\n *\n * Parameters:\n- * property - {String}\n- * value - {String}\n- *\n- * Returns:\n- * {} A feature corresponding to the given\n- * property value or null if there is no such feature.\n+ * e - {Event}\n */\n- getFeatureBy: function(property, value) {\n- //TBD - would it be more efficient to use a hash for this.features?\n- var feature = null;\n- for (var i = 0, len = this.features.length; i < len; ++i) {\n- if (this.features[i][property] == value) {\n- feature = this.features[i];\n- break;\n- }\n+ minimizeControl: function(e) {\n+\n+ // to minimize the control we set its div's width\n+ // and height to 0px, we cannot just set \"display\"\n+ // to \"none\" because it would hide the maximize\n+ // div\n+ this.div.style.width = \"0px\";\n+ this.div.style.height = \"0px\";\n+\n+ this.showControls(true);\n+\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n }\n- return feature;\n },\n \n /**\n- * APIMethod: getFeatureById\n- * Given a feature id, return the feature if it exists in the features array\n+ * Method: showControls\n+ * Hide/Show all LayerSwitcher controls depending on whether we are\n+ * minimized or not\n *\n * Parameters:\n- * featureId - {String}\n- *\n- * Returns:\n- * {} A feature corresponding to the given\n- * featureId or null if there is no such feature.\n+ * minimize - {Boolean}\n */\n- getFeatureById: function(featureId) {\n- return this.getFeatureBy('id', featureId);\n- },\n+ showControls: function(minimize) {\n \n- /**\n- * APIMethod: getFeatureByFid\n- * Given a feature fid, return the feature if it exists in the features array\n- *\n- * Parameters:\n- * featureFid - {String}\n- *\n- * Returns:\n- * {} A feature corresponding to the given\n- * featureFid or null if there is no such feature.\n- */\n- getFeatureByFid: function(featureFid) {\n- return this.getFeatureBy('fid', featureFid);\n+ this.maximizeDiv.style.display = minimize ? \"\" : \"none\";\n+ this.minimizeDiv.style.display = minimize ? \"none\" : \"\";\n+\n+ this.layersDiv.style.display = minimize ? \"none\" : \"\";\n },\n \n /**\n- * APIMethod: getFeaturesByAttribute\n- * Returns an array of features that have the given attribute key set to the\n- * given value. Comparison of attribute values takes care of datatypes, e.g.\n- * the string '1234' is not equal to the number 1234.\n- *\n- * Parameters:\n- * attrName - {String}\n- * attrValue - {Mixed}\n- *\n- * Returns:\n- * Array({}) An array of features that have the \n- * passed named attribute set to the given value.\n+ * Method: loadContents\n+ * Set up the labels and divs for the control\n */\n- getFeaturesByAttribute: function(attrName, attrValue) {\n- var i,\n- feature,\n- len = this.features.length,\n- foundFeatures = [];\n- for (i = 0; i < len; i++) {\n- feature = this.features[i];\n- if (feature && feature.attributes) {\n- if (feature.attributes[attrName] === attrValue) {\n- foundFeatures.push(feature);\n- }\n- }\n- }\n- return foundFeatures;\n- },\n+ loadContents: function() {\n \n- /**\n- * Unselect the selected features\n- * i.e. clears the featureSelection array\n- * change the style back\n- clearSelection: function() {\n+ // layers list div\n+ this.layersDiv = document.createElement(\"div\");\n+ this.layersDiv.id = this.id + \"_layersDiv\";\n+ OpenLayers.Element.addClass(this.layersDiv, \"layersDiv\");\n \n- var vectorLayer = this.map.vectorLayer;\n- for (var i = 0; i < this.map.featureSelection.length; i++) {\n- var featureSelection = this.map.featureSelection[i];\n- vectorLayer.drawFeature(featureSelection, vectorLayer.style);\n- }\n- this.map.featureSelection = [];\n- },\n- */\n+ this.baseLbl = document.createElement(\"div\");\n+ this.baseLbl.innerHTML = OpenLayers.i18n(\"Base Layer\");\n+ OpenLayers.Element.addClass(this.baseLbl, \"baseLbl\");\n \n+ this.baseLayersDiv = document.createElement(\"div\");\n+ OpenLayers.Element.addClass(this.baseLayersDiv, \"baseLayersDiv\");\n \n- /**\n- * APIMethod: onFeatureInsert\n- * method called after a feature is inserted.\n- * Does nothing by default. Override this if you\n- * need to do something on feature updates.\n- *\n- * Parameters: \n- * feature - {} \n- */\n- onFeatureInsert: function(feature) {},\n+ this.dataLbl = document.createElement(\"div\");\n+ this.dataLbl.innerHTML = OpenLayers.i18n(\"Overlays\");\n+ OpenLayers.Element.addClass(this.dataLbl, \"dataLbl\");\n \n- /**\n- * APIMethod: preFeatureInsert\n- * method called before a feature is inserted.\n- * Does nothing by default. Override this if you\n- * need to do something when features are first added to the\n- * layer, but before they are drawn, such as adjust the style.\n- *\n- * Parameters:\n- * feature - {} \n- */\n- preFeatureInsert: function(feature) {},\n+ this.dataLayersDiv = document.createElement(\"div\");\n+ OpenLayers.Element.addClass(this.dataLayersDiv, \"dataLayersDiv\");\n \n- /** \n- * APIMethod: getDataExtent\n- * Calculates the max extent which includes all of the features.\n- * \n- * Returns:\n- * {} or null if the layer has no features with\n- * geometries.\n- */\n- getDataExtent: function() {\n- var maxExtent = null;\n- var features = this.features;\n- if (features && (features.length > 0)) {\n- var geometry = null;\n- for (var i = 0, len = features.length; i < len; i++) {\n- geometry = features[i].geometry;\n- if (geometry) {\n- if (maxExtent === null) {\n- maxExtent = new OpenLayers.Bounds();\n- }\n- maxExtent.extend(geometry.getBounds());\n- }\n- }\n+ if (this.ascending) {\n+ this.layersDiv.appendChild(this.baseLbl);\n+ this.layersDiv.appendChild(this.baseLayersDiv);\n+ this.layersDiv.appendChild(this.dataLbl);\n+ this.layersDiv.appendChild(this.dataLayersDiv);\n+ } else {\n+ this.layersDiv.appendChild(this.dataLbl);\n+ this.layersDiv.appendChild(this.dataLayersDiv);\n+ this.layersDiv.appendChild(this.baseLbl);\n+ this.layersDiv.appendChild(this.baseLayersDiv);\n }\n- return maxExtent;\n+\n+ this.div.appendChild(this.layersDiv);\n+\n+ // maximize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');\n+ this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ \"OpenLayers_Control_MaximizeDiv\",\n+ null,\n+ null,\n+ img,\n+ \"absolute\");\n+ OpenLayers.Element.addClass(this.maximizeDiv, \"maximizeDiv olButton\");\n+ this.maximizeDiv.style.display = \"none\";\n+\n+ this.div.appendChild(this.maximizeDiv);\n+\n+ // minimize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');\n+ this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ \"OpenLayers_Control_MinimizeDiv\",\n+ null,\n+ null,\n+ img,\n+ \"absolute\");\n+ OpenLayers.Element.addClass(this.minimizeDiv, \"minimizeDiv olButton\");\n+ this.minimizeDiv.style.display = \"none\";\n+\n+ this.div.appendChild(this.minimizeDiv);\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.Vector\"\n+ CLASS_NAME: \"OpenLayers.Control.LayerSwitcher\"\n });\n /* ======================================================================\n- OpenLayers/Layer/PointTrack.js\n+ OpenLayers/Control/PanZoom.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Layer/Vector.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Events/buttonclick.js\n */\n \n /**\n- * Class: OpenLayers.Layer.PointTrack\n- * Vector layer to display ordered point features as a line, creating one\n- * LineString feature for each pair of two points.\n+ * Class: OpenLayers.Control.PanZoom\n+ * The PanZoom is a visible control, composed of a\n+ * and a . By\n+ * default it is drawn in the upper left corner of the map.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.PointTrack = OpenLayers.Class(OpenLayers.Layer.Vector, {\n+OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * APIProperty: slideFactor\n+ * {Integer} Number of pixels by which we'll pan the map in any direction \n+ * on clicking the arrow buttons. If you want to pan by some ratio\n+ * of the map dimensions, use instead.\n+ */\n+ slideFactor: 50,\n+\n+ /** \n+ * APIProperty: slideRatio\n+ * {Number} The fraction of map width/height by which we'll pan the map \n+ * on clicking the arrow buttons. Default is null. If set, will\n+ * override . E.g. if slideRatio is .5, then the Pan Up\n+ * button will pan up half the map height. \n+ */\n+ slideRatio: null,\n+\n+ /** \n+ * Property: buttons\n+ * {Array(DOMElement)} Array of Button Divs \n+ */\n+ buttons: null,\n+\n+ /** \n+ * Property: position\n+ * {} \n+ */\n+ position: null,\n \n /**\n- * APIProperty: dataFrom\n- * {} or\n- * {} optional. If the lines\n- * should get the data/attributes from one of the two points it is\n- * composed of, which one should it be?\n+ * Constructor: OpenLayers.Control.PanZoom\n+ * \n+ * Parameters:\n+ * options - {Object}\n */\n- dataFrom: null,\n+ initialize: function(options) {\n+ this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X,\n+ OpenLayers.Control.PanZoom.Y);\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n+ },\n \n /**\n- * APIProperty: styleFrom\n- * {} or\n- * {} optional. If the lines\n- * should get the style from one of the two points it is composed of,\n- * which one should it be?\n+ * APIMethod: destroy\n */\n- styleFrom: null,\n+ destroy: function() {\n+ if (this.map) {\n+ this.map.events.unregister(\"buttonclick\", this, this.onButtonClick);\n+ }\n+ this.removeButtons();\n+ this.buttons = null;\n+ this.position = null;\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ },\n+\n+ /** \n+ * Method: setMap\n+ *\n+ * Properties:\n+ * map - {} \n+ */\n+ setMap: function(map) {\n+ OpenLayers.Control.prototype.setMap.apply(this, arguments);\n+ this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n+ },\n \n /**\n- * Constructor: OpenLayers.PointTrack\n- * Constructor for a new OpenLayers.PointTrack instance.\n+ * Method: draw\n *\n * Parameters:\n- * name - {String} name of the layer\n- * options - {Object} Optional object with properties to tag onto the\n- * instance.\n+ * px - {} \n+ * \n+ * Returns:\n+ * {DOMElement} A reference to the container div for the PanZoom control.\n */\n+ draw: function(px) {\n+ // initialize our internal div\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ px = this.position;\n+\n+ // place the controls\n+ this.buttons = [];\n+\n+ var sz = {\n+ w: 18,\n+ h: 18\n+ };\n+ var centered = new OpenLayers.Pixel(px.x + sz.w / 2, px.y);\n+\n+ this._addButton(\"panup\", \"north-mini.png\", centered, sz);\n+ px.y = centered.y + sz.h;\n+ this._addButton(\"panleft\", \"west-mini.png\", px, sz);\n+ this._addButton(\"panright\", \"east-mini.png\", px.add(sz.w, 0), sz);\n+ this._addButton(\"pandown\", \"south-mini.png\",\n+ centered.add(0, sz.h * 2), sz);\n+ this._addButton(\"zoomin\", \"zoom-plus-mini.png\",\n+ centered.add(0, sz.h * 3 + 5), sz);\n+ this._addButton(\"zoomworld\", \"zoom-world-mini.png\",\n+ centered.add(0, sz.h * 4 + 5), sz);\n+ this._addButton(\"zoomout\", \"zoom-minus-mini.png\",\n+ centered.add(0, sz.h * 5 + 5), sz);\n+ return this.div;\n+ },\n \n /**\n- * APIMethod: addNodes\n- * Adds point features that will be used to create lines from, using point\n- * pairs. The first point of a pair will be the source node, the second\n- * will be the target node.\n+ * Method: _addButton\n * \n * Parameters:\n- * pointFeatures - {Array()}\n- * options - {Object}\n+ * id - {String} \n+ * img - {String} \n+ * xy - {} \n+ * sz - {} \n * \n- * Supported options:\n- * silent - {Boolean} true to suppress (before)feature(s)added events\n+ * Returns:\n+ * {DOMElement} A Div (an alphaImageDiv, to be precise) that contains the\n+ * image of the button, and has all the proper event handlers set.\n */\n- addNodes: function(pointFeatures, options) {\n- if (pointFeatures.length < 2) {\n- throw new Error(\"At least two point features have to be added to \" +\n- \"create a line from\");\n- }\n-\n- var lines = new Array(pointFeatures.length - 1);\n-\n- var pointFeature, startPoint, endPoint;\n- for (var i = 0, len = pointFeatures.length; i < len; i++) {\n- pointFeature = pointFeatures[i];\n- endPoint = pointFeature.geometry;\n+ _addButton: function(id, img, xy, sz) {\n+ var imgLocation = OpenLayers.Util.getImageLocation(img);\n+ var btn = OpenLayers.Util.createAlphaImageDiv(\n+ this.id + \"_\" + id,\n+ xy, sz, imgLocation, \"absolute\");\n+ btn.style.cursor = \"pointer\";\n+ //we want to add the outer div\n+ this.div.appendChild(btn);\n+ btn.action = id;\n+ btn.className = \"olButton\";\n \n- if (!endPoint) {\n- var lonlat = pointFeature.lonlat;\n- endPoint = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);\n- } else if (endPoint.CLASS_NAME != \"OpenLayers.Geometry.Point\") {\n- throw new TypeError(\"Only features with point geometries are supported.\");\n- }\n+ //we want to remember/reference the outer div\n+ this.buttons.push(btn);\n+ return btn;\n+ },\n \n- if (i > 0) {\n- var attributes = (this.dataFrom != null) ?\n- (pointFeatures[i + this.dataFrom].data ||\n- pointFeatures[i + this.dataFrom].attributes) :\n- null;\n- var style = (this.styleFrom != null) ?\n- (pointFeatures[i + this.styleFrom].style) :\n- null;\n- var line = new OpenLayers.Geometry.LineString([startPoint,\n- endPoint\n- ]);\n+ /**\n+ * Method: _removeButton\n+ * \n+ * Parameters:\n+ * btn - {Object}\n+ */\n+ _removeButton: function(btn) {\n+ this.div.removeChild(btn);\n+ OpenLayers.Util.removeItem(this.buttons, btn);\n+ },\n \n- lines[i - 1] = new OpenLayers.Feature.Vector(line, attributes,\n- style);\n- }\n+ /**\n+ * Method: removeButtons\n+ */\n+ removeButtons: function() {\n+ for (var i = this.buttons.length - 1; i >= 0; --i) {\n+ this._removeButton(this.buttons[i]);\n+ }\n+ },\n \n- startPoint = endPoint;\n+ /**\n+ * Method: onButtonClick\n+ *\n+ * Parameters:\n+ * evt - {Event}\n+ */\n+ onButtonClick: function(evt) {\n+ var btn = evt.buttonElement;\n+ switch (btn.action) {\n+ case \"panup\":\n+ this.map.pan(0, -this.getSlideFactor(\"h\"));\n+ break;\n+ case \"pandown\":\n+ this.map.pan(0, this.getSlideFactor(\"h\"));\n+ break;\n+ case \"panleft\":\n+ this.map.pan(-this.getSlideFactor(\"w\"), 0);\n+ break;\n+ case \"panright\":\n+ this.map.pan(this.getSlideFactor(\"w\"), 0);\n+ break;\n+ case \"zoomin\":\n+ this.map.zoomIn();\n+ break;\n+ case \"zoomout\":\n+ this.map.zoomOut();\n+ break;\n+ case \"zoomworld\":\n+ this.map.zoomToMaxExtent();\n+ break;\n }\n+ },\n \n- this.addFeatures(lines, options);\n+ /**\n+ * Method: getSlideFactor\n+ *\n+ * Parameters:\n+ * dim - {String} \"w\" or \"h\" (for width or height).\n+ *\n+ * Returns:\n+ * {Number} The slide factor for panning in the requested direction.\n+ */\n+ getSlideFactor: function(dim) {\n+ return this.slideRatio ?\n+ this.map.getSize()[dim] * this.slideRatio :\n+ this.slideFactor;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.PointTrack\"\n+ CLASS_NAME: \"OpenLayers.Control.PanZoom\"\n });\n \n /**\n- * Constant: OpenLayers.Layer.PointTrack.SOURCE_NODE\n- * {Number} value for and\n- * \n- */\n-OpenLayers.Layer.PointTrack.SOURCE_NODE = -1;\n-\n-/**\n- * Constant: OpenLayers.Layer.PointTrack.TARGET_NODE\n- * {Number} value for and\n- * \n+ * Constant: X\n+ * {Integer}\n */\n-OpenLayers.Layer.PointTrack.TARGET_NODE = 0;\n+OpenLayers.Control.PanZoom.X = 4;\n \n /**\n- * Constant: OpenLayers.Layer.PointTrack.dataFrom\n- * {Object} with the following keys - *deprecated*\n- * - SOURCE_NODE: take data/attributes from the source node of the line\n- * - TARGET_NODE: take data/attributes from the target node of the line\n+ * Constant: Y\n+ * {Integer}\n */\n-OpenLayers.Layer.PointTrack.dataFrom = {\n- 'SOURCE_NODE': -1,\n- 'TARGET_NODE': 0\n-};\n+OpenLayers.Control.PanZoom.Y = 4;\n /* ======================================================================\n- OpenLayers/Layer/EventPane.js\n+ OpenLayers/Control/OverviewMap.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n-/**\n- * @requires OpenLayers/Layer.js\n- * @requires OpenLayers/Util.js\n+/** \n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/BaseTypes.js\n+ * @requires OpenLayers/Events/buttonclick.js\n+ * @requires OpenLayers/Map.js\n+ * @requires OpenLayers/Handler/Click.js\n+ * @requires OpenLayers/Handler/Drag.js\n */\n \n /**\n- * Class: OpenLayers.Layer.EventPane\n- * Base class for 3rd party layers, providing a DOM element which isolates\n- * the 3rd-party layer from mouse events.\n- * Only used by Google layers.\n- *\n- * Automatically instantiated by the Google constructor, and not usually instantiated directly.\n+ * Class: OpenLayers.Control.OverviewMap\n+ * The OverMap control creates a small overview map, useful to display the \n+ * extent of a zoomed map and your main map and provide additional \n+ * navigation options to the User. By default the overview map is drawn in\n+ * the lower right corner of the main map. Create a new overview map with the\n+ * constructor.\n *\n- * Create a new event pane layer with the\n- * constructor.\n- * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, {\n+OpenLayers.Control.OverviewMap = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * APIProperty: smoothDragPan\n- * {Boolean} smoothDragPan determines whether non-public/internal API\n- * methods are used for better performance while dragging EventPane \n- * layers. When not in sphericalMercator mode, the smoother dragging \n- * doesn't actually move north/south directly with the number of \n- * pixels moved, resulting in a slight offset when you drag your mouse \n- * north south with this option on. If this visual disparity bothers \n- * you, you should turn this option off, or use spherical mercator. \n- * Default is on.\n+ * Property: element\n+ * {DOMElement} The DOM element that contains the overview map\n */\n- smoothDragPan: true,\n+ element: null,\n \n /**\n- * Property: isBaseLayer\n- * {Boolean} EventPaned layers are always base layers, by necessity.\n+ * APIProperty: ovmap\n+ * {} A reference to the overview map itself.\n */\n- isBaseLayer: true,\n+ ovmap: null,\n \n /**\n- * APIProperty: isFixed\n- * {Boolean} EventPaned layers are fixed by default.\n+ * APIProperty: size\n+ * {} The overvew map size in pixels. Note that this is\n+ * the size of the map itself - the element that contains the map (default\n+ * class name olControlOverviewMapElement) may have padding or other style\n+ * attributes added via CSS.\n */\n- isFixed: true,\n+ size: {\n+ w: 180,\n+ h: 90\n+ },\n \n /**\n- * Property: pane\n- * {DOMElement} A reference to the element that controls the events.\n+ * APIProperty: layers\n+ * {Array()} Ordered list of layers in the overview map.\n+ * If none are sent at construction, the base layer for the main map is used.\n */\n- pane: null,\n+ layers: null,\n \n+ /**\n+ * APIProperty: minRectSize\n+ * {Integer} The minimum width or height (in pixels) of the extent\n+ * rectangle on the overview map. When the extent rectangle reaches\n+ * this size, it will be replaced depending on the value of the\n+ * property. Default is 15 pixels.\n+ */\n+ minRectSize: 15,\n \n /**\n- * Property: mapObject\n- * {Object} This is the object which will be used to load the 3rd party library\n- * in the case of the google layer, this will be of type GMap, \n- * in the case of the ve layer, this will be of type VEMap\n+ * APIProperty: minRectDisplayClass\n+ * {String} Replacement style class name for the extent rectangle when\n+ * is reached. This string will be suffixed on to the\n+ * displayClass. Default is \"RectReplacement\".\n+ *\n+ * Example CSS declaration:\n+ * (code)\n+ * .olControlOverviewMapRectReplacement {\n+ * overflow: hidden;\n+ * cursor: move;\n+ * background-image: url(\"img/overview_replacement.gif\");\n+ * background-repeat: no-repeat;\n+ * background-position: center;\n+ * }\n+ * (end)\n */\n- mapObject: null,\n+ minRectDisplayClass: \"RectReplacement\",\n \n+ /**\n+ * APIProperty: minRatio\n+ * {Float} The ratio of the overview map resolution to the main map\n+ * resolution at which to zoom farther out on the overview map.\n+ */\n+ minRatio: 8,\n \n /**\n- * Constructor: OpenLayers.Layer.EventPane\n- * Create a new event pane layer\n- *\n- * Parameters:\n- * name - {String}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * APIProperty: maxRatio\n+ * {Float} The ratio of the overview map resolution to the main map\n+ * resolution at which to zoom farther in on the overview map.\n */\n- initialize: function(name, options) {\n- OpenLayers.Layer.prototype.initialize.apply(this, arguments);\n- if (this.pane == null) {\n- this.pane = OpenLayers.Util.createDiv(this.div.id + \"_EventPane\");\n- }\n- },\n+ maxRatio: 32,\n \n /**\n- * APIMethod: destroy\n- * Deconstruct this layer.\n+ * APIProperty: mapOptions\n+ * {Object} An object containing any non-default properties to be sent to\n+ * the overview map's map constructor. These should include any\n+ * non-default options that the main map was constructed with.\n */\n- destroy: function() {\n- this.mapObject = null;\n- this.pane = null;\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n- },\n+ mapOptions: null,\n \n+ /**\n+ * APIProperty: autoPan\n+ * {Boolean} Always pan the overview map, so the extent marker remains in\n+ * the center. Default is false. If true, when you drag the extent\n+ * marker, the overview map will update itself so the marker returns\n+ * to the center.\n+ */\n+ autoPan: false,\n \n /**\n- * Method: setMap\n- * Set the map property for the layer. This is done through an accessor\n- * so that subclasses can override this and take special action once \n- * they have their map variable set. \n+ * Property: handlers\n+ * {Object}\n+ */\n+ handlers: null,\n+\n+ /**\n+ * Property: resolutionFactor\n+ * {Object}\n+ */\n+ resolutionFactor: 1,\n+\n+ /**\n+ * APIProperty: maximized\n+ * {Boolean} Start as maximized (visible). Defaults to false.\n+ */\n+ maximized: false,\n+\n+ /**\n+ * APIProperty: maximizeTitle\n+ * {String} This property is used for showing a tooltip over the \n+ * maximize div. Defaults to \"\" (no title).\n+ */\n+ maximizeTitle: \"\",\n+\n+ /**\n+ * APIProperty: minimizeTitle\n+ * {String} This property is used for showing a tooltip over the \n+ * minimize div. Defaults to \"\" (no title).\n+ */\n+ minimizeTitle: \"\",\n+\n+ /**\n+ * Constructor: OpenLayers.Control.OverviewMap\n+ * Create a new overview map\n *\n * Parameters:\n- * map - {}\n+ * options - {Object} Properties of this object will be set on the overview\n+ * map object. Note, to set options on the map object contained in this\n+ * control, set as one of the options properties.\n */\n- setMap: function(map) {\n- OpenLayers.Layer.prototype.setMap.apply(this, arguments);\n+ initialize: function(options) {\n+ this.layers = [];\n+ this.handlers = {};\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ },\n \n- this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;\n- this.pane.style.display = this.div.style.display;\n- this.pane.style.width = \"100%\";\n- this.pane.style.height = \"100%\";\n- if (OpenLayers.BROWSER_NAME == \"msie\") {\n- this.pane.style.background =\n- \"url(\" + OpenLayers.Util.getImageLocation(\"blank.gif\") + \")\";\n+ /**\n+ * APIMethod: destroy\n+ * Deconstruct the control\n+ */\n+ destroy: function() {\n+ if (!this.mapDiv) { // we've already been destroyed\n+ return;\n+ }\n+ if (this.handlers.click) {\n+ this.handlers.click.destroy();\n+ }\n+ if (this.handlers.drag) {\n+ this.handlers.drag.destroy();\n }\n \n- if (this.isFixed) {\n- this.map.viewPortDiv.appendChild(this.pane);\n- } else {\n- this.map.layerContainerDiv.appendChild(this.pane);\n+ this.ovmap && this.ovmap.viewPortDiv.removeChild(this.extentRectangle);\n+ this.extentRectangle = null;\n+\n+ if (this.rectEvents) {\n+ this.rectEvents.destroy();\n+ this.rectEvents = null;\n }\n \n- // once our layer has been added to the map, we can load it\n- this.loadMapObject();\n+ if (this.ovmap) {\n+ this.ovmap.destroy();\n+ this.ovmap = null;\n+ }\n \n- // if map didn't load, display warning\n- if (this.mapObject == null) {\n- this.loadWarningMessage();\n+ this.element.removeChild(this.mapDiv);\n+ this.mapDiv = null;\n+\n+ this.div.removeChild(this.element);\n+ this.element = null;\n+\n+ if (this.maximizeDiv) {\n+ this.div.removeChild(this.maximizeDiv);\n+ this.maximizeDiv = null;\n }\n- },\n \n- /**\n- * APIMethod: removeMap\n- * On being removed from the map, we'll like to remove the invisible 'pane'\n- * div that we added to it on creation. \n- * \n- * Parameters:\n- * map - {}\n- */\n- removeMap: function(map) {\n- if (this.pane && this.pane.parentNode) {\n- this.pane.parentNode.removeChild(this.pane);\n+ if (this.minimizeDiv) {\n+ this.div.removeChild(this.minimizeDiv);\n+ this.minimizeDiv = null;\n }\n- OpenLayers.Layer.prototype.removeMap.apply(this, arguments);\n+\n+ this.map.events.un({\n+ buttonclick: this.onButtonClick,\n+ moveend: this.update,\n+ changebaselayer: this.baseLayerDraw,\n+ scope: this\n+ });\n+\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: loadWarningMessage\n- * If we can't load the map lib, then display an error message to the \n- * user and tell them where to go for help.\n- * \n- * This function sets up the layout for the warning message. Each 3rd\n- * party layer must implement its own getWarningHTML() function to \n- * provide the actual warning message.\n+ * Method: draw\n+ * Render the control in the browser.\n */\n- loadWarningMessage: function() {\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ if (this.layers.length === 0) {\n+ if (this.map.baseLayer) {\n+ var layer = this.map.baseLayer.clone();\n+ this.layers = [layer];\n+ } else {\n+ this.map.events.register(\"changebaselayer\", this, this.baseLayerDraw);\n+ return this.div;\n+ }\n+ }\n \n- this.div.style.backgroundColor = \"darkblue\";\n+ // create overview map DOM elements\n+ this.element = document.createElement('div');\n+ this.element.className = this.displayClass + 'Element';\n+ this.element.style.display = 'none';\n \n- var viewSize = this.map.getSize();\n+ this.mapDiv = document.createElement('div');\n+ this.mapDiv.style.width = this.size.w + 'px';\n+ this.mapDiv.style.height = this.size.h + 'px';\n+ this.mapDiv.style.position = 'relative';\n+ this.mapDiv.style.overflow = 'hidden';\n+ this.mapDiv.id = OpenLayers.Util.createUniqueID('overviewMap');\n \n- var msgW = Math.min(viewSize.w, 300);\n- var msgH = Math.min(viewSize.h, 200);\n- var size = new OpenLayers.Size(msgW, msgH);\n+ this.extentRectangle = document.createElement('div');\n+ this.extentRectangle.style.position = 'absolute';\n+ this.extentRectangle.style.zIndex = 1000; //HACK\n+ this.extentRectangle.className = this.displayClass + 'ExtentRectangle';\n \n- var centerPx = new OpenLayers.Pixel(viewSize.w / 2, viewSize.h / 2);\n+ this.element.appendChild(this.mapDiv);\n \n- var topLeft = centerPx.add(-size.w / 2, -size.h / 2);\n+ this.div.appendChild(this.element);\n \n- var div = OpenLayers.Util.createDiv(this.name + \"_warning\",\n- topLeft,\n- size,\n- null,\n- null,\n- null,\n- \"auto\");\n+ // Optionally add min/max buttons if the control will go in the\n+ // map viewport.\n+ if (!this.outsideViewport) {\n+ this.div.className += \" \" + this.displayClass + 'Container';\n+ // maximize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-maximize.png');\n+ this.maximizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ this.displayClass + 'MaximizeButton',\n+ null,\n+ null,\n+ img,\n+ 'absolute');\n+ this.maximizeDiv.style.display = 'none';\n+ this.maximizeDiv.className = this.displayClass + 'MaximizeButton olButton';\n+ if (this.maximizeTitle) {\n+ this.maximizeDiv.title = this.maximizeTitle;\n+ }\n+ this.div.appendChild(this.maximizeDiv);\n \n- div.style.padding = \"7px\";\n- div.style.backgroundColor = \"yellow\";\n+ // minimize button div\n+ var img = OpenLayers.Util.getImageLocation('layer-switcher-minimize.png');\n+ this.minimizeDiv = OpenLayers.Util.createAlphaImageDiv(\n+ 'OpenLayers_Control_minimizeDiv',\n+ null,\n+ null,\n+ img,\n+ 'absolute');\n+ this.minimizeDiv.style.display = 'none';\n+ this.minimizeDiv.className = this.displayClass + 'MinimizeButton olButton';\n+ if (this.minimizeTitle) {\n+ this.minimizeDiv.title = this.minimizeTitle;\n+ }\n+ this.div.appendChild(this.minimizeDiv);\n+ this.minimizeControl();\n+ } else {\n+ // show the overview map\n+ this.element.style.display = '';\n+ }\n+ if (this.map.getExtent()) {\n+ this.update();\n+ }\n \n- div.innerHTML = this.getWarningHTML();\n- this.div.appendChild(div);\n+ this.map.events.on({\n+ buttonclick: this.onButtonClick,\n+ moveend: this.update,\n+ scope: this\n+ });\n+\n+ if (this.maximized) {\n+ this.maximizeControl();\n+ }\n+ return this.div;\n },\n \n- /** \n- * Method: getWarningHTML\n- * To be implemented by subclasses.\n- * \n- * Returns:\n- * {String} String with information on why layer is broken, how to get\n- * it working.\n+ /**\n+ * Method: baseLayerDraw\n+ * Draw the base layer - called if unable to complete in the initial draw\n */\n- getWarningHTML: function() {\n- //should be implemented by subclasses\n- return \"\";\n+ baseLayerDraw: function() {\n+ this.draw();\n+ this.map.events.unregister(\"changebaselayer\", this, this.baseLayerDraw);\n },\n \n /**\n- * Method: display\n- * Set the display on the pane\n+ * Method: rectDrag\n+ * Handle extent rectangle drag\n *\n * Parameters:\n- * display - {Boolean}\n+ * px - {} The pixel location of the drag.\n */\n- display: function(display) {\n- OpenLayers.Layer.prototype.display.apply(this, arguments);\n- this.pane.style.display = this.div.style.display;\n+ rectDrag: function(px) {\n+ var deltaX = this.handlers.drag.last.x - px.x;\n+ var deltaY = this.handlers.drag.last.y - px.y;\n+ if (deltaX != 0 || deltaY != 0) {\n+ var rectTop = this.rectPxBounds.top;\n+ var rectLeft = this.rectPxBounds.left;\n+ var rectHeight = Math.abs(this.rectPxBounds.getHeight());\n+ var rectWidth = this.rectPxBounds.getWidth();\n+ // don't allow dragging off of parent element\n+ var newTop = Math.max(0, (rectTop - deltaY));\n+ newTop = Math.min(newTop,\n+ this.ovmap.size.h - this.hComp - rectHeight);\n+ var newLeft = Math.max(0, (rectLeft - deltaX));\n+ newLeft = Math.min(newLeft,\n+ this.ovmap.size.w - this.wComp - rectWidth);\n+ this.setRectPxBounds(new OpenLayers.Bounds(newLeft,\n+ newTop + rectHeight,\n+ newLeft + rectWidth,\n+ newTop));\n+ }\n },\n \n /**\n- * Method: setZIndex\n- * Set the z-index order for the pane.\n- * \n+ * Method: mapDivClick\n+ * Handle browser events\n+ *\n * Parameters:\n- * zIndex - {int}\n+ * evt - {} evt\n */\n- setZIndex: function(zIndex) {\n- OpenLayers.Layer.prototype.setZIndex.apply(this, arguments);\n- this.pane.style.zIndex = parseInt(this.div.style.zIndex) + 1;\n+ mapDivClick: function(evt) {\n+ var pxCenter = this.rectPxBounds.getCenterPixel();\n+ var deltaX = evt.xy.x - pxCenter.x;\n+ var deltaY = evt.xy.y - pxCenter.y;\n+ var top = this.rectPxBounds.top;\n+ var left = this.rectPxBounds.left;\n+ var height = Math.abs(this.rectPxBounds.getHeight());\n+ var width = this.rectPxBounds.getWidth();\n+ var newTop = Math.max(0, (top + deltaY));\n+ newTop = Math.min(newTop, this.ovmap.size.h - height);\n+ var newLeft = Math.max(0, (left + deltaX));\n+ newLeft = Math.min(newLeft, this.ovmap.size.w - width);\n+ this.setRectPxBounds(new OpenLayers.Bounds(newLeft,\n+ newTop + height,\n+ newLeft + width,\n+ newTop));\n+ this.updateMapToRect();\n },\n \n /**\n- * Method: moveByPx\n- * Move the layer based on pixel vector. To be implemented by subclasses.\n+ * Method: onButtonClick\n *\n * Parameters:\n- * dx - {Number} The x coord of the displacement vector.\n- * dy - {Number} The y coord of the displacement vector.\n+ * evt - {Event}\n */\n- moveByPx: function(dx, dy) {\n- OpenLayers.Layer.prototype.moveByPx.apply(this, arguments);\n+ onButtonClick: function(evt) {\n+ if (evt.buttonElement === this.minimizeDiv) {\n+ this.minimizeControl();\n+ } else if (evt.buttonElement === this.maximizeDiv) {\n+ this.maximizeControl();\n+ }\n+ },\n \n- if (this.dragPanMapObject) {\n- this.dragPanMapObject(dx, -dy);\n- } else {\n- this.moveTo(this.map.getCachedCenter());\n+ /**\n+ * Method: maximizeControl\n+ * Unhide the control. Called when the control is in the map viewport.\n+ *\n+ * Parameters:\n+ * e - {}\n+ */\n+ maximizeControl: function(e) {\n+ this.element.style.display = '';\n+ this.showToggle(false);\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n }\n },\n \n /**\n- * Method: moveTo\n- * Handle calls to move the layer.\n+ * Method: minimizeControl\n+ * Hide all the contents of the control, shrink the size, \n+ * add the maximize icon\n * \n * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean}\n- * dragging - {Boolean}\n+ * e - {}\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- OpenLayers.Layer.prototype.moveTo.apply(this, arguments);\n+ minimizeControl: function(e) {\n+ this.element.style.display = 'none';\n+ this.showToggle(true);\n+ if (e != null) {\n+ OpenLayers.Event.stop(e);\n+ }\n+ },\n \n- if (this.mapObject != null) {\n+ /**\n+ * Method: showToggle\n+ * Hide/Show the toggle depending on whether the control is minimized\n+ *\n+ * Parameters:\n+ * minimize - {Boolean} \n+ */\n+ showToggle: function(minimize) {\n+ if (this.maximizeDiv) {\n+ this.maximizeDiv.style.display = minimize ? '' : 'none';\n+ }\n+ if (this.minimizeDiv) {\n+ this.minimizeDiv.style.display = minimize ? 'none' : '';\n+ }\n+ },\n \n- var newCenter = this.map.getCenter();\n- var newZoom = this.map.getZoom();\n+ /**\n+ * Method: update\n+ * Update the overview map after layers move.\n+ */\n+ update: function() {\n+ if (this.ovmap == null) {\n+ this.createMap();\n+ }\n \n- if (newCenter != null) {\n+ if (this.autoPan || !this.isSuitableOverview()) {\n+ this.updateOverview();\n+ }\n \n- var moOldCenter = this.getMapObjectCenter();\n- var oldCenter = this.getOLLonLatFromMapObjectLonLat(moOldCenter);\n+ // update extent rectangle\n+ this.updateRectToMap();\n+ },\n \n- var moOldZoom = this.getMapObjectZoom();\n- var oldZoom = this.getOLZoomFromMapObjectZoom(moOldZoom);\n+ /**\n+ * Method: isSuitableOverview\n+ * Determines if the overview map is suitable given the extent and\n+ * resolution of the main map.\n+ */\n+ isSuitableOverview: function() {\n+ var mapExtent = this.map.getExtent();\n+ var maxExtent = this.map.getMaxExtent();\n+ var testExtent = new OpenLayers.Bounds(\n+ Math.max(mapExtent.left, maxExtent.left),\n+ Math.max(mapExtent.bottom, maxExtent.bottom),\n+ Math.min(mapExtent.right, maxExtent.right),\n+ Math.min(mapExtent.top, maxExtent.top));\n \n- if (!(newCenter.equals(oldCenter)) || newZoom != oldZoom) {\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ testExtent = testExtent.transform(\n+ this.map.getProjectionObject(),\n+ this.ovmap.getProjectionObject());\n+ }\n \n- if (!zoomChanged && oldCenter && this.dragPanMapObject &&\n- this.smoothDragPan) {\n- var oldPx = this.map.getViewPortPxFromLonLat(oldCenter);\n- var newPx = this.map.getViewPortPxFromLonLat(newCenter);\n- this.dragPanMapObject(newPx.x - oldPx.x, oldPx.y - newPx.y);\n- } else {\n- var center = this.getMapObjectLonLatFromOLLonLat(newCenter);\n- var zoom = this.getMapObjectZoomFromOLZoom(newZoom);\n- this.setMapObjectCenter(center, zoom, dragging);\n- }\n- }\n- }\n+ var resRatio = this.ovmap.getResolution() / this.map.getResolution();\n+ return ((resRatio > this.minRatio) &&\n+ (resRatio <= this.maxRatio) &&\n+ (this.ovmap.getExtent().containsBounds(testExtent)));\n+ },\n+\n+ /**\n+ * Method updateOverview\n+ * Called by if returns true\n+ */\n+ updateOverview: function() {\n+ var mapRes = this.map.getResolution();\n+ var targetRes = this.ovmap.getResolution();\n+ var resRatio = targetRes / mapRes;\n+ if (resRatio > this.maxRatio) {\n+ // zoom in overview map\n+ targetRes = this.minRatio * mapRes;\n+ } else if (resRatio <= this.minRatio) {\n+ // zoom out overview map\n+ targetRes = this.maxRatio * mapRes;\n+ }\n+ var center;\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ center = this.map.center.clone();\n+ center.transform(this.map.getProjectionObject(),\n+ this.ovmap.getProjectionObject());\n+ } else {\n+ center = this.map.center;\n }\n+ this.ovmap.setCenter(center, this.ovmap.getZoomForResolution(\n+ targetRes * this.resolutionFactor));\n+ this.updateRectToMap();\n },\n \n+ /**\n+ * Method: createMap\n+ * Construct the map that this control contains\n+ */\n+ createMap: function() {\n+ // create the overview map\n+ var options = OpenLayers.Util.extend({\n+ controls: [],\n+ maxResolution: 'auto',\n+ fallThrough: false\n+ }, this.mapOptions);\n+ this.ovmap = new OpenLayers.Map(this.mapDiv, options);\n+ this.ovmap.viewPortDiv.appendChild(this.extentRectangle);\n \n- /********************************************************/\n- /* */\n- /* Baselayer Functions */\n- /* */\n- /********************************************************/\n+ // prevent ovmap from being destroyed when the page unloads, because\n+ // the OverviewMap control has to do this (and does it).\n+ OpenLayers.Event.stopObserving(window, 'unload', this.ovmap.unloadDestroy);\n+\n+ this.ovmap.addLayers(this.layers);\n+ this.ovmap.zoomToMaxExtent();\n+ // check extent rectangle border width\n+ this.wComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-left-width')) +\n+ parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-right-width'));\n+ this.wComp = (this.wComp) ? this.wComp : 2;\n+ this.hComp = parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-top-width')) +\n+ parseInt(OpenLayers.Element.getStyle(this.extentRectangle,\n+ 'border-bottom-width'));\n+ this.hComp = (this.hComp) ? this.hComp : 2;\n+\n+ this.handlers.drag = new OpenLayers.Handler.Drag(\n+ this, {\n+ move: this.rectDrag,\n+ done: this.updateMapToRect\n+ }, {\n+ map: this.ovmap\n+ }\n+ );\n+ this.handlers.click = new OpenLayers.Handler.Click(\n+ this, {\n+ \"click\": this.mapDivClick\n+ }, {\n+ \"single\": true,\n+ \"double\": false,\n+ \"stopSingle\": true,\n+ \"stopDouble\": true,\n+ \"pixelTolerance\": 1,\n+ map: this.ovmap\n+ }\n+ );\n+ this.handlers.click.activate();\n+\n+ this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,\n+ null, true);\n+ this.rectEvents.register(\"mouseover\", this, function(e) {\n+ if (!this.handlers.drag.active && !this.map.dragging) {\n+ this.handlers.drag.activate();\n+ }\n+ });\n+ this.rectEvents.register(\"mouseout\", this, function(e) {\n+ if (!this.handlers.drag.dragging) {\n+ this.handlers.drag.deactivate();\n+ }\n+ });\n+\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ var sourceUnits = this.map.getProjectionObject().getUnits() ||\n+ this.map.units || this.map.baseLayer.units;\n+ var targetUnits = this.ovmap.getProjectionObject().getUnits() ||\n+ this.ovmap.units || this.ovmap.baseLayer.units;\n+ this.resolutionFactor = sourceUnits && targetUnits ?\n+ OpenLayers.INCHES_PER_UNIT[sourceUnits] /\n+ OpenLayers.INCHES_PER_UNIT[targetUnits] : 1;\n+ }\n+ },\n \n /**\n- * Method: getLonLatFromViewPortPx\n- * Get a map location from a pixel location\n- * \n- * Parameters:\n- * viewPortPx - {}\n- *\n- * Returns:\n- * {} An OpenLayers.LonLat which is the passed-in view\n- * port OpenLayers.Pixel, translated into lon/lat by map lib\n- * If the map lib is not loaded or not centered, returns null\n+ * Method: updateRectToMap\n+ * Updates the extent rectangle position and size to match the map extent\n */\n- getLonLatFromViewPortPx: function(viewPortPx) {\n- var lonlat = null;\n- if ((this.mapObject != null) &&\n- (this.getMapObjectCenter() != null)) {\n- var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx);\n- var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel);\n- lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat);\n+ updateRectToMap: function() {\n+ // If the projections differ we need to reproject\n+ var bounds;\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ bounds = this.map.getExtent().transform(\n+ this.map.getProjectionObject(),\n+ this.ovmap.getProjectionObject());\n+ } else {\n+ bounds = this.map.getExtent();\n+ }\n+ var pxBounds = this.getRectBoundsFromMapBounds(bounds);\n+ if (pxBounds) {\n+ this.setRectPxBounds(pxBounds);\n }\n- return lonlat;\n },\n \n+ /**\n+ * Method: updateMapToRect\n+ * Updates the map extent to match the extent rectangle position and size\n+ */\n+ updateMapToRect: function() {\n+ var lonLatBounds = this.getMapBoundsFromRectBounds(this.rectPxBounds);\n+ if (this.ovmap.getProjection() != this.map.getProjection()) {\n+ lonLatBounds = lonLatBounds.transform(\n+ this.ovmap.getProjectionObject(),\n+ this.map.getProjectionObject());\n+ }\n+ this.map.panTo(lonLatBounds.getCenterLonLat());\n+ },\n \n /**\n- * Method: getViewPortPxFromLonLat\n- * Get a pixel location from a map location\n+ * Method: setRectPxBounds\n+ * Set extent rectangle pixel bounds.\n *\n * Parameters:\n- * lonlat - {}\n- *\n- * Returns:\n- * {} An OpenLayers.Pixel which is the passed-in\n- * OpenLayers.LonLat, translated into view port pixels by map lib\n- * If map lib is not loaded or not centered, returns null\n+ * pxBounds - {}\n */\n- getViewPortPxFromLonLat: function(lonlat) {\n- var viewPortPx = null;\n- if ((this.mapObject != null) &&\n- (this.getMapObjectCenter() != null)) {\n-\n- var moLonLat = this.getMapObjectLonLatFromOLLonLat(lonlat);\n- var moPixel = this.getMapObjectPixelFromMapObjectLonLat(moLonLat);\n-\n- viewPortPx = this.getOLPixelFromMapObjectPixel(moPixel);\n+ setRectPxBounds: function(pxBounds) {\n+ var top = Math.max(pxBounds.top, 0);\n+ var left = Math.max(pxBounds.left, 0);\n+ var bottom = Math.min(pxBounds.top + Math.abs(pxBounds.getHeight()),\n+ this.ovmap.size.h - this.hComp);\n+ var right = Math.min(pxBounds.left + pxBounds.getWidth(),\n+ this.ovmap.size.w - this.wComp);\n+ var width = Math.max(right - left, 0);\n+ var height = Math.max(bottom - top, 0);\n+ if (width < this.minRectSize || height < this.minRectSize) {\n+ this.extentRectangle.className = this.displayClass +\n+ this.minRectDisplayClass;\n+ var rLeft = left + (width / 2) - (this.minRectSize / 2);\n+ var rTop = top + (height / 2) - (this.minRectSize / 2);\n+ this.extentRectangle.style.top = Math.round(rTop) + 'px';\n+ this.extentRectangle.style.left = Math.round(rLeft) + 'px';\n+ this.extentRectangle.style.height = this.minRectSize + 'px';\n+ this.extentRectangle.style.width = this.minRectSize + 'px';\n+ } else {\n+ this.extentRectangle.className = this.displayClass +\n+ 'ExtentRectangle';\n+ this.extentRectangle.style.top = Math.round(top) + 'px';\n+ this.extentRectangle.style.left = Math.round(left) + 'px';\n+ this.extentRectangle.style.height = Math.round(height) + 'px';\n+ this.extentRectangle.style.width = Math.round(width) + 'px';\n }\n- return viewPortPx;\n+ this.rectPxBounds = new OpenLayers.Bounds(\n+ Math.round(left), Math.round(bottom),\n+ Math.round(right), Math.round(top)\n+ );\n },\n \n- /********************************************************/\n- /* */\n- /* Translation Functions */\n- /* */\n- /* The following functions translate Map Object and */\n- /* OL formats for Pixel, LonLat */\n- /* */\n- /********************************************************/\n-\n- //\n- // TRANSLATION: MapObject LatLng <-> OpenLayers.LonLat\n- //\n-\n /**\n- * Method: getOLLonLatFromMapObjectLonLat\n- * Get an OL style map location from a 3rd party style map location\n+ * Method: getRectBoundsFromMapBounds\n+ * Get the rect bounds from the map bounds.\n+ *\n+ * Parameters:\n+ * lonLatBounds - {}\n *\n- * Parameters\n- * moLonLat - {Object}\n- * \n * Returns:\n- * {} An OpenLayers.LonLat, translated from the passed in \n- * MapObject LonLat\n- * Returns null if null value is passed in\n+ * {}A bounds which is the passed-in map lon/lat extent\n+ * translated into pixel bounds for the overview map\n */\n- getOLLonLatFromMapObjectLonLat: function(moLonLat) {\n- var olLonLat = null;\n- if (moLonLat != null) {\n- var lon = this.getLongitudeFromMapObjectLonLat(moLonLat);\n- var lat = this.getLatitudeFromMapObjectLonLat(moLonLat);\n- olLonLat = new OpenLayers.LonLat(lon, lat);\n+ getRectBoundsFromMapBounds: function(lonLatBounds) {\n+ var leftBottomPx = this.getOverviewPxFromLonLat({\n+ lon: lonLatBounds.left,\n+ lat: lonLatBounds.bottom\n+ });\n+ var rightTopPx = this.getOverviewPxFromLonLat({\n+ lon: lonLatBounds.right,\n+ lat: lonLatBounds.top\n+ });\n+ var bounds = null;\n+ if (leftBottomPx && rightTopPx) {\n+ bounds = new OpenLayers.Bounds(leftBottomPx.x, leftBottomPx.y,\n+ rightTopPx.x, rightTopPx.y);\n }\n- return olLonLat;\n+ return bounds;\n },\n \n /**\n- * Method: getMapObjectLonLatFromOLLonLat\n- * Get a 3rd party map location from an OL map location.\n+ * Method: getMapBoundsFromRectBounds\n+ * Get the map bounds from the rect bounds.\n *\n * Parameters:\n- * olLonLat - {}\n- * \n+ * pxBounds - {}\n+ *\n * Returns:\n- * {Object} A MapObject LonLat, translated from the passed in \n- * OpenLayers.LonLat\n- * Returns null if null value is passed in\n+ * {} Bounds which is the passed-in overview rect bounds\n+ * translated into lon/lat bounds for the overview map\n */\n- getMapObjectLonLatFromOLLonLat: function(olLonLat) {\n- var moLatLng = null;\n- if (olLonLat != null) {\n- moLatLng = this.getMapObjectLonLatFromLonLat(olLonLat.lon,\n- olLonLat.lat);\n- }\n- return moLatLng;\n+ getMapBoundsFromRectBounds: function(pxBounds) {\n+ var leftBottomLonLat = this.getLonLatFromOverviewPx({\n+ x: pxBounds.left,\n+ y: pxBounds.bottom\n+ });\n+ var rightTopLonLat = this.getLonLatFromOverviewPx({\n+ x: pxBounds.right,\n+ y: pxBounds.top\n+ });\n+ return new OpenLayers.Bounds(leftBottomLonLat.lon, leftBottomLonLat.lat,\n+ rightTopLonLat.lon, rightTopLonLat.lat);\n },\n \n-\n- //\n- // TRANSLATION: MapObject Pixel <-> OpenLayers.Pixel\n- //\n-\n /**\n- * Method: getOLPixelFromMapObjectPixel\n- * Get an OL pixel location from a 3rd party pixel location.\n+ * Method: getLonLatFromOverviewPx\n+ * Get a map location from a pixel location\n *\n * Parameters:\n- * moPixel - {Object}\n- * \n+ * overviewMapPx - {|Object} OpenLayers.Pixel or\n+ * an object with a\n+ * 'x' and 'y' properties.\n+ *\n * Returns:\n- * {} An OpenLayers.Pixel, translated from the passed in \n- * MapObject Pixel\n- * Returns null if null value is passed in\n+ * {Object} Location which is the passed-in overview map\n+ * OpenLayers.Pixel, translated into lon/lat by the overview\n+ * map. An object with a 'lon' and 'lat' properties.\n */\n- getOLPixelFromMapObjectPixel: function(moPixel) {\n- var olPixel = null;\n- if (moPixel != null) {\n- var x = this.getXFromMapObjectPixel(moPixel);\n- var y = this.getYFromMapObjectPixel(moPixel);\n- olPixel = new OpenLayers.Pixel(x, y);\n- }\n- return olPixel;\n+ getLonLatFromOverviewPx: function(overviewMapPx) {\n+ var size = this.ovmap.size;\n+ var res = this.ovmap.getResolution();\n+ var center = this.ovmap.getExtent().getCenterLonLat();\n+\n+ var deltaX = overviewMapPx.x - (size.w / 2);\n+ var deltaY = overviewMapPx.y - (size.h / 2);\n+\n+ return {\n+ lon: center.lon + deltaX * res,\n+ lat: center.lat - deltaY * res\n+ };\n },\n \n /**\n- * Method: getMapObjectPixelFromOLPixel\n- * Get a 3rd party pixel location from an OL pixel location\n+ * Method: getOverviewPxFromLonLat\n+ * Get a pixel location from a map location\n *\n * Parameters:\n- * olPixel - {}\n- * \n+ * lonlat - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n+ *\n * Returns:\n- * {Object} A MapObject Pixel, translated from the passed in \n- * OpenLayers.Pixel\n- * Returns null if null value is passed in\n+ * {Object} Location which is the passed-in OpenLayers.LonLat, \n+ * translated into overview map pixels\n */\n- getMapObjectPixelFromOLPixel: function(olPixel) {\n- var moPixel = null;\n- if (olPixel != null) {\n- moPixel = this.getMapObjectPixelFromXY(olPixel.x, olPixel.y);\n+ getOverviewPxFromLonLat: function(lonlat) {\n+ var res = this.ovmap.getResolution();\n+ var extent = this.ovmap.getExtent();\n+ if (extent) {\n+ return {\n+ x: Math.round(1 / res * (lonlat.lon - extent.left)),\n+ y: Math.round(1 / res * (extent.top - lonlat.lat))\n+ };\n }\n- return moPixel;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.EventPane\"\n+ CLASS_NAME: 'OpenLayers.Control.OverviewMap'\n });\n /* ======================================================================\n- OpenLayers/Format/ArcXML.js\n+ OpenLayers/Format/WMSGetFeatureInfo.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Geometry/Polygon.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Geometry/MultiPolygon.js\n- * @requires OpenLayers/Geometry/LinearRing.js\n */\n \n /**\n- * Class: OpenLayers.Format.ArcXML\n- * Read/Write ArcXML. Create a new instance with the \n- * constructor.\n- * \n+ * Class: OpenLayers.Format.WMSGetFeatureInfo\n+ * Class to read GetFeatureInfo responses from Web Mapping Services\n+ *\n * Inherits from:\n * - \n */\n-OpenLayers.Format.ArcXML = OpenLayers.Class(OpenLayers.Format.XML, {\n-\n- /**\n- * Property: fontStyleKeys\n- * {Array} List of keys used in font styling.\n- */\n- fontStyleKeys: [\n- 'antialiasing', 'blockout', 'font', 'fontcolor', 'fontsize', 'fontstyle',\n- 'glowing', 'interval', 'outline', 'printmode', 'shadow', 'transparency'\n- ],\n+OpenLayers.Format.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Format.XML, {\n \n /**\n- * Property: request\n- * A get_image request destined for an ArcIMS server.\n+ * APIProperty: layerIdentifier\n+ * {String} All xml nodes containing this search criteria will populate an\n+ * internal array of layer nodes.\n */\n- request: null,\n+ layerIdentifier: '_layer',\n \n /**\n- * Property: response\n- * A parsed response from an ArcIMS server.\n+ * APIProperty: featureIdentifier\n+ * {String} All xml nodes containing this search criteria will populate an \n+ * internal array of feature nodes for each layer node found.\n */\n- response: null,\n+ featureIdentifier: '_feature',\n \n /**\n- * Constructor: OpenLayers.Format.ArcXML\n- * Create a new parser/writer for ArcXML. Create an instance of this class\n- * to begin authoring a request to an ArcIMS service. This is used\n- * primarily by the ArcIMS layer, but could be used to do other wild\n- * stuff, like geocoding.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n+ * Property: regExes\n+ * Compiled regular expressions for manipulating strings.\n */\n- initialize: function(options) {\n- this.request = new OpenLayers.Format.ArcXML.Request();\n- this.response = new OpenLayers.Format.ArcXML.Response();\n-\n- if (options) {\n- if (options.requesttype == \"feature\") {\n- this.request.get_image = null;\n-\n- var qry = this.request.get_feature.query;\n- this.addCoordSys(qry.featurecoordsys, options.featureCoordSys);\n- this.addCoordSys(qry.filtercoordsys, options.filterCoordSys);\n-\n- if (options.polygon) {\n- qry.isspatial = true;\n- qry.spatialfilter.polygon = options.polygon;\n- } else if (options.envelope) {\n- qry.isspatial = true;\n- qry.spatialfilter.envelope = {\n- minx: 0,\n- miny: 0,\n- maxx: 0,\n- maxy: 0\n- };\n- this.parseEnvelope(qry.spatialfilter.envelope, options.envelope);\n- }\n- } else if (options.requesttype == \"image\") {\n- this.request.get_feature = null;\n-\n- var props = this.request.get_image.properties;\n- this.parseEnvelope(props.envelope, options.envelope);\n-\n- this.addLayers(props.layerlist, options.layers);\n- this.addImageSize(props.imagesize, options.tileSize);\n- this.addCoordSys(props.featurecoordsys, options.featureCoordSys);\n- this.addCoordSys(props.filtercoordsys, options.filterCoordSys);\n- } else {\n- // if an arcxml object is being created with no request type, it is\n- // probably going to consume a response, so do not throw an error if\n- // the requesttype is not defined\n- this.request = null;\n- }\n- }\n-\n- OpenLayers.Format.XML.prototype.initialize.apply(this, [options]);\n+ regExes: {\n+ trimSpace: (/^\\s*|\\s*$/g),\n+ removeSpace: (/\\s*/g),\n+ splitSpace: (/\\s+/),\n+ trimComma: (/\\s*,\\s*/g)\n },\n \n /**\n- * Method: parseEnvelope\n- * Parse an array of coordinates into an ArcXML envelope structure.\n- *\n- * Parameters:\n- * env - {Object} An envelope object that will contain the parsed coordinates.\n- * arr - {Array(double)} An array of coordinates in the order: [ minx, miny, maxx, maxy ]\n- */\n- parseEnvelope: function(env, arr) {\n- if (arr && arr.length == 4) {\n- env.minx = arr[0];\n- env.miny = arr[1];\n- env.maxx = arr[2];\n- env.maxy = arr[3];\n- }\n- },\n-\n- /** \n- * Method: addLayers\n- * Add a collection of layers to another collection of layers. Each layer in the list is tuple of\n- * { id, visible }. These layer collections represent the \n- * /ARCXML/REQUEST/get_image/PROPERTIES/LAYERLIST/LAYERDEF items in ArcXML\n- *\n- * TODO: Add support for dynamic layer rendering.\n- *\n- * Parameters:\n- * ll - {Array({id,visible})} A list of layer definitions.\n- * lyrs - {Array({id,visible})} A list of layer definitions.\n+ * Property: gmlFormat\n+ * {} internal GML format for parsing geometries\n+ * in msGMLOutput\n */\n- addLayers: function(ll, lyrs) {\n- for (var lind = 0, len = lyrs.length; lind < len; lind++) {\n- ll.push(lyrs[lind]);\n- }\n- },\n+ gmlFormat: null,\n \n /**\n- * Method: addImageSize\n- * Set the size of the requested image.\n+ * Constructor: OpenLayers.Format.WMSGetFeatureInfo\n+ * Create a new parser for WMS GetFeatureInfo responses\n *\n * Parameters:\n- * imsize - {Object} An ArcXML imagesize object.\n- * olsize - {} The image size to set.\n+ * options - {Object} An optional object whose properties will be set on\n+ * this instance.\n */\n- addImageSize: function(imsize, olsize) {\n- if (olsize !== null) {\n- imsize.width = olsize.w;\n- imsize.height = olsize.h;\n- imsize.printwidth = olsize.w;\n- imsize.printheight = olsize.h;\n- }\n- },\n \n /**\n- * Method: addCoordSys\n- * Add the coordinate system information to an object. The object may be \n+ * APIMethod: read\n+ * Read WMS GetFeatureInfo data from a string, and return an array of features\n *\n * Parameters:\n- * featOrFilt - {Object} A featurecoordsys or filtercoordsys ArcXML structure.\n- * fsys - {String} or {} or {filtercoordsys} or \n- * {featurecoordsys} A projection representation. If it's a {String}, \n- * the value is assumed to be the SRID. If it's a {OpenLayers.Projection} \n- * AND Proj4js is available, the projection number and name are extracted \n- * from there. If it's a filter or feature ArcXML structure, it is copied.\n+ * data - {String} or {DOMElement} data to read/parse.\n+ *\n+ * Returns:\n+ * {Array()} An array of features.\n */\n- addCoordSys: function(featOrFilt, fsys) {\n- if (typeof fsys == \"string\") {\n- featOrFilt.id = parseInt(fsys);\n- featOrFilt.string = fsys;\n+ read: function(data) {\n+ var result;\n+ if (typeof data == \"string\") {\n+ data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n }\n- // is this a proj4js instance?\n- else if (typeof fsys == \"object\" && fsys.proj !== null) {\n- featOrFilt.id = fsys.proj.srsProjNumber;\n- featOrFilt.string = fsys.proj.srsCode;\n+ var root = data.documentElement;\n+ if (root) {\n+ var scope = this;\n+ var read = this[\"read_\" + root.nodeName];\n+ if (read) {\n+ result = read.call(this, root);\n+ } else {\n+ // fall-back to GML since this is a common output format for WMS\n+ // GetFeatureInfo responses\n+ result = new OpenLayers.Format.GML((this.options ? this.options : {})).read(data);\n+ }\n } else {\n- featOrFilt = fsys;\n+ result = data;\n }\n+ return result;\n },\n \n+\n /**\n- * APIMethod: iserror\n- * Check to see if the response from the server was an error.\n+ * Method: read_msGMLOutput\n+ * Parse msGMLOutput nodes.\n *\n * Parameters:\n- * data - {String} or {DOMElement} data to read/parse. If nothing is supplied,\n- * the current response is examined.\n+ * data - {DOMElement}\n *\n * Returns:\n- * {Boolean} true if the response was an error.\n+ * {Array}\n */\n- iserror: function(data) {\n- var ret = null;\n-\n- if (!data) {\n- ret = (this.response.error !== '');\n- } else {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- var errorNodes = data.documentElement.getElementsByTagName(\"ERROR\");\n- ret = (errorNodes !== null && errorNodes.length > 0);\n+ read_msGMLOutput: function(data) {\n+ var response = [];\n+ var layerNodes = this.getSiblingNodesByTagCriteria(data,\n+ this.layerIdentifier);\n+ if (layerNodes) {\n+ for (var i = 0, len = layerNodes.length; i < len; ++i) {\n+ var node = layerNodes[i];\n+ var layerName = node.nodeName;\n+ if (node.prefix) {\n+ layerName = layerName.split(':')[1];\n+ }\n+ var layerName = layerName.replace(this.layerIdentifier, '');\n+ var featureNodes = this.getSiblingNodesByTagCriteria(node,\n+ this.featureIdentifier);\n+ if (featureNodes) {\n+ for (var j = 0; j < featureNodes.length; j++) {\n+ var featureNode = featureNodes[j];\n+ var geomInfo = this.parseGeometry(featureNode);\n+ var attributes = this.parseAttributes(featureNode);\n+ var feature = new OpenLayers.Feature.Vector(geomInfo.geometry,\n+ attributes, null);\n+ feature.bounds = geomInfo.bounds;\n+ feature.type = layerName;\n+ response.push(feature);\n+ }\n+ }\n+ }\n }\n-\n- return ret;\n+ return response;\n },\n \n /**\n- * APIMethod: read\n- * Read data from a string, and return an response. \n- * \n+ * Method: read_FeatureInfoResponse\n+ * Parse FeatureInfoResponse nodes.\n+ *\n * Parameters:\n- * data - {String} or {DOMElement} data to read/parse.\n+ * data - {DOMElement}\n *\n * Returns:\n- * {} An ArcXML response. Note that this response\n- * data may change in the future. \n+ * {Array}\n */\n- read: function(data) {\n- if (typeof data == \"string\") {\n- data = OpenLayers.Format.XML.prototype.read.apply(this, [data]);\n- }\n+ read_FeatureInfoResponse: function(data) {\n+ var response = [];\n+ var featureNodes = this.getElementsByTagNameNS(data, '*',\n+ 'FIELDS');\n \n- var arcNode = null;\n- if (data && data.documentElement) {\n- if (data.documentElement.nodeName == \"ARCXML\") {\n- arcNode = data.documentElement;\n+ for (var i = 0, len = featureNodes.length; i < len; i++) {\n+ var featureNode = featureNodes[i];\n+ var geom = null;\n+\n+ // attributes can be actual attributes on the FIELDS tag, \n+ // or FIELD children\n+ var attributes = {};\n+ var j;\n+ var jlen = featureNode.attributes.length;\n+ if (jlen > 0) {\n+ for (j = 0; j < jlen; j++) {\n+ var attribute = featureNode.attributes[j];\n+ attributes[attribute.nodeName] = attribute.nodeValue;\n+ }\n } else {\n- arcNode = data.documentElement.getElementsByTagName(\"ARCXML\")[0];\n+ var nodes = featureNode.childNodes;\n+ for (j = 0, jlen = nodes.length; j < jlen; ++j) {\n+ var node = nodes[j];\n+ if (node.nodeType != 3) {\n+ attributes[node.getAttribute(\"name\")] =\n+ node.getAttribute(\"value\");\n+ }\n+ }\n }\n- }\n \n- // in Safari, arcNode will be there but will have a child named \n- // parsererror\n- if (!arcNode || arcNode.firstChild.nodeName === 'parsererror') {\n- var error, source;\n- try {\n- error = data.firstChild.nodeValue;\n- source = data.firstChild.childNodes[1].firstChild.nodeValue;\n- } catch (err) {\n- // pass\n- }\n- throw {\n- message: \"Error parsing the ArcXML request\",\n- error: error,\n- source: source\n- };\n+ response.push(\n+ new OpenLayers.Feature.Vector(geom, attributes, null)\n+ );\n }\n-\n- var response = this.parseResponse(arcNode);\n return response;\n },\n \n /**\n- * APIMethod: write\n- * Generate an ArcXml document string for sending to an ArcIMS server. \n+ * Method: getSiblingNodesByTagCriteria\n+ * Recursively searches passed xml node and all it's descendant levels for \n+ * nodes whose tagName contains the passed search string. This returns an \n+ * array of all sibling nodes which match the criteria from the highest \n+ * hierarchial level from which a match is found.\n * \n+ * Parameters:\n+ * node - {DOMElement} An xml node\n+ * criteria - {String} Search string which will match some part of a tagName \n+ * \n * Returns:\n- * {String} A string representing the ArcXML document request.\n+ * Array({DOMElement}) An array of sibling xml nodes\n */\n- write: function(request) {\n- if (!request) {\n- request = this.request;\n- }\n- var root = this.createElementNS(\"\", \"ARCXML\");\n- root.setAttribute(\"version\", \"1.1\");\n-\n- var reqElem = this.createElementNS(\"\", \"REQUEST\");\n-\n- if (request.get_image != null) {\n- var getElem = this.createElementNS(\"\", \"GET_IMAGE\");\n- reqElem.appendChild(getElem);\n-\n- var propElem = this.createElementNS(\"\", \"PROPERTIES\");\n- getElem.appendChild(propElem);\n-\n- var props = request.get_image.properties;\n- if (props.featurecoordsys != null) {\n- var feat = this.createElementNS(\"\", \"FEATURECOORDSYS\");\n- propElem.appendChild(feat);\n+ getSiblingNodesByTagCriteria: function(node, criteria) {\n+ var nodes = [];\n+ var children, tagName, n, matchNodes, child;\n+ if (node && node.hasChildNodes()) {\n+ children = node.childNodes;\n+ n = children.length;\n \n- if (props.featurecoordsys.id === 0) {\n- feat.setAttribute(\"string\", props.featurecoordsys['string']);\n+ for (var k = 0; k < n; k++) {\n+ child = children[k];\n+ while (child && child.nodeType != 1) {\n+ child = child.nextSibling;\n+ k++;\n+ }\n+ tagName = (child ? child.nodeName : '');\n+ if (tagName.length > 0 && tagName.indexOf(criteria) > -1) {\n+ nodes.push(child);\n } else {\n- feat.setAttribute(\"id\", props.featurecoordsys.id);\n+ matchNodes = this.getSiblingNodesByTagCriteria(\n+ child, criteria);\n+\n+ if (matchNodes.length > 0) {\n+ (nodes.length == 0) ?\n+ nodes = matchNodes: nodes.push(matchNodes);\n+ }\n }\n }\n \n- if (props.filtercoordsys != null) {\n- var filt = this.createElementNS(\"\", \"FILTERCOORDSYS\");\n- propElem.appendChild(filt);\n-\n- if (props.filtercoordsys.id === 0) {\n- filt.setAttribute(\"string\", props.filtercoordsys.string);\n- } else {\n- filt.setAttribute(\"id\", props.filtercoordsys.id);\n- }\n- }\n-\n- if (props.envelope != null) {\n- var env = this.createElementNS(\"\", \"ENVELOPE\");\n- propElem.appendChild(env);\n-\n- env.setAttribute(\"minx\", props.envelope.minx);\n- env.setAttribute(\"miny\", props.envelope.miny);\n- env.setAttribute(\"maxx\", props.envelope.maxx);\n- env.setAttribute(\"maxy\", props.envelope.maxy);\n- }\n-\n- var imagesz = this.createElementNS(\"\", \"IMAGESIZE\");\n- propElem.appendChild(imagesz);\n-\n- imagesz.setAttribute(\"height\", props.imagesize.height);\n- imagesz.setAttribute(\"width\", props.imagesize.width);\n-\n- if (props.imagesize.height != props.imagesize.printheight ||\n- props.imagesize.width != props.imagesize.printwidth) {\n- imagesz.setAttribute(\"printheight\", props.imagesize.printheight);\n- imagesz.setArrtibute(\"printwidth\", props.imagesize.printwidth);\n- }\n-\n- if (props.background != null) {\n- var backgrnd = this.createElementNS(\"\", \"BACKGROUND\");\n- propElem.appendChild(backgrnd);\n-\n- backgrnd.setAttribute(\"color\",\n- props.background.color.r + \",\" +\n- props.background.color.g + \",\" +\n- props.background.color.b);\n-\n- if (props.background.transcolor !== null) {\n- backgrnd.setAttribute(\"transcolor\",\n- props.background.transcolor.r + \",\" +\n- props.background.transcolor.g + \",\" +\n- props.background.transcolor.b);\n- }\n- }\n-\n- if (props.layerlist != null && props.layerlist.length > 0) {\n- var layerlst = this.createElementNS(\"\", \"LAYERLIST\");\n- propElem.appendChild(layerlst);\n-\n- for (var ld = 0; ld < props.layerlist.length; ld++) {\n- var ldef = this.createElementNS(\"\", \"LAYERDEF\");\n- layerlst.appendChild(ldef);\n-\n- ldef.setAttribute(\"id\", props.layerlist[ld].id);\n- ldef.setAttribute(\"visible\", props.layerlist[ld].visible);\n-\n- if (typeof props.layerlist[ld].query == \"object\") {\n- var query = props.layerlist[ld].query;\n-\n- if (query.where.length < 0) {\n- continue;\n- }\n-\n- var queryElem = null;\n- if (typeof query.spatialfilter == \"boolean\" && query.spatialfilter) {\n- // handle spatial filter madness\n- queryElem = this.createElementNS(\"\", \"SPATIALQUERY\");\n- } else {\n- queryElem = this.createElementNS(\"\", \"QUERY\");\n- }\n-\n- queryElem.setAttribute(\"where\", query.where);\n-\n- if (typeof query.accuracy == \"number\" && query.accuracy > 0) {\n- queryElem.setAttribute(\"accuracy\", query.accuracy);\n- }\n- if (typeof query.featurelimit == \"number\" && query.featurelimit < 2000) {\n- queryElem.setAttribute(\"featurelimit\", query.featurelimit);\n- }\n- if (typeof query.subfields == \"string\" && query.subfields != \"#ALL#\") {\n- queryElem.setAttribute(\"subfields\", query.subfields);\n- }\n- if (typeof query.joinexpression == \"string\" && query.joinexpression.length > 0) {\n- queryElem.setAttribute(\"joinexpression\", query.joinexpression);\n- }\n- if (typeof query.jointables == \"string\" && query.jointables.length > 0) {\n- queryElem.setAttribute(\"jointables\", query.jointables);\n- }\n-\n- ldef.appendChild(queryElem);\n- }\n-\n- if (typeof props.layerlist[ld].renderer == \"object\") {\n- this.addRenderer(ldef, props.layerlist[ld].renderer);\n- }\n- }\n- }\n- } else if (request.get_feature != null) {\n- var getElem = this.createElementNS(\"\", \"GET_FEATURES\");\n- getElem.setAttribute(\"outputmode\", \"newxml\");\n- getElem.setAttribute(\"checkesc\", \"true\");\n-\n- if (request.get_feature.geometry) {\n- getElem.setAttribute(\"geometry\", request.get_feature.geometry);\n- } else {\n- getElem.setAttribute(\"geometry\", \"false\");\n- }\n-\n- if (request.get_feature.compact) {\n- getElem.setAttribute(\"compact\", request.get_feature.compact);\n- }\n-\n- if (request.get_feature.featurelimit == \"number\") {\n- getElem.setAttribute(\"featurelimit\", request.get_feature.featurelimit);\n- }\n-\n- getElem.setAttribute(\"globalenvelope\", \"true\");\n- reqElem.appendChild(getElem);\n-\n- if (request.get_feature.layer != null && request.get_feature.layer.length > 0) {\n- var lyrElem = this.createElementNS(\"\", \"LAYER\");\n- lyrElem.setAttribute(\"id\", request.get_feature.layer);\n- getElem.appendChild(lyrElem);\n- }\n-\n- var fquery = request.get_feature.query;\n- if (fquery != null) {\n- var qElem = null;\n- if (fquery.isspatial) {\n- qElem = this.createElementNS(\"\", \"SPATIALQUERY\");\n- } else {\n- qElem = this.createElementNS(\"\", \"QUERY\");\n- }\n- getElem.appendChild(qElem);\n-\n- if (typeof fquery.accuracy == \"number\") {\n- qElem.setAttribute(\"accuracy\", fquery.accuracy);\n- }\n- //qElem.setAttribute(\"featurelimit\", \"5\");\n-\n- if (fquery.featurecoordsys != null) {\n- var fcsElem1 = this.createElementNS(\"\", \"FEATURECOORDSYS\");\n-\n- if (fquery.featurecoordsys.id == 0) {\n- fcsElem1.setAttribute(\"string\", fquery.featurecoordsys.string);\n- } else {\n- fcsElem1.setAttribute(\"id\", fquery.featurecoordsys.id);\n- }\n- qElem.appendChild(fcsElem1);\n- }\n-\n- if (fquery.filtercoordsys != null) {\n- var fcsElem2 = this.createElementNS(\"\", \"FILTERCOORDSYS\");\n-\n- if (fquery.filtercoordsys.id === 0) {\n- fcsElem2.setAttribute(\"string\", fquery.filtercoordsys.string);\n- } else {\n- fcsElem2.setAttribute(\"id\", fquery.filtercoordsys.id);\n- }\n- qElem.appendChild(fcsElem2);\n- }\n-\n- if (fquery.buffer > 0) {\n- var bufElem = this.createElementNS(\"\", \"BUFFER\");\n- bufElem.setAttribute(\"distance\", fquery.buffer);\n- qElem.appendChild(bufElem);\n- }\n-\n- if (fquery.isspatial) {\n- var spfElem = this.createElementNS(\"\", \"SPATIALFILTER\");\n- spfElem.setAttribute(\"relation\", fquery.spatialfilter.relation);\n- qElem.appendChild(spfElem);\n-\n- if (fquery.spatialfilter.envelope) {\n- var envElem = this.createElementNS(\"\", \"ENVELOPE\");\n- envElem.setAttribute(\"minx\", fquery.spatialfilter.envelope.minx);\n- envElem.setAttribute(\"miny\", fquery.spatialfilter.envelope.miny);\n- envElem.setAttribute(\"maxx\", fquery.spatialfilter.envelope.maxx);\n- envElem.setAttribute(\"maxy\", fquery.spatialfilter.envelope.maxy);\n- spfElem.appendChild(envElem);\n- } else if (typeof fquery.spatialfilter.polygon == \"object\") {\n- spfElem.appendChild(this.writePolygonGeometry(fquery.spatialfilter.polygon));\n- }\n- }\n-\n- if (fquery.where != null && fquery.where.length > 0) {\n- qElem.setAttribute(\"where\", fquery.where);\n- }\n- }\n- }\n-\n- root.appendChild(reqElem);\n-\n- return OpenLayers.Format.XML.prototype.write.apply(this, [root]);\n- },\n-\n-\n- addGroupRenderer: function(ldef, toprenderer) {\n- var topRelem = this.createElementNS(\"\", \"GROUPRENDERER\");\n- ldef.appendChild(topRelem);\n-\n- for (var rind = 0; rind < toprenderer.length; rind++) {\n- var renderer = toprenderer[rind];\n- this.addRenderer(topRelem, renderer);\n- }\n- },\n-\n-\n- addRenderer: function(topRelem, renderer) {\n- if (OpenLayers.Util.isArray(renderer)) {\n- this.addGroupRenderer(topRelem, renderer);\n- } else {\n- var renderElem = this.createElementNS(\"\", renderer.type.toUpperCase() + \"RENDERER\");\n- topRelem.appendChild(renderElem);\n-\n- if (renderElem.tagName == \"VALUEMAPRENDERER\") {\n- this.addValueMapRenderer(renderElem, renderer);\n- } else if (renderElem.tagName == \"VALUEMAPLABELRENDERER\") {\n- this.addValueMapLabelRenderer(renderElem, renderer);\n- } else if (renderElem.tagName == \"SIMPLELABELRENDERER\") {\n- this.addSimpleLabelRenderer(renderElem, renderer);\n- } else if (renderElem.tagName == \"SCALEDEPENDENTRENDERER\") {\n- this.addScaleDependentRenderer(renderElem, renderer);\n- }\n- }\n- },\n-\n-\n- addScaleDependentRenderer: function(renderElem, renderer) {\n- if (typeof renderer.lower == \"string\" || typeof renderer.lower == \"number\") {\n- renderElem.setAttribute(\"lower\", renderer.lower);\n- }\n- if (typeof renderer.upper == \"string\" || typeof renderer.upper == \"number\") {\n- renderElem.setAttribute(\"upper\", renderer.upper);\n- }\n-\n- this.addRenderer(renderElem, renderer.renderer);\n- },\n-\n-\n- addValueMapLabelRenderer: function(renderElem, renderer) {\n- renderElem.setAttribute(\"lookupfield\", renderer.lookupfield);\n- renderElem.setAttribute(\"labelfield\", renderer.labelfield);\n-\n- if (typeof renderer.exacts == \"object\") {\n- for (var ext = 0, extlen = renderer.exacts.length; ext < extlen; ext++) {\n- var exact = renderer.exacts[ext];\n-\n- var eelem = this.createElementNS(\"\", \"EXACT\");\n-\n- if (typeof exact.value == \"string\") {\n- eelem.setAttribute(\"value\", exact.value);\n- }\n- if (typeof exact.label == \"string\") {\n- eelem.setAttribute(\"label\", exact.label);\n- }\n- if (typeof exact.method == \"string\") {\n- eelem.setAttribute(\"method\", exact.method);\n- }\n-\n- renderElem.appendChild(eelem);\n-\n- if (typeof exact.symbol == \"object\") {\n- var selem = null;\n-\n- if (exact.symbol.type == \"text\") {\n- selem = this.createElementNS(\"\", \"TEXTSYMBOL\");\n- }\n-\n- if (selem != null) {\n- var keys = this.fontStyleKeys;\n- for (var i = 0, len = keys.length; i < len; i++) {\n- var key = keys[i];\n- if (exact.symbol[key]) {\n- selem.setAttribute(key, exact.symbol[key]);\n- }\n- }\n- eelem.appendChild(selem);\n- }\n- }\n- } // for each exact\n- }\n- },\n-\n- addValueMapRenderer: function(renderElem, renderer) {\n- renderElem.setAttribute(\"lookupfield\", renderer.lookupfield);\n-\n- if (typeof renderer.ranges == \"object\") {\n- for (var rng = 0, rnglen = renderer.ranges.length; rng < rnglen; rng++) {\n- var range = renderer.ranges[rng];\n-\n- var relem = this.createElementNS(\"\", \"RANGE\");\n- relem.setAttribute(\"lower\", range.lower);\n- relem.setAttribute(\"upper\", range.upper);\n-\n- renderElem.appendChild(relem);\n-\n- if (typeof range.symbol == \"object\") {\n- var selem = null;\n-\n- if (range.symbol.type == \"simplepolygon\") {\n- selem = this.createElementNS(\"\", \"SIMPLEPOLYGONSYMBOL\");\n- }\n-\n- if (selem != null) {\n- if (typeof range.symbol.boundarycolor == \"string\") {\n- selem.setAttribute(\"boundarycolor\", range.symbol.boundarycolor);\n- }\n- if (typeof range.symbol.fillcolor == \"string\") {\n- selem.setAttribute(\"fillcolor\", range.symbol.fillcolor);\n- }\n- if (typeof range.symbol.filltransparency == \"number\") {\n- selem.setAttribute(\"filltransparency\", range.symbol.filltransparency);\n- }\n- relem.appendChild(selem);\n- }\n- }\n- } // for each range\n- } else if (typeof renderer.exacts == \"object\") {\n- for (var ext = 0, extlen = renderer.exacts.length; ext < extlen; ext++) {\n- var exact = renderer.exacts[ext];\n-\n- var eelem = this.createElementNS(\"\", \"EXACT\");\n- if (typeof exact.value == \"string\") {\n- eelem.setAttribute(\"value\", exact.value);\n- }\n- if (typeof exact.label == \"string\") {\n- eelem.setAttribute(\"label\", exact.label);\n- }\n- if (typeof exact.method == \"string\") {\n- eelem.setAttribute(\"method\", exact.method);\n- }\n-\n- renderElem.appendChild(eelem);\n-\n- if (typeof exact.symbol == \"object\") {\n- var selem = null;\n-\n- if (exact.symbol.type == \"simplemarker\") {\n- selem = this.createElementNS(\"\", \"SIMPLEMARKERSYMBOL\");\n- }\n-\n- if (selem != null) {\n- if (typeof exact.symbol.antialiasing == \"string\") {\n- selem.setAttribute(\"antialiasing\", exact.symbol.antialiasing);\n- }\n- if (typeof exact.symbol.color == \"string\") {\n- selem.setAttribute(\"color\", exact.symbol.color);\n- }\n- if (typeof exact.symbol.outline == \"string\") {\n- selem.setAttribute(\"outline\", exact.symbol.outline);\n- }\n- if (typeof exact.symbol.overlap == \"string\") {\n- selem.setAttribute(\"overlap\", exact.symbol.overlap);\n- }\n- if (typeof exact.symbol.shadow == \"string\") {\n- selem.setAttribute(\"shadow\", exact.symbol.shadow);\n- }\n- if (typeof exact.symbol.transparency == \"number\") {\n- selem.setAttribute(\"transparency\", exact.symbol.transparency);\n- }\n- //if (typeof exact.symbol.type == \"string\")\n- // selem.setAttribute(\"type\", exact.symbol.type);\n- if (typeof exact.symbol.usecentroid == \"string\") {\n- selem.setAttribute(\"usecentroid\", exact.symbol.usecentroid);\n- }\n- if (typeof exact.symbol.width == \"number\") {\n- selem.setAttribute(\"width\", exact.symbol.width);\n- }\n-\n- eelem.appendChild(selem);\n- }\n- }\n- } // for each exact\n- }\n- },\n-\n-\n- addSimpleLabelRenderer: function(renderElem, renderer) {\n- renderElem.setAttribute(\"field\", renderer.field);\n- var keys = ['featureweight', 'howmanylabels', 'labelbufferratio',\n- 'labelpriorities', 'labelweight', 'linelabelposition',\n- 'rotationalangles'\n- ];\n- for (var i = 0, len = keys.length; i < len; i++) {\n- var key = keys[i];\n- if (renderer[key]) {\n- renderElem.setAttribute(key, renderer[key]);\n- }\n- }\n-\n- if (renderer.symbol.type == \"text\") {\n- var symbol = renderer.symbol;\n- var selem = this.createElementNS(\"\", \"TEXTSYMBOL\");\n- renderElem.appendChild(selem);\n-\n- var keys = this.fontStyleKeys;\n- for (var i = 0, len = keys.length; i < len; i++) {\n- var key = keys[i];\n- if (symbol[key]) {\n- selem.setAttribute(key, renderer[key]);\n- }\n- }\n- }\n- },\n-\n- writePolygonGeometry: function(polygon) {\n- if (!(polygon instanceof OpenLayers.Geometry.Polygon)) {\n- throw {\n- message: 'Cannot write polygon geometry to ArcXML with an ' +\n- polygon.CLASS_NAME + ' object.',\n- geometry: polygon\n- };\n- }\n-\n- var polyElem = this.createElementNS(\"\", \"POLYGON\");\n-\n- for (var ln = 0, lnlen = polygon.components.length; ln < lnlen; ln++) {\n- var ring = polygon.components[ln];\n- var ringElem = this.createElementNS(\"\", \"RING\");\n-\n- for (var rn = 0, rnlen = ring.components.length; rn < rnlen; rn++) {\n- var point = ring.components[rn];\n- var pointElem = this.createElementNS(\"\", \"POINT\");\n-\n- pointElem.setAttribute(\"x\", point.x);\n- pointElem.setAttribute(\"y\", point.y);\n-\n- ringElem.appendChild(pointElem);\n- }\n-\n- polyElem.appendChild(ringElem);\n- }\n-\n- return polyElem;\n- },\n-\n- /**\n- * Method: parseResponse\n- * Take an ArcXML response, and parse in into this object's internal properties.\n- *\n- * Parameters:\n- * data - {String} or {DOMElement} The ArcXML response, as either a string or the\n- * top level DOMElement of the response.\n- */\n- parseResponse: function(data) {\n- if (typeof data == \"string\") {\n- var newData = new OpenLayers.Format.XML();\n- data = newData.read(data);\n- }\n- var response = new OpenLayers.Format.ArcXML.Response();\n-\n- var errorNode = data.getElementsByTagName(\"ERROR\");\n-\n- if (errorNode != null && errorNode.length > 0) {\n- response.error = this.getChildValue(errorNode, \"Unknown error.\");\n- } else {\n- var responseNode = data.getElementsByTagName(\"RESPONSE\");\n-\n- if (responseNode == null || responseNode.length == 0) {\n- response.error = \"No RESPONSE tag found in ArcXML response.\";\n- return response;\n- }\n-\n- var rtype = responseNode[0].firstChild.nodeName;\n- if (rtype == \"#text\") {\n- rtype = responseNode[0].firstChild.nextSibling.nodeName;\n- }\n-\n- if (rtype == \"IMAGE\") {\n- var envelopeNode = data.getElementsByTagName(\"ENVELOPE\");\n- var outputNode = data.getElementsByTagName(\"OUTPUT\");\n-\n- if (envelopeNode == null || envelopeNode.length == 0) {\n- response.error = \"No ENVELOPE tag found in ArcXML response.\";\n- } else if (outputNode == null || outputNode.length == 0) {\n- response.error = \"No OUTPUT tag found in ArcXML response.\";\n- } else {\n- var envAttr = this.parseAttributes(envelopeNode[0]);\n- var outputAttr = this.parseAttributes(outputNode[0]);\n-\n- if (typeof outputAttr.type == \"string\") {\n- response.image = {\n- envelope: envAttr,\n- output: {\n- type: outputAttr.type,\n- data: this.getChildValue(outputNode[0])\n- }\n- };\n- } else {\n- response.image = {\n- envelope: envAttr,\n- output: outputAttr\n- };\n- }\n- }\n- } else if (rtype == \"FEATURES\") {\n- var features = responseNode[0].getElementsByTagName(\"FEATURES\");\n-\n- // get the feature count\n- var featureCount = features[0].getElementsByTagName(\"FEATURECOUNT\");\n- response.features.featurecount = featureCount[0].getAttribute(\"count\");\n-\n- if (response.features.featurecount > 0) {\n- // get the feature envelope\n- var envelope = features[0].getElementsByTagName(\"ENVELOPE\");\n- response.features.envelope = this.parseAttributes(envelope[0], typeof(0));\n-\n- // get the field values per feature\n- var featureList = features[0].getElementsByTagName(\"FEATURE\");\n- for (var fn = 0; fn < featureList.length; fn++) {\n- var feature = new OpenLayers.Feature.Vector();\n- var fields = featureList[fn].getElementsByTagName(\"FIELD\");\n-\n- for (var fdn = 0; fdn < fields.length; fdn++) {\n- var fieldName = fields[fdn].getAttribute(\"name\");\n- var fieldValue = fields[fdn].getAttribute(\"value\");\n- feature.attributes[fieldName] = fieldValue;\n- }\n-\n- var geom = featureList[fn].getElementsByTagName(\"POLYGON\");\n-\n- if (geom.length > 0) {\n- // if there is a polygon, create an openlayers polygon, and assign\n- // it to the .geometry property of the feature\n- var ring = geom[0].getElementsByTagName(\"RING\");\n-\n- var polys = [];\n- for (var rn = 0; rn < ring.length; rn++) {\n- var linearRings = [];\n- linearRings.push(this.parsePointGeometry(ring[rn]));\n-\n- var holes = ring[rn].getElementsByTagName(\"HOLE\");\n- for (var hn = 0; hn < holes.length; hn++) {\n- linearRings.push(this.parsePointGeometry(holes[hn]));\n- }\n- holes = null;\n- polys.push(new OpenLayers.Geometry.Polygon(linearRings));\n- linearRings = null;\n- }\n- ring = null;\n-\n- if (polys.length == 1) {\n- feature.geometry = polys[0];\n- } else {\n- feature.geometry = new OpenLayers.Geometry.MultiPolygon(polys);\n- }\n- }\n-\n- response.features.feature.push(feature);\n- }\n- }\n- } else {\n- response.error = \"Unidentified response type.\";\n- }\n }\n- return response;\n+ return nodes;\n },\n \n-\n /**\n * Method: parseAttributes\n *\n * Parameters:\n- * node - {} An element to parse attributes from.\n+ * node - {}\n *\n * Returns:\n- * {Object} An attributes object, with properties set to attribute values.\n+ * {Object} An attributes object.\n+ * \n+ * Notes:\n+ * Assumes that attributes are direct child xml nodes of the passed node\n+ * and contain only a single text node. \n */\n- parseAttributes: function(node, type) {\n+ parseAttributes: function(node) {\n var attributes = {};\n- for (var attr = 0; attr < node.attributes.length; attr++) {\n- if (type == \"number\") {\n- attributes[node.attributes[attr].nodeName] = parseFloat(node.attributes[attr].nodeValue);\n- } else {\n- attributes[node.attributes[attr].nodeName] = node.attributes[attr].nodeValue;\n+ if (node.nodeType == 1) {\n+ var children = node.childNodes;\n+ var n = children.length;\n+ for (var i = 0; i < n; ++i) {\n+ var child = children[i];\n+ if (child.nodeType == 1) {\n+ var grandchildren = child.childNodes;\n+ var name = (child.prefix) ?\n+ child.nodeName.split(\":\")[1] : child.nodeName;\n+ if (grandchildren.length == 0) {\n+ attributes[name] = null;\n+ } else if (grandchildren.length == 1) {\n+ var grandchild = grandchildren[0];\n+ if (grandchild.nodeType == 3 ||\n+ grandchild.nodeType == 4) {\n+ var value = grandchild.nodeValue.replace(\n+ this.regExes.trimSpace, \"\");\n+ attributes[name] = value;\n+ }\n+ }\n+ }\n }\n }\n return attributes;\n },\n \n-\n /**\n- * Method: parsePointGeometry\n+ * Method: parseGeometry\n+ * Parse the geometry and the feature bounds out of the node using \n+ * Format.GML\n *\n * Parameters:\n- * node - {} An element to parse or arcxml data from.\n+ * node - {}\n *\n * Returns:\n- * {} A linear ring represented by the node's points.\n+ * {Object} An object containing the geometry and the feature bounds\n */\n- parsePointGeometry: function(node) {\n- var ringPoints = [];\n- var coords = node.getElementsByTagName(\"COORDS\");\n-\n- if (coords.length > 0) {\n- // if coords is present, it's the only coords item\n- var coordArr = this.getChildValue(coords[0]);\n- coordArr = coordArr.split(/;/);\n- for (var cn = 0; cn < coordArr.length; cn++) {\n- var coordItems = coordArr[cn].split(/ /);\n- ringPoints.push(new OpenLayers.Geometry.Point(coordItems[0], coordItems[1]));\n- }\n- coords = null;\n- } else {\n- var point = node.getElementsByTagName(\"POINT\");\n- if (point.length > 0) {\n- for (var pn = 0; pn < point.length; pn++) {\n- ringPoints.push(\n- new OpenLayers.Geometry.Point(\n- parseFloat(point[pn].getAttribute(\"x\")),\n- parseFloat(point[pn].getAttribute(\"y\"))\n- )\n- );\n- }\n- }\n- point = null;\n+ parseGeometry: function(node) {\n+ // we need to use the old Format.GML parser since we do not know the \n+ // geometry name\n+ if (!this.gmlFormat) {\n+ this.gmlFormat = new OpenLayers.Format.GML();\n }\n-\n- return new OpenLayers.Geometry.LinearRing(ringPoints);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Format.ArcXML\"\n-});\n-\n-OpenLayers.Format.ArcXML.Request = OpenLayers.Class({\n- initialize: function(params) {\n- var defaults = {\n- get_image: {\n- properties: {\n- background: null,\n- /*{ \n- color: { r:255, g:255, b:255 },\n- transcolor: null\n- },*/\n- draw: true,\n- envelope: {\n- minx: 0,\n- miny: 0,\n- maxx: 0,\n- maxy: 0\n- },\n- featurecoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- filtercoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- imagesize: {\n- height: 0,\n- width: 0,\n- dpi: 96,\n- printheight: 0,\n- printwidth: 0,\n- scalesymbols: false\n- },\n- layerlist: [],\n- /* no support for legends */\n- output: {\n- baseurl: \"\",\n- legendbaseurl: \"\",\n- legendname: \"\",\n- legendpath: \"\",\n- legendurl: \"\",\n- name: \"\",\n- path: \"\",\n- type: \"jpg\",\n- url: \"\"\n- }\n- }\n- },\n-\n- get_feature: {\n- layer: \"\",\n- query: {\n- isspatial: false,\n- featurecoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- filtercoordsys: {\n- id: 0,\n- string: \"\",\n- datumtransformid: 0,\n- datumtransformstring: \"\"\n- },\n- buffer: 0,\n- where: \"\",\n- spatialfilter: {\n- relation: \"envelope_intersection\",\n- envelope: null\n- }\n- }\n- },\n-\n- environment: {\n- separators: {\n- cs: \" \",\n- ts: \";\"\n- }\n- },\n-\n- layer: [],\n- workspaces: []\n+ var feature = this.gmlFormat.parseFeature(node);\n+ var geometry, bounds = null;\n+ if (feature) {\n+ geometry = feature.geometry && feature.geometry.clone();\n+ bounds = feature.bounds && feature.bounds.clone();\n+ feature.destroy();\n+ }\n+ return {\n+ geometry: geometry,\n+ bounds: bounds\n };\n-\n- return OpenLayers.Util.extend(this, defaults);\n },\n \n- CLASS_NAME: \"OpenLayers.Format.ArcXML.Request\"\n-});\n-\n-OpenLayers.Format.ArcXML.Response = OpenLayers.Class({\n- initialize: function(params) {\n- var defaults = {\n- image: {\n- envelope: null,\n- output: ''\n- },\n-\n- features: {\n- featurecount: 0,\n- envelope: null,\n- feature: []\n- },\n-\n- error: ''\n- };\n-\n- return OpenLayers.Util.extend(this, defaults);\n- },\n+ CLASS_NAME: \"OpenLayers.Format.WMSGetFeatureInfo\"\n \n- CLASS_NAME: \"OpenLayers.Format.ArcXML.Response\"\n });\n /* ======================================================================\n- OpenLayers/Layer/ArcIMS.js\n+ OpenLayers/Control/WMSGetFeatureInfo.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Layer/Grid.js\n- * @requires OpenLayers/Format/ArcXML.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Click.js\n+ * @requires OpenLayers/Handler/Hover.js\n * @requires OpenLayers/Request.js\n+ * @requires OpenLayers/Format/WMSGetFeatureInfo.js\n */\n \n /**\n- * Class: OpenLayers.Layer.ArcIMS\n- * Instances of OpenLayers.Layer.ArcIMS are used to display data from ESRI ArcIMS\n- * Mapping Services. Create a new ArcIMS layer with the \n- * constructor.\n- * \n+ * Class: OpenLayers.Control.WMSGetFeatureInfo\n+ * The WMSGetFeatureInfo control uses a WMS query to get information about a point on the map. The\n+ * information may be in a display-friendly format such as HTML, or a machine-friendly format such\n+ * as GML, depending on the server's capabilities and the client's configuration. This control\n+ * handles click or hover events, attempts to parse the results using an OpenLayers.Format, and\n+ * fires a 'getfeatureinfo' event with the click position, the raw body of the response, and an\n+ * array of features if it successfully read the response.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.WMSGetFeatureInfo = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Constant: DEFAULT_PARAMS\n- * {Object} Default query string parameters.\n+ * APIProperty: hover\n+ * {Boolean} Send GetFeatureInfo requests when mouse stops moving.\n+ * Default is false.\n */\n- DEFAULT_PARAMS: {\n- ClientVersion: \"9.2\",\n- ServiceName: ''\n- },\n+ hover: false,\n \n /**\n- * APIProperty: featureCoordSys\n- * {String} Code for feature coordinate system. Default is \"4326\".\n+ * APIProperty: drillDown\n+ * {Boolean} Drill down over all WMS layers in the map. When\n+ * using drillDown mode, hover is not possible, and an infoFormat that\n+ * returns parseable features is required. Default is false.\n */\n- featureCoordSys: \"4326\",\n+ drillDown: false,\n \n /**\n- * APIProperty: filterCoordSys\n- * {String} Code for filter coordinate system. Default is \"4326\".\n+ * APIProperty: maxFeatures\n+ * {Integer} Maximum number of features to return from a WMS query. This\n+ * sets the feature_count parameter on WMS GetFeatureInfo\n+ * requests.\n */\n- filterCoordSys: \"4326\",\n+ maxFeatures: 10,\n+\n+ /**\n+ * APIProperty: clickCallback\n+ * {String} The click callback to register in the\n+ * {} object created when the hover\n+ * option is set to false. Default is \"click\".\n+ */\n+ clickCallback: \"click\",\n+\n+ /**\n+ * APIProperty: output\n+ * {String} Either \"features\" or \"object\". When triggering a getfeatureinfo\n+ * request should we pass on an array of features or an object with with\n+ * a \"features\" property and other properties (such as the url of the\n+ * WMS). Default is \"features\".\n+ */\n+ output: \"features\",\n \n /**\n * APIProperty: layers\n- * {Array} An array of objects with layer properties.\n+ * {Array()} The layers to query for feature info.\n+ * If omitted, all map WMS layers with a url that matches this or\n+ * will be considered.\n */\n layers: null,\n \n /**\n- * APIProperty: async\n- * {Boolean} Request images asynchronously. Default is true.\n+ * APIProperty: queryVisible\n+ * {Boolean} If true, filter out hidden layers when searching the map for\n+ * layers to query. Default is false.\n */\n- async: true,\n+ queryVisible: false,\n \n /**\n- * APIProperty: name\n- * {String} Layer name. Default is \"ArcIMS\".\n+ * APIProperty: url\n+ * {String} The URL of the WMS service to use. If not provided, the url\n+ * of the first eligible layer will be used.\n */\n- name: \"ArcIMS\",\n+ url: null,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} The layer is a base layer. Default is true.\n+ * APIProperty: layerUrls\n+ * {Array(String)} Optional list of urls for layers that should be queried.\n+ * This can be used when the layer url differs from the url used for\n+ * making GetFeatureInfo requests (in the case of a layer using cached\n+ * tiles).\n */\n- isBaseLayer: true,\n+ layerUrls: null,\n \n /**\n- * Constant: DEFAULT_OPTIONS\n- * {Object} Default layers properties.\n+ * APIProperty: infoFormat\n+ * {String} The mimetype to request from the server. If you are using\n+ * drillDown mode and have multiple servers that do not share a common\n+ * infoFormat, you can override the control's infoFormat by providing an\n+ * INFO_FORMAT parameter in your instance(s).\n */\n- DEFAULT_OPTIONS: {\n- tileSize: new OpenLayers.Size(512, 512),\n- featureCoordSys: \"4326\",\n- filterCoordSys: \"4326\",\n- layers: null,\n- isBaseLayer: true,\n- async: true,\n- name: \"ArcIMS\"\n- },\n+ infoFormat: 'text/html',\n \n /**\n- * Constructor: OpenLayers.Layer.ArcIMS\n- * Create a new ArcIMS layer object.\n- *\n- * Example:\n- * (code)\n- * var arcims = new OpenLayers.Layer.ArcIMS(\n- * \"Global Sample\",\n- * \"http://sample.avencia.com/servlet/com.esri.esrimap.Esrimap\", \n- * {\n- * service: \"OpenLayers_Sample\", \n- * layers: [\n- * // layers to manipulate\n- * {id: \"1\", visible: true}\n- * ]\n- * }\n- * );\n+ * APIProperty: vendorParams\n+ * {Object} Additional parameters that will be added to the request, for\n+ * WMS implementations that support them. This could e.g. look like\n+ * (start code)\n+ * {\n+ * radius: 5\n+ * }\n * (end)\n- *\n- * Parameters:\n- * name - {String} A name for the layer\n- * url - {String} Base url for the ArcIMS server\n- * options - {Object} Optional object with properties to be set on the\n- * layer.\n */\n- initialize: function(name, url, options) {\n-\n- this.tileSize = new OpenLayers.Size(512, 512);\n-\n- // parameters\n- this.params = OpenLayers.Util.applyDefaults({\n- ServiceName: options.serviceName\n- },\n- this.DEFAULT_PARAMS\n- );\n- this.options = OpenLayers.Util.applyDefaults(\n- options, this.DEFAULT_OPTIONS\n- );\n+ vendorParams: {},\n \n- OpenLayers.Layer.Grid.prototype.initialize.apply(\n- this, [name, url, this.params, options]\n- );\n+ /**\n+ * APIProperty: format\n+ * {} A format for parsing GetFeatureInfo responses.\n+ * Default is .\n+ */\n+ format: null,\n \n- //layer is transparent \n- if (this.transparent) {\n+ /**\n+ * APIProperty: formatOptions\n+ * {Object} Optional properties to set on the format (if one is not provided\n+ * in the property.\n+ */\n+ formatOptions: null,\n \n- // unless explicitly set in options, make layer an overlay\n- if (!this.isBaseLayer) {\n- this.isBaseLayer = false;\n- }\n+ /**\n+ * APIProperty: handlerOptions\n+ * {Object} Additional options for the handlers used by this control, e.g.\n+ * (start code)\n+ * {\n+ * \"click\": {delay: 100},\n+ * \"hover\": {delay: 300}\n+ * }\n+ * (end)\n+ */\n \n- // jpegs can never be transparent, so intelligently switch the \n- // format, depending on the browser's capabilities\n- if (this.format == \"image/jpeg\") {\n- this.format = OpenLayers.Util.alphaHack() ? \"image/gif\" : \"image/png\";\n- }\n- }\n+ /**\n+ * Property: handler\n+ * {Object} Reference to the for this control\n+ */\n+ handler: null,\n \n- // create an empty layer list if no layers specified in the options\n- if (this.options.layers === null) {\n- this.options.layers = [];\n- }\n- },\n+ /**\n+ * Property: hoverRequest\n+ * {} contains the currently running hover request\n+ * (if any).\n+ */\n+ hoverRequest: null,\n \n /**\n- * Method: getURL\n- * Return an image url this layer.\n+ * APIProperty: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n *\n- * Parameters:\n- * bounds - {} A bounds representing the bbox for the\n- * request.\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * control.events.register(type, obj, listener);\n+ * (end)\n *\n- * Returns:\n- * {String} A string with the map image's url.\n+ * Supported event types (in addition to those from ):\n+ * beforegetfeatureinfo - Triggered before the request is sent.\n+ * The event object has an *xy* property with the position of the\n+ * mouse click or hover event that triggers the request.\n+ * nogetfeatureinfo - no queryable layers were found.\n+ * getfeatureinfo - Triggered when a GetFeatureInfo response is received.\n+ * The event object has a *text* property with the body of the\n+ * response (String), a *features* property with an array of the\n+ * parsed features, an *xy* property with the position of the mouse\n+ * click or hover event that triggered the request, and a *request*\n+ * property with the request itself. If drillDown is set to true and\n+ * multiple requests were issued to collect feature info from all\n+ * layers, *text* and *request* will only contain the response body\n+ * and request object of the last request.\n */\n- getURL: function(bounds) {\n- var url = \"\";\n- bounds = this.adjustBounds(bounds);\n \n- // create an arcxml request to generate the image\n- var axlReq = new OpenLayers.Format.ArcXML(\n- OpenLayers.Util.extend(this.options, {\n- requesttype: \"image\",\n- envelope: bounds.toArray(),\n- tileSize: this.tileSize\n- })\n- );\n-\n- // create a synchronous ajax request to get an arcims image\n- var req = new OpenLayers.Request.POST({\n- url: this.getFullRequestString(),\n- data: axlReq.write(),\n- async: false\n- });\n+ /**\n+ * Constructor: \n+ *\n+ * Parameters:\n+ * options - {Object}\n+ */\n+ initialize: function(options) {\n+ options = options || {};\n+ options.handlerOptions = options.handlerOptions || {};\n \n- // if the response exists\n- if (req != null) {\n- var doc = req.responseXML;\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n \n- if (!doc || !doc.documentElement) {\n- doc = req.responseText;\n- }\n+ if (!this.format) {\n+ this.format = new OpenLayers.Format.WMSGetFeatureInfo(\n+ options.formatOptions\n+ );\n+ }\n \n- // create a new arcxml format to read the response\n- var axlResp = new OpenLayers.Format.ArcXML();\n- var arcxml = axlResp.read(doc);\n- url = this.getUrlOrImage(arcxml.image.output);\n+ if (this.drillDown === true) {\n+ this.hover = false;\n }\n \n- return url;\n+ if (this.hover) {\n+ this.handler = new OpenLayers.Handler.Hover(\n+ this, {\n+ 'move': this.cancelHover,\n+ 'pause': this.getInfoForHover\n+ },\n+ OpenLayers.Util.extend(this.handlerOptions.hover || {}, {\n+ 'delay': 250\n+ }));\n+ } else {\n+ var callbacks = {};\n+ callbacks[this.clickCallback] = this.getInfoForClick;\n+ this.handler = new OpenLayers.Handler.Click(\n+ this, callbacks, this.handlerOptions.click || {});\n+ }\n },\n \n-\n /**\n- * Method: getURLasync\n- * Get an image url this layer asynchronously, and execute a callback\n- * when the image url is generated.\n+ * Method: getInfoForClick\n+ * Called on click\n *\n * Parameters:\n- * bounds - {} A bounds representing the bbox for the\n- * request.\n- * callback - {Function} Function to call when image url is retrieved.\n- * scope - {Object} The scope of the callback method.\n+ * evt - {}\n */\n- getURLasync: function(bounds, callback, scope) {\n- bounds = this.adjustBounds(bounds);\n+ getInfoForClick: function(evt) {\n+ this.events.triggerEvent(\"beforegetfeatureinfo\", {\n+ xy: evt.xy\n+ });\n+ // Set the cursor to \"wait\" to tell the user we're working on their\n+ // click.\n+ OpenLayers.Element.addClass(this.map.viewPortDiv, \"olCursorWait\");\n+ this.request(evt.xy, {});\n+ },\n \n- // create an arcxml request to generate the image\n- var axlReq = new OpenLayers.Format.ArcXML(\n- OpenLayers.Util.extend(this.options, {\n- requesttype: \"image\",\n- envelope: bounds.toArray(),\n- tileSize: this.tileSize\n- })\n- );\n+ /**\n+ * Method: getInfoForHover\n+ * Pause callback for the hover handler\n+ *\n+ * Parameters:\n+ * evt - {Object}\n+ */\n+ getInfoForHover: function(evt) {\n+ this.events.triggerEvent(\"beforegetfeatureinfo\", {\n+ xy: evt.xy\n+ });\n+ this.request(evt.xy, {\n+ hover: true\n+ });\n+ },\n \n- // create an asynchronous ajax request to get an arcims image\n- OpenLayers.Request.POST({\n- url: this.getFullRequestString(),\n- async: true,\n- data: axlReq.write(),\n- callback: function(req) {\n- // process the response from ArcIMS, and call the callback function\n- // to set the image URL\n- var doc = req.responseXML;\n- if (!doc || !doc.documentElement) {\n- doc = req.responseText;\n- }\n+ /**\n+ * Method: cancelHover\n+ * Cancel callback for the hover handler\n+ */\n+ cancelHover: function() {\n+ if (this.hoverRequest) {\n+ this.hoverRequest.abort();\n+ this.hoverRequest = null;\n+ }\n+ },\n \n- // create a new arcxml format to read the response\n- var axlResp = new OpenLayers.Format.ArcXML();\n- var arcxml = axlResp.read(doc);\n+ /**\n+ * Method: findLayers\n+ * Internal method to get the layers, independent of whether we are\n+ * inspecting the map or using a client-provided array\n+ */\n+ findLayers: function() {\n \n- callback.call(scope, this.getUrlOrImage(arcxml.image.output));\n- },\n- scope: this\n- });\n+ var candidates = this.layers || this.map.layers;\n+ var layers = [];\n+ var layer, url;\n+ for (var i = candidates.length - 1; i >= 0; --i) {\n+ layer = candidates[i];\n+ if (layer instanceof OpenLayers.Layer.WMS &&\n+ (!this.queryVisible || layer.getVisibility())) {\n+ url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;\n+ // if the control was not configured with a url, set it\n+ // to the first layer url\n+ if (this.drillDown === false && !this.url) {\n+ this.url = url;\n+ }\n+ if (this.drillDown === true || this.urlMatches(url)) {\n+ layers.push(layer);\n+ }\n+ }\n+ }\n+ return layers;\n },\n \n /**\n- * Method: getUrlOrImage\n- * Extract a url or image from the ArcXML image output.\n+ * Method: urlMatches\n+ * Test to see if the provided url matches either the control or one\n+ * of the .\n *\n * Parameters:\n- * output - {Object} The image.output property of the object returned from\n- * the ArcXML format read method.\n+ * url - {String} The url to test.\n *\n * Returns:\n- * {String} A URL for an image (potentially with the data protocol).\n+ * {Boolean} The provided url matches the control or one of the\n+ * .\n */\n- getUrlOrImage: function(output) {\n- var ret = \"\";\n- if (output.url) {\n- // If the image response output url is a string, then the image\n- // data is not inline.\n- ret = output.url;\n- } else if (output.data) {\n- // The image data is inline and base64 encoded, create a data\n- // url for the image. This will only work for small images,\n- // due to browser url length limits.\n- ret = \"data:image/\" + output.type +\n- \";base64,\" + output.data;\n+ urlMatches: function(url) {\n+ var matches = OpenLayers.Util.isEquivalentUrl(this.url, url);\n+ if (!matches && this.layerUrls) {\n+ for (var i = 0, len = this.layerUrls.length; i < len; ++i) {\n+ if (OpenLayers.Util.isEquivalentUrl(this.layerUrls[i], url)) {\n+ matches = true;\n+ break;\n+ }\n+ }\n }\n- return ret;\n+ return matches;\n },\n \n /**\n- * Method: setLayerQuery\n- * Set the query definition on this layer. Query definitions are used to\n- * render parts of the spatial data in an image, and can be used to\n- * filter features or layers in the ArcIMS service.\n+ * Method: buildWMSOptions\n+ * Build an object with the relevant WMS options for the GetFeatureInfo request\n *\n * Parameters:\n- * id - {String} The ArcIMS layer ID.\n- * querydef - {Object} The query definition to apply to this layer.\n+ * url - {String} The url to be used for sending the request\n+ * layers - {Array(} The position on the map where the mouse\n+ * event occurred.\n+ * format - {String} The format from the corresponding GetMap request\n */\n- setLayerQuery: function(id, querydef) {\n- // find the matching layer, if it exists\n- for (var lyr = 0; lyr < this.options.layers.length; lyr++) {\n- if (id == this.options.layers[lyr].id) {\n- // replace this layer definition\n- this.options.layers[lyr].query = querydef;\n- return;\n+ buildWMSOptions: function(url, layers, clickPosition, format) {\n+ var layerNames = [],\n+ styleNames = [];\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ if (layers[i].params.LAYERS != null) {\n+ layerNames = layerNames.concat(layers[i].params.LAYERS);\n+ styleNames = styleNames.concat(this.getStyleNames(layers[i]));\n }\n }\n-\n- // no layer found, create a new definition\n- this.options.layers.push({\n- id: id,\n- visible: true,\n- query: querydef\n+ var firstLayer = layers[0];\n+ // use the firstLayer's projection if it matches the map projection -\n+ // this assumes that all layers will be available in this projection\n+ var projection = this.map.getProjection();\n+ var layerProj = firstLayer.projection;\n+ if (layerProj && layerProj.equals(this.map.getProjectionObject())) {\n+ projection = layerProj.getCode();\n+ }\n+ var params = OpenLayers.Util.extend({\n+ service: \"WMS\",\n+ version: firstLayer.params.VERSION,\n+ request: \"GetFeatureInfo\",\n+ exceptions: firstLayer.params.EXCEPTIONS,\n+ bbox: this.map.getExtent().toBBOX(null,\n+ firstLayer.reverseAxisOrder()),\n+ feature_count: this.maxFeatures,\n+ height: this.map.getSize().h,\n+ width: this.map.getSize().w,\n+ format: format,\n+ info_format: firstLayer.params.INFO_FORMAT || this.infoFormat\n+ }, (parseFloat(firstLayer.params.VERSION) >= 1.3) ? {\n+ crs: projection,\n+ i: parseInt(clickPosition.x),\n+ j: parseInt(clickPosition.y)\n+ } : {\n+ srs: projection,\n+ x: parseInt(clickPosition.x),\n+ y: parseInt(clickPosition.y)\n });\n+ if (layerNames.length != 0) {\n+ params = OpenLayers.Util.extend({\n+ layers: layerNames,\n+ query_layers: layerNames,\n+ styles: styleNames\n+ }, params);\n+ }\n+ OpenLayers.Util.applyDefaults(params, this.vendorParams);\n+ return {\n+ url: url,\n+ params: OpenLayers.Util.upperCaseObject(params),\n+ callback: function(request) {\n+ this.handleResponse(clickPosition, request, url);\n+ },\n+ scope: this\n+ };\n },\n \n /**\n- * Method: getFeatureInfo\n- * Get feature information from ArcIMS. Using the applied geometry, apply\n- * the options to the query (buffer, area/envelope intersection), and\n- * query the ArcIMS service.\n- *\n- * A note about accuracy:\n- * ArcIMS interprets the accuracy attribute in feature requests to be\n- * something like the 'modulus' operator on feature coordinates,\n- * applied to the database geometry of the feature. It doesn't round,\n- * so your feature coordinates may be up to (1 x accuracy) offset from\n- * the actual feature coordinates. If the accuracy of the layer is not\n- * specified, the accuracy will be computed to be approximately 1\n- * feature coordinate per screen pixel.\n+ * Method: getStyleNames\n+ * Gets the STYLES parameter for the layer. Make sure the STYLES parameter\n+ * matches the LAYERS parameter\n *\n * Parameters:\n- * geometry - {} or {} The\n- * geometry to use when making the query. This should be a closed\n- * polygon for behavior approximating a free selection.\n- * layer - {Object} The ArcIMS layer definition. This is an anonymous object\n- * that looks like:\n- * (code)\n- * {\n- * id: \"ArcXML layer ID\", // the ArcXML layer ID\n- * query: {\n- * where: \"STATE = 'PA'\", // the where clause of the query\n- * accuracy: 100 // the accuracy of the returned feature\n- * }\n- * }\n- * (end)\n- * options - {Object} Object with non-default properties to set on the layer.\n- * Supported properties are buffer, callback, scope, and any other\n- * properties applicable to the ArcXML format. Set the 'callback' and\n- * 'scope' for an object and function to recieve the parsed features\n- * from ArcIMS.\n+ * layer - {}\n+ *\n+ * Returns:\n+ * {Array(String)} The STYLES parameter\n */\n- getFeatureInfo: function(geometry, layer, options) {\n- // set the buffer to 1 unit (dd/m/ft?) by default\n- var buffer = options.buffer || 1;\n- // empty callback by default\n- var callback = options.callback || function() {};\n- // default scope is window (global)\n- var scope = options.scope || window;\n-\n- // apply these option to the request options\n- var requestOptions = {};\n- OpenLayers.Util.extend(requestOptions, this.options);\n-\n- // this is a feature request\n- requestOptions.requesttype = \"feature\";\n-\n- if (geometry instanceof OpenLayers.LonLat) {\n- // create an envelope if the geometry is really a lon/lat\n- requestOptions.polygon = null;\n- requestOptions.envelope = [\n- geometry.lon - buffer,\n- geometry.lat - buffer,\n- geometry.lon + buffer,\n- geometry.lat + buffer\n- ];\n- } else if (geometry instanceof OpenLayers.Geometry.Polygon) {\n- // use the polygon assigned, and empty the envelope\n- requestOptions.envelope = null;\n- requestOptions.polygon = geometry;\n- }\n-\n- // create an arcxml request to get feature requests\n- var arcxml = new OpenLayers.Format.ArcXML(requestOptions);\n-\n- // apply any get feature options to the arcxml request\n- OpenLayers.Util.extend(arcxml.request.get_feature, options);\n-\n- arcxml.request.get_feature.layer = layer.id;\n- if (typeof layer.query.accuracy == \"number\") {\n- // set the accuracy if it was specified\n- arcxml.request.get_feature.query.accuracy = layer.query.accuracy;\n+ getStyleNames: function(layer) {\n+ // in the event of a WMS layer bundling multiple layers but not\n+ // specifying styles,we need the same number of commas to specify\n+ // the default style for each of the layers. We can't just leave it\n+ // blank as we may be including other layers that do specify styles.\n+ var styleNames;\n+ if (layer.params.STYLES) {\n+ styleNames = layer.params.STYLES;\n } else {\n- // guess that the accuracy is 1 per screen pixel\n- var mapCenter = this.map.getCenter();\n- var viewPx = this.map.getViewPortPxFromLonLat(mapCenter);\n- viewPx.x++;\n- var mapOffCenter = this.map.getLonLatFromPixel(viewPx);\n- arcxml.request.get_feature.query.accuracy = mapOffCenter.lon - mapCenter.lon;\n+ if (OpenLayers.Util.isArray(layer.params.LAYERS)) {\n+ styleNames = new Array(layer.params.LAYERS.length);\n+ } else { // Assume it's a String\n+ styleNames = layer.params.LAYERS.replace(/[^,]/g, \"\");\n+ }\n }\n+ return styleNames;\n+ },\n \n- // set the get_feature query to be the same as the layer passed in\n- arcxml.request.get_feature.query.where = layer.query.where;\n-\n- // use area_intersection\n- arcxml.request.get_feature.query.spatialfilter.relation = \"area_intersection\";\n+ /**\n+ * Method: request\n+ * Sends a GetFeatureInfo request to the WMS\n+ *\n+ * Parameters:\n+ * clickPosition - {} The position on the map where the\n+ * mouse event occurred.\n+ * options - {Object} additional options for this method.\n+ *\n+ * Valid options:\n+ * - *hover* {Boolean} true if we do the request for the hover handler\n+ */\n+ request: function(clickPosition, options) {\n+ var layers = this.findLayers();\n+ if (layers.length == 0) {\n+ this.events.triggerEvent(\"nogetfeatureinfo\");\n+ // Reset the cursor.\n+ OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ return;\n+ }\n \n- // create a new asynchronous request to get the feature info\n- OpenLayers.Request.POST({\n- url: this.getFullRequestString({\n- 'CustomService': 'Query'\n- }),\n- data: arcxml.write(),\n- callback: function(request) {\n- // parse the arcxml response\n- var response = arcxml.parseResponse(request.responseText);\n+ options = options || {};\n+ if (this.drillDown === false) {\n+ var wmsOptions = this.buildWMSOptions(this.url, layers,\n+ clickPosition, layers[0].params.FORMAT);\n+ var request = OpenLayers.Request.GET(wmsOptions);\n \n- if (!arcxml.iserror()) {\n- // if the arcxml is not an error, call the callback with the features parsed\n- callback.call(scope, response.features);\n+ if (options.hover === true) {\n+ this.hoverRequest = request;\n+ }\n+ } else {\n+ this._requestCount = 0;\n+ this._numRequests = 0;\n+ this.features = [];\n+ // group according to service url to combine requests\n+ var services = {},\n+ url;\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ var layer = layers[i];\n+ var service, found = false;\n+ url = OpenLayers.Util.isArray(layer.url) ? layer.url[0] : layer.url;\n+ if (url in services) {\n+ services[url].push(layer);\n } else {\n- // if the arcxml is an error, return null features selected\n- callback.call(scope, null);\n+ this._numRequests++;\n+ services[url] = [layer];\n }\n }\n- });\n+ var layers;\n+ for (var url in services) {\n+ layers = services[url];\n+ var wmsOptions = this.buildWMSOptions(url, layers,\n+ clickPosition, layers[0].params.FORMAT);\n+ OpenLayers.Request.GET(wmsOptions);\n+ }\n+ }\n },\n \n /**\n- * Method: clone\n- * Create a clone of this layer\n+ * Method: triggerGetFeatureInfo\n+ * Trigger the getfeatureinfo event when all is done\n *\n- * Returns:\n- * {} An exact clone of this layer\n+ * Parameters:\n+ * request - {XMLHttpRequest} The request object\n+ * xy - {} The position on the map where the\n+ * mouse event occurred.\n+ * features - {Array()} or\n+ * {Array({Object}) when output is \"object\". The object has a url and a\n+ * features property which contains an array of features.\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.ArcIMS(this.name,\n- this.url,\n- this.getOptions());\n- }\n+ triggerGetFeatureInfo: function(request, xy, features) {\n+ this.events.triggerEvent(\"getfeatureinfo\", {\n+ text: request.responseText,\n+ features: features,\n+ request: request,\n+ xy: xy\n+ });\n \n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n+ // Reset the cursor.\n+ OpenLayers.Element.removeClass(this.map.viewPortDiv, \"olCursorWait\");\n+ },\n \n- // copy/set any non-init, non-simple values here\n+ /**\n+ * Method: handleResponse\n+ * Handler for the GetFeatureInfo response.\n+ *\n+ * Parameters:\n+ * xy - {} The position on the map where the\n+ * mouse event occurred.\n+ * request - {XMLHttpRequest} The request object.\n+ * url - {String} The url which was used for this request.\n+ */\n+ handleResponse: function(xy, request, url) {\n \n- return obj;\n+ var doc = request.responseXML;\n+ if (!doc || !doc.documentElement) {\n+ doc = request.responseText;\n+ }\n+ var features = this.format.read(doc);\n+ if (this.drillDown === false) {\n+ this.triggerGetFeatureInfo(request, xy, features);\n+ } else {\n+ this._requestCount++;\n+ if (this.output === \"object\") {\n+ this._features = (this._features || []).concat({\n+ url: url,\n+ features: features\n+ });\n+ } else {\n+ this._features = (this._features || []).concat(features);\n+ }\n+ if (this._requestCount === this._numRequests) {\n+ this.triggerGetFeatureInfo(request, xy, this._features.concat());\n+ delete this._features;\n+ delete this._requestCount;\n+ delete this._numRequests;\n+ }\n+ }\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.ArcIMS\"\n+ CLASS_NAME: \"OpenLayers.Control.WMSGetFeatureInfo\"\n });\n /* ======================================================================\n- OpenLayers/Layer/WorldWind.js\n+ OpenLayers/Control/ZoomBox.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Box.js\n */\n \n /**\n- * Class: OpenLayers.Layer.WorldWind\n- * \n+ * Class: OpenLayers.Control.ZoomBox\n+ * The ZoomBox control enables zooming directly to a given extent, by drawing \n+ * a box on the map. The box is drawn by holding down shift, whilst dragging \n+ * the mouse.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.WorldWind = OpenLayers.Class(OpenLayers.Layer.Grid, {\n-\n- DEFAULT_PARAMS: {},\n+OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {\n+ /**\n+ * Property: type\n+ * {OpenLayers.Control.TYPE}\n+ */\n+ type: OpenLayers.Control.TYPE_TOOL,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} WorldWind layer is a base layer by default.\n+ * Property: out\n+ * {Boolean} Should the control be used for zooming out?\n */\n- isBaseLayer: true,\n+ out: false,\n \n- /** \n- * APIProperty: lzd\n- * {Float} LevelZeroTileSizeDegrees\n+ /**\n+ * APIProperty: keyMask\n+ * {Integer} Zoom only occurs if the keyMask matches the combination of \n+ * keys down. Use bitwise operators and one or more of the\n+ * constants to construct a keyMask. Leave null if \n+ * not used mask. Default is null.\n */\n- lzd: null,\n+ keyMask: null,\n \n /**\n- * APIProperty: zoomLevels\n- * {Integer} Number of zoom levels.\n+ * APIProperty: alwaysZoom\n+ * {Boolean} Always zoom in/out when box drawn, even if the zoom level does\n+ * not change.\n */\n- zoomLevels: null,\n+ alwaysZoom: false,\n \n /**\n- * Constructor: OpenLayers.Layer.WorldWind\n- * \n- * Parameters:\n- * name - {String} Name of Layer\n- * url - {String} Base URL \n- * lzd - {Float} Level zero tile size degrees \n- * zoomLevels - {Integer} number of zoom levels\n- * params - {Object} additional parameters\n- * options - {Object} additional options\n+ * APIProperty: zoomOnClick\n+ * {Boolean} Should we zoom when no box was dragged, i.e. the user only\n+ * clicked? Default is true.\n */\n- initialize: function(name, url, lzd, zoomLevels, params, options) {\n- this.lzd = lzd;\n- this.zoomLevels = zoomLevels;\n- var newArguments = [];\n- newArguments.push(name, url, params, options);\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);\n- this.params = OpenLayers.Util.applyDefaults(\n- this.params, this.DEFAULT_PARAMS\n- );\n- },\n+ zoomOnClick: true,\n \n /**\n- * Method: getZoom\n- * Convert map zoom to WW zoom.\n+ * Method: draw\n */\n- getZoom: function() {\n- var zoom = this.map.getZoom();\n- var extent = this.map.getMaxExtent();\n- zoom = zoom - Math.log(this.maxResolution / (this.lzd / 512)) / Math.log(2);\n- return zoom;\n+ draw: function() {\n+ this.handler = new OpenLayers.Handler.Box(this, {\n+ done: this.zoomBox\n+ }, {\n+ keyMask: this.keyMask\n+ });\n },\n \n /**\n- * Method: getURL\n+ * Method: zoomBox\n *\n * Parameters:\n- * bounds - {} \n- *\n- * Returns:\n- * {String} A string with the layer's url and parameters and also the \n- * passed-in bounds and appropriate tile size specified as \n- * parameters\n+ * position - {} or {}\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n- var zoom = this.getZoom();\n- var extent = this.map.getMaxExtent();\n- var deg = this.lzd / Math.pow(2, this.getZoom());\n- var x = Math.floor((bounds.left - extent.left) / deg);\n- var y = Math.floor((bounds.bottom - extent.bottom) / deg);\n- if (this.map.getResolution() <= (this.lzd / 512) &&\n- this.getZoom() <= this.zoomLevels) {\n- return this.getFullRequestString({\n- L: zoom,\n- X: x,\n- Y: y\n- });\n- } else {\n- return OpenLayers.Util.getImageLocation(\"blank.gif\");\n+ zoomBox: function(position) {\n+ if (position instanceof OpenLayers.Bounds) {\n+ var bounds,\n+ targetCenterPx = position.getCenterPixel();\n+ if (!this.out) {\n+ var minXY = this.map.getLonLatFromPixel({\n+ x: position.left,\n+ y: position.bottom\n+ });\n+ var maxXY = this.map.getLonLatFromPixel({\n+ x: position.right,\n+ y: position.top\n+ });\n+ bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,\n+ maxXY.lon, maxXY.lat);\n+ } else {\n+ var pixWidth = position.right - position.left;\n+ var pixHeight = position.bottom - position.top;\n+ var zoomFactor = Math.min((this.map.size.h / pixHeight),\n+ (this.map.size.w / pixWidth));\n+ var extent = this.map.getExtent();\n+ var center = this.map.getLonLatFromPixel(targetCenterPx);\n+ var xmin = center.lon - (extent.getWidth() / 2) * zoomFactor;\n+ var xmax = center.lon + (extent.getWidth() / 2) * zoomFactor;\n+ var ymin = center.lat - (extent.getHeight() / 2) * zoomFactor;\n+ var ymax = center.lat + (extent.getHeight() / 2) * zoomFactor;\n+ bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);\n+ }\n+ // always zoom in/out \n+ var lastZoom = this.map.getZoom(),\n+ size = this.map.getSize(),\n+ centerPx = {\n+ x: size.w / 2,\n+ y: size.h / 2\n+ },\n+ zoom = this.map.getZoomForExtent(bounds),\n+ oldRes = this.map.getResolution(),\n+ newRes = this.map.getResolutionForZoom(zoom);\n+ if (oldRes == newRes) {\n+ this.map.setCenter(this.map.getLonLatFromPixel(targetCenterPx));\n+ } else {\n+ var zoomOriginPx = {\n+ x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /\n+ (oldRes - newRes),\n+ y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /\n+ (oldRes - newRes)\n+ };\n+ this.map.zoomTo(zoom, zoomOriginPx);\n+ }\n+ if (lastZoom == this.map.getZoom() && this.alwaysZoom == true) {\n+ this.map.zoomTo(lastZoom + (this.out ? -1 : 1));\n+ }\n+ } else if (this.zoomOnClick) { // it's a pixel\n+ if (!this.out) {\n+ this.map.zoomTo(this.map.getZoom() + 1, position);\n+ } else {\n+ this.map.zoomTo(this.map.getZoom() - 1, position);\n+ }\n }\n-\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.WorldWind\"\n+ CLASS_NAME: \"OpenLayers.Control.ZoomBox\"\n });\n /* ======================================================================\n- OpenLayers/Layer/ArcGIS93Rest.js\n+ OpenLayers/Control/Scale.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n+\n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Lang.js\n */\n \n /**\n- * Class: OpenLayers.Layer.ArcGIS93Rest\n- * Instances of OpenLayers.Layer.ArcGIS93Rest are used to display data from\n- * ESRI ArcGIS Server 9.3 (and up?) Mapping Services using the REST API.\n- * Create a new ArcGIS93Rest layer with the \n- * constructor. More detail on the REST API is available at\n- * http://sampleserver1.arcgisonline.com/ArcGIS/SDK/REST/index.html ;\n- * specifically, the URL provided to this layer should be an export service\n- * URL: http://sampleserver1.arcgisonline.com/ArcGIS/SDK/REST/export.html \n- * \n+ * Class: OpenLayers.Control.Scale\n+ * The Scale control displays the current map scale as a ratio (e.g. Scale = \n+ * 1:1M). By default it is displayed in the lower right corner of the map.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.ArcGIS93Rest = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.Scale = OpenLayers.Class(OpenLayers.Control, {\n \n /**\n- * Constant: DEFAULT_PARAMS\n- * {Object} Hashtable of default parameter key/value pairs \n+ * Property: element\n+ * {DOMElement}\n */\n- DEFAULT_PARAMS: {\n- format: \"png\"\n- },\n+ element: null,\n \n /**\n- * APIProperty: isBaseLayer\n- * {Boolean} Default is true for ArcGIS93Rest layer\n+ * APIProperty: geodesic\n+ * {Boolean} Use geodesic measurement. Default is false. The recommended\n+ * setting for maps in EPSG:4326 is false, and true EPSG:900913. If set to\n+ * true, the scale will be calculated based on the horizontal size of the\n+ * pixel in the center of the map viewport.\n */\n- isBaseLayer: true,\n-\n+ geodesic: false,\n \n /**\n- * Constructor: OpenLayers.Layer.ArcGIS93Rest\n- * Create a new ArcGIS93Rest layer object.\n- *\n- * Example:\n- * (code)\n- * var arcims = new OpenLayers.Layer.ArcGIS93Rest(\"MyName\",\n- * \"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer/export\", \n- * {\n- * layers: \"0,1,2\"\n- * });\n- * (end)\n- *\n+ * Constructor: OpenLayers.Control.Scale\n+ * \n * Parameters:\n- * name - {String} A name for the layer\n- * url - {String} Base url for the ArcGIS server REST service\n- * options - {Object} An object with key/value pairs representing the\n- * options and option values.\n- *\n- * Valid Options:\n- * format - {String} MIME type of desired image type.\n- * layers - {String} Comma-separated list of layers to display.\n- * srs - {String} Projection ID.\n+ * element - {DOMElement} \n+ * options - {Object} \n */\n- initialize: function(name, url, params, options) {\n- var newArguments = [];\n- //uppercase params\n- params = OpenLayers.Util.upperCaseObject(params);\n- newArguments.push(name, url, params, options);\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);\n- OpenLayers.Util.applyDefaults(\n- this.params,\n- OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)\n- );\n-\n- //layer is transparent \n- if (this.params.TRANSPARENT &&\n- this.params.TRANSPARENT.toString().toLowerCase() == \"true\") {\n-\n- // unless explicitly set in options, make layer an overlay\n- if ((options == null) || (!options.isBaseLayer)) {\n- this.isBaseLayer = false;\n- }\n-\n- // jpegs can never be transparent, so intelligently switch the \n- // format, depending on the browser's capabilities\n- if (this.params.FORMAT == \"jpg\") {\n- this.params.FORMAT = OpenLayers.Util.alphaHack() ? \"gif\" :\n- \"png\";\n- }\n- }\n+ initialize: function(element, options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.element = OpenLayers.Util.getElement(element);\n },\n \n /**\n- * Method: clone\n- * Create a clone of this layer\n- *\n+ * Method: draw\n+ * \n * Returns:\n- * {} An exact clone of this layer\n+ * {DOMElement}\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.ArcGIS93Rest(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ if (!this.element) {\n+ this.element = document.createElement(\"div\");\n+ this.div.appendChild(this.element);\n }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n-\n- return obj;\n+ this.map.events.register('moveend', this, this.updateScale);\n+ this.updateScale();\n+ return this.div;\n },\n \n-\n /**\n- * Method: getURL\n- * Return an image url this layer.\n- *\n- * Parameters:\n- * bounds - {} A bounds representing the bbox for the\n- * request.\n- *\n- * Returns:\n- * {String} A string with the map image's url.\n+ * Method: updateScale\n */\n- getURL: function(bounds) {\n- bounds = this.adjustBounds(bounds);\n-\n- // ArcGIS Server only wants the numeric portion of the projection ID.\n- var projWords = this.projection.getCode().split(\":\");\n- var srid = projWords[projWords.length - 1];\n-\n- var imageSize = this.getImageSize();\n- var newParams = {\n- 'BBOX': bounds.toBBOX(),\n- 'SIZE': imageSize.w + \",\" + imageSize.h,\n- // We always want image, the other options were json, image with a whole lotta html around it, etc.\n- 'F': \"image\",\n- 'BBOXSR': srid,\n- 'IMAGESR': srid\n- };\n-\n- // Now add the filter parameters.\n- if (this.layerDefs) {\n- var layerDefStrList = [];\n- var layerID;\n- for (layerID in this.layerDefs) {\n- if (this.layerDefs.hasOwnProperty(layerID)) {\n- if (this.layerDefs[layerID]) {\n- layerDefStrList.push(layerID);\n- layerDefStrList.push(\":\");\n- layerDefStrList.push(this.layerDefs[layerID]);\n- layerDefStrList.push(\";\");\n- }\n- }\n- }\n- if (layerDefStrList.length > 0) {\n- newParams['LAYERDEFS'] = layerDefStrList.join(\"\");\n+ updateScale: function() {\n+ var scale;\n+ if (this.geodesic === true) {\n+ var units = this.map.getUnits();\n+ if (!units) {\n+ return;\n }\n+ var inches = OpenLayers.INCHES_PER_UNIT;\n+ scale = (this.map.getGeodesicPixelSize().w || 0.000001) *\n+ inches[\"km\"] * OpenLayers.DOTS_PER_INCH;\n+ } else {\n+ scale = this.map.getScale();\n }\n- var requestString = this.getFullRequestString(newParams);\n- return requestString;\n- },\n \n- /**\n- * Method: setLayerFilter\n- * addTile creates a tile, initializes it, and adds it to the layer div. \n- *\n- * Parameters:\n- * id - {String} The id of the layer to which the filter applies.\n- * queryDef - {String} A sql-ish query filter, for more detail see the ESRI\n- * documentation at http://sampleserver1.arcgisonline.com/ArcGIS/SDK/REST/export.html\n- */\n- setLayerFilter: function(id, queryDef) {\n- if (!this.layerDefs) {\n- this.layerDefs = {};\n- }\n- if (queryDef) {\n- this.layerDefs[id] = queryDef;\n- } else {\n- delete this.layerDefs[id];\n+ if (!scale) {\n+ return;\n }\n- },\n \n- /**\n- * Method: clearLayerFilter\n- * Clears layer filters, either from a specific layer,\n- * or all of them.\n- *\n- * Parameters:\n- * id - {String} The id of the layer from which to remove any\n- * filter. If unspecified/blank, all filters\n- * will be removed.\n- */\n- clearLayerFilter: function(id) {\n- if (id) {\n- delete this.layerDefs[id];\n+ if (scale >= 9500 && scale <= 950000) {\n+ scale = Math.round(scale / 1000) + \"K\";\n+ } else if (scale >= 950000) {\n+ scale = Math.round(scale / 1000000) + \"M\";\n } else {\n- delete this.layerDefs;\n+ scale = Math.round(scale);\n }\n- },\n \n- /**\n- * APIMethod: mergeNewParams\n- * Catch changeParams and uppercase the new params to be merged in\n- * before calling changeParams on the super class.\n- * \n- * Once params have been changed, the tiles will be reloaded with\n- * the new parameters.\n- * \n- * Parameters:\n- * newParams - {Object} Hashtable of new params to use\n- */\n- mergeNewParams: function(newParams) {\n- var upperParams = OpenLayers.Util.upperCaseObject(newParams);\n- var newArguments = [upperParams];\n- return OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this,\n- newArguments);\n+ this.element.innerHTML = OpenLayers.i18n(\"Scale = 1 : ${scaleDenom}\", {\n+ 'scaleDenom': scale\n+ });\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.ArcGIS93Rest\"\n+ CLASS_NAME: \"OpenLayers.Control.Scale\"\n });\n+\n /* ======================================================================\n- OpenLayers/Layer/XYZ.js\n+ OpenLayers/Control/Panel.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Events/buttonclick.js\n */\n \n-/** \n- * Class: OpenLayers.Layer.XYZ\n- * The XYZ class is designed to make it easier for people who have tiles\n- * arranged by a standard XYZ grid. \n- * \n+/**\n+ * Class: OpenLayers.Control.Panel\n+ * The Panel control is a container for other controls. With it toolbars\n+ * may be composed.\n+ *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {\n+ /**\n+ * Property: controls\n+ * {Array()}\n+ */\n+ controls: null,\n \n /**\n- * APIProperty: isBaseLayer\n- * Default is true, as this is designed to be a base tile source. \n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- isBaseLayer: true,\n+ autoActivate: true,\n+\n+ /** \n+ * APIProperty: defaultControl\n+ * {} The control which is activated when the control is\n+ * activated (turned on), which also happens at instantiation.\n+ * If is true, will be nullified after the\n+ * first activation of the panel.\n+ */\n+ defaultControl: null,\n \n /**\n- * APIProperty: sphericalMercator\n- * Whether the tile extents should be set to the defaults for \n- * spherical mercator. Useful for things like OpenStreetMap.\n- * Default is false, except for the OSM subclass.\n+ * APIProperty: saveState\n+ * {Boolean} If set to true, the active state of this panel's controls will\n+ * be stored on panel deactivation, and restored on reactivation. Default\n+ * is false.\n */\n- sphericalMercator: false,\n+ saveState: false,\n \n /**\n- * APIProperty: zoomOffset\n- * {Number} If your cache has more zoom levels than you want to provide\n- * access to with this layer, supply a zoomOffset. This zoom offset\n- * is added to the current map zoom level to determine the level\n- * for a requested tile. For example, if you supply a zoomOffset\n- * of 3, when the map is at the zoom 0, tiles will be requested from\n- * level 3 of your cache. Default is 0 (assumes cache level and map\n- * zoom are equivalent). Using is an alternative to\n- * setting if you only want to expose a subset\n- * of the server resolutions.\n+ * APIProperty: allowDepress\n+ * {Boolean} If is true the controls can \n+ * be deactivated by clicking the icon that represents them. Default \n+ * is false.\n */\n- zoomOffset: 0,\n+ allowDepress: false,\n \n /**\n- * APIProperty: serverResolutions\n- * {Array} A list of all resolutions available on the server. Only set this\n- * property if the map resolutions differ from the server. This\n- * property serves two purposes. (a) can include\n- * resolutions that the server supports and that you don't want to\n- * provide with this layer; you can also look at , which is\n- * an alternative to for that specific purpose.\n- * (b) The map can work with resolutions that aren't supported by\n- * the server, i.e. that aren't in . When the\n- * map is displayed in such a resolution data for the closest\n- * server-supported resolution is loaded and the layer div is\n- * stretched as necessary.\n+ * Property: activeState\n+ * {Object} stores the active state of this panel's controls.\n */\n- serverResolutions: null,\n+ activeState: null,\n \n /**\n- * Constructor: OpenLayers.Layer.XYZ\n+ * Constructor: OpenLayers.Control.Panel\n+ * Create a new control panel.\n+ *\n+ * Each control in the panel is represented by an icon. When clicking \n+ * on an icon, the method is called.\n+ *\n+ * Specific properties for controls on a panel:\n+ * type - {Number} One of ,\n+ * , .\n+ * If not provided, is assumed.\n+ * title - {string} Text displayed when mouse is over the icon that \n+ * represents the control. \n+ *\n+ * The of a control determines the behavior when\n+ * clicking its icon:\n+ * - The control is activated and other\n+ * controls of this type in the same panel are deactivated. This is\n+ * the default type.\n+ * - The active state of the control is\n+ * toggled.\n+ * - The\n+ * method of the control is called,\n+ * but its active state is not changed.\n+ *\n+ * If a control is , it will be drawn with the\n+ * olControl[Name]ItemActive class, otherwise with the\n+ * olControl[Name]ItemInactive class.\n *\n * Parameters:\n- * name - {String}\n- * url - {String}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * options - {Object} An optional object whose properties will be used\n+ * to extend the control.\n */\n- initialize: function(name, url, options) {\n- if (options && options.sphericalMercator || this.sphericalMercator) {\n- options = OpenLayers.Util.extend({\n- projection: \"EPSG:900913\",\n- numZoomLevels: 19\n- }, options);\n- }\n- OpenLayers.Layer.Grid.prototype.initialize.apply(this, [\n- name || this.name, url || this.url, {},\n- options\n- ]);\n+ initialize: function(options) {\n+ OpenLayers.Control.prototype.initialize.apply(this, [options]);\n+ this.controls = [];\n+ this.activeState = {};\n },\n \n /**\n- * APIMethod: clone\n- * Create a clone of this layer\n- *\n- * Parameters:\n- * obj - {Object} Is this ever used?\n- * \n- * Returns:\n- * {} An exact clone of this OpenLayers.Layer.XYZ\n+ * APIMethod: destroy\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.XYZ(this.name,\n- this.url,\n- this.getOptions());\n+ destroy: function() {\n+ if (this.map) {\n+ this.map.events.unregister(\"buttonclick\", this, this.onButtonClick);\n }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n-\n- return obj;\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n+ for (var ctl, i = this.controls.length - 1; i >= 0; i--) {\n+ ctl = this.controls[i];\n+ if (ctl.events) {\n+ ctl.events.un({\n+ activate: this.iconOn,\n+ deactivate: this.iconOff\n+ });\n+ }\n+ ctl.panel_div = null;\n+ }\n+ this.activeState = null;\n },\n \n /**\n- * Method: getURL\n- *\n- * Parameters:\n- * bounds - {}\n- *\n- * Returns:\n- * {String} A string with the layer's url and parameters and also the\n- * passed-in bounds and appropriate tile size specified as\n- * parameters\n+ * APIMethod: activate\n */\n- getURL: function(bounds) {\n- var xyz = this.getXYZ(bounds);\n- var url = this.url;\n- if (OpenLayers.Util.isArray(url)) {\n- var s = '' + xyz.x + xyz.y + xyz.z;\n- url = this.selectUrl(s, url);\n+ activate: function() {\n+ if (OpenLayers.Control.prototype.activate.apply(this, arguments)) {\n+ var control;\n+ for (var i = 0, len = this.controls.length; i < len; i++) {\n+ control = this.controls[i];\n+ if (control === this.defaultControl ||\n+ (this.saveState && this.activeState[control.id])) {\n+ control.activate();\n+ }\n+ }\n+ if (this.saveState === true) {\n+ this.defaultControl = null;\n+ }\n+ this.redraw();\n+ return true;\n+ } else {\n+ return false;\n }\n+ },\n \n- return OpenLayers.String.format(url, xyz);\n+ /**\n+ * APIMethod: deactivate\n+ */\n+ deactivate: function() {\n+ if (OpenLayers.Control.prototype.deactivate.apply(this, arguments)) {\n+ var control;\n+ for (var i = 0, len = this.controls.length; i < len; i++) {\n+ control = this.controls[i];\n+ this.activeState[control.id] = control.deactivate();\n+ }\n+ this.redraw();\n+ return true;\n+ } else {\n+ return false;\n+ }\n },\n \n /**\n- * Method: getXYZ\n- * Calculates x, y and z for the given bounds.\n- *\n- * Parameters:\n- * bounds - {}\n+ * Method: draw\n *\n * Returns:\n- * {Object} - an object with x, y and z properties.\n+ * {DOMElement}\n */\n- getXYZ: function(bounds) {\n- var res = this.getServerResolution();\n- var x = Math.round((bounds.left - this.maxExtent.left) /\n- (res * this.tileSize.w));\n- var y = Math.round((this.maxExtent.top - bounds.top) /\n- (res * this.tileSize.h));\n- var z = this.getServerZoom();\n-\n- if (this.wrapDateLine) {\n- var limit = Math.pow(2, z);\n- x = ((x % limit) + limit) % limit;\n+ draw: function() {\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ if (this.outsideViewport) {\n+ this.events.attachToElement(this.div);\n+ this.events.register(\"buttonclick\", this, this.onButtonClick);\n+ } else {\n+ this.map.events.register(\"buttonclick\", this, this.onButtonClick);\n }\n-\n- return {\n- 'x': x,\n- 'y': y,\n- 'z': z\n- };\n+ this.addControlsToMap(this.controls);\n+ return this.div;\n },\n \n- /* APIMethod: setMap\n- * When the layer is added to a map, then we can fetch our origin \n- * (if we don't have one.) \n- * \n- * Parameters:\n- * map - {}\n+ /**\n+ * Method: redraw\n */\n- setMap: function(map) {\n- OpenLayers.Layer.Grid.prototype.setMap.apply(this, arguments);\n- if (!this.tileOrigin) {\n- this.tileOrigin = new OpenLayers.LonLat(this.maxExtent.left,\n- this.maxExtent.bottom);\n+ redraw: function() {\n+ for (var l = this.div.childNodes.length, i = l - 1; i >= 0; i--) {\n+ this.div.removeChild(this.div.childNodes[i]);\n+ }\n+ this.div.innerHTML = \"\";\n+ if (this.active) {\n+ for (var i = 0, len = this.controls.length; i < len; i++) {\n+ this.div.appendChild(this.controls[i].panel_div);\n+ }\n }\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.XYZ\"\n-});\n-/* ======================================================================\n- OpenLayers/Tile/UTFGrid.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Tile.js\n- * @requires OpenLayers/Format/JSON.js\n- * @requires OpenLayers/Request.js\n- */\n-\n-/**\n- * Class: OpenLayers.Tile.UTFGrid\n- * Instances of OpenLayers.Tile.UTFGrid are used to manage \n- * UTFGrids. This is an unusual tile type in that it doesn't have a\n- * rendered image; only a 'hit grid' that can be used to \n- * look up feature attributes.\n- *\n- * See the constructor for details on constructing a\n- * new instance.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Tile.UTFGrid = OpenLayers.Class(OpenLayers.Tile, {\n-\n- /** \n- * Property: url\n- * {String}\n- * The URL of the UTFGrid file being requested. Provided by the \n- * method. \n+ /**\n+ * APIMethod: activateControl\n+ * This method is called when the user click on the icon representing a \n+ * control in the panel.\n+ *\n+ * Parameters:\n+ * control - {}\n */\n- url: null,\n+ activateControl: function(control) {\n+ if (!this.active) {\n+ return false;\n+ }\n+ if (control.type == OpenLayers.Control.TYPE_BUTTON) {\n+ control.trigger();\n+ return;\n+ }\n+ if (control.type == OpenLayers.Control.TYPE_TOGGLE) {\n+ if (control.active) {\n+ control.deactivate();\n+ } else {\n+ control.activate();\n+ }\n+ return;\n+ }\n+ if (this.allowDepress && control.active) {\n+ control.deactivate();\n+ } else {\n+ var c;\n+ for (var i = 0, len = this.controls.length; i < len; i++) {\n+ c = this.controls[i];\n+ if (c != control &&\n+ (c.type === OpenLayers.Control.TYPE_TOOL || c.type == null)) {\n+ c.deactivate();\n+ }\n+ }\n+ control.activate();\n+ }\n+ },\n \n /**\n- * Property: utfgridResolution\n- * {Number}\n- * Ratio of the pixel width to the width of a UTFGrid data point. If an \n- * entry in the grid represents a 4x4 block of pixels, the \n- * utfgridResolution would be 4. Default is 2.\n+ * APIMethod: addControls\n+ * To build a toolbar, you add a set of controls to it. addControls\n+ * lets you add a single control or a list of controls to the \n+ * Control Panel.\n+ *\n+ * Parameters:\n+ * controls - {} Controls to add in the panel.\n */\n- utfgridResolution: 2,\n+ addControls: function(controls) {\n+ if (!(OpenLayers.Util.isArray(controls))) {\n+ controls = [controls];\n+ }\n+ this.controls = this.controls.concat(controls);\n \n- /** \n- * Property: json\n- * {Object}\n- * Stores the parsed JSON tile data structure. \n- */\n- json: null,\n+ for (var i = 0, len = controls.length; i < len; i++) {\n+ var control = controls[i],\n+ element = this.createControlMarkup(control);\n+ OpenLayers.Element.addClass(element,\n+ control.displayClass + \"ItemInactive\");\n+ OpenLayers.Element.addClass(element, \"olButton\");\n+ if (control.title != \"\" && !element.title) {\n+ element.title = control.title;\n+ }\n+ control.panel_div = element;\n+ }\n \n- /** \n- * Property: format\n- * {OpenLayers.Format.JSON}\n- * Parser instance used to parse JSON for cross browser support. The native\n- * JSON.parse method will be used where available (all except IE<8).\n- */\n- format: null,\n+ if (this.map) { // map.addControl() has already been called on the panel\n+ this.addControlsToMap(controls);\n+ this.redraw();\n+ }\n+ },\n \n- /** \n- * Constructor: OpenLayers.Tile.UTFGrid\n- * Constructor for a new instance.\n- * \n+ /**\n+ * APIMethod: createControlMarkup\n+ * This function just creates a div for the control. If specific HTML\n+ * markup is needed this function can be overridden in specific classes,\n+ * or at panel instantiation time:\n+ *\n+ * Example:\n+ * (code)\n+ * var panel = new OpenLayers.Control.Panel({\n+ * defaultControl: control,\n+ * // ovverride createControlMarkup to create actual buttons\n+ * // including texts wrapped into span elements.\n+ * createControlMarkup: function(control) {\n+ * var button = document.createElement('button'),\n+ * span = document.createElement('span');\n+ * if (control.text) {\n+ * span.innerHTML = control.text;\n+ * }\n+ * return button;\n+ * }\n+ * });\n+ * (end)\n+ *\n * Parameters:\n- * layer - {} layer that the tile will go in.\n- * position - {}\n- * bounds - {}\n- * url - {} Deprecated. Remove me in 3.0.\n- * size - {}\n- * options - {Object}\n- */\n-\n- /** \n- * APIMethod: destroy\n- * Clean up.\n+ * control - {} The control to create the HTML\n+ * markup for.\n+ *\n+ * Returns:\n+ * {DOMElement} The markup.\n */\n- destroy: function() {\n- this.clear();\n- OpenLayers.Tile.prototype.destroy.apply(this, arguments);\n+ createControlMarkup: function(control) {\n+ return document.createElement(\"div\");\n },\n \n /**\n- * Method: draw\n- * Check that a tile should be drawn, and draw it.\n- * In the case of UTFGrids, \"drawing\" it means fetching and\n- * parsing the json. \n- * \n- * Returns:\n- * {Boolean} Was a tile drawn?\n+ * Method: addControlsToMap\n+ * Only for internal use in draw() and addControls() methods.\n+ *\n+ * Parameters:\n+ * controls - {Array()} Controls to add into map.\n */\n- draw: function() {\n- var drawn = OpenLayers.Tile.prototype.draw.apply(this, arguments);\n- if (drawn) {\n- if (this.isLoading) {\n- this.abortLoading();\n- //if we're already loading, send 'reload' instead of 'loadstart'.\n- this.events.triggerEvent(\"reload\");\n- } else {\n- this.isLoading = true;\n- this.events.triggerEvent(\"loadstart\");\n- }\n- this.url = this.layer.getURL(this.bounds);\n-\n- if (this.layer.useJSONP) {\n- // Use JSONP method to avoid xbrowser policy\n- var ols = new OpenLayers.Protocol.Script({\n- url: this.url,\n- callback: function(response) {\n- this.isLoading = false;\n- this.events.triggerEvent(\"loadend\");\n- this.json = response.data;\n- },\n- scope: this\n- });\n- ols.read();\n- this.request = ols;\n+ addControlsToMap: function(controls) {\n+ var control;\n+ for (var i = 0, len = controls.length; i < len; i++) {\n+ control = controls[i];\n+ if (control.autoActivate === true) {\n+ control.autoActivate = false;\n+ this.map.addControl(control);\n+ control.autoActivate = true;\n } else {\n- // Use standard XHR\n- this.request = OpenLayers.Request.GET({\n- url: this.url,\n- callback: function(response) {\n- this.isLoading = false;\n- this.events.triggerEvent(\"loadend\");\n- if (response.status === 200) {\n- this.parseData(response.responseText);\n- }\n- },\n- scope: this\n- });\n+ this.map.addControl(control);\n+ control.deactivate();\n }\n- } else {\n- this.unload();\n+ control.events.on({\n+ activate: this.iconOn,\n+ deactivate: this.iconOff\n+ });\n }\n- return drawn;\n },\n \n /**\n- * Method: abortLoading\n- * Cancel a pending request.\n+ * Method: iconOn\n+ * Internal use, for use only with \"controls[i].events.on/un\".\n */\n- abortLoading: function() {\n- if (this.request) {\n- this.request.abort();\n- delete this.request;\n- }\n- this.isLoading = false;\n+ iconOn: function() {\n+ var d = this.panel_div; // \"this\" refers to a control on panel!\n+ var re = new RegExp(\"\\\\b(\" + this.displayClass + \"Item)Inactive\\\\b\");\n+ d.className = d.className.replace(re, \"$1Active\");\n },\n \n /**\n- * Method: getFeatureInfo\n- * Get feature information associated with a pixel offset. If the pixel\n- * offset corresponds to a feature, the returned object will have id\n- * and data properties. Otherwise, null will be returned.\n- * \n+ * Method: iconOff\n+ * Internal use, for use only with \"controls[i].events.on/un\".\n+ */\n+ iconOff: function() {\n+ var d = this.panel_div; // \"this\" refers to a control on panel!\n+ var re = new RegExp(\"\\\\b(\" + this.displayClass + \"Item)Active\\\\b\");\n+ d.className = d.className.replace(re, \"$1Inactive\");\n+ },\n+\n+ /**\n+ * Method: onButtonClick\n *\n * Parameters:\n- * i - {Number} X-axis pixel offset (from top left of tile)\n- * j - {Number} Y-axis pixel offset (from top left of tile)\n- *\n- * Returns:\n- * {Object} Object with feature id and data properties corresponding to the \n- * given pixel offset.\n+ * evt - {Event}\n */\n- getFeatureInfo: function(i, j) {\n- var info = null;\n- if (this.json) {\n- var id = this.getFeatureId(i, j);\n- if (id !== null) {\n- info = {\n- id: id,\n- data: this.json.data[id]\n- };\n+ onButtonClick: function(evt) {\n+ var controls = this.controls,\n+ button = evt.buttonElement;\n+ for (var i = controls.length - 1; i >= 0; --i) {\n+ if (controls[i].panel_div === button) {\n+ this.activateControl(controls[i]);\n+ break;\n }\n }\n- return info;\n },\n \n /**\n- * Method: getFeatureId\n- * Get the identifier for the feature associated with a pixel offset.\n+ * APIMethod: getControlsBy\n+ * Get a list of controls with properties matching the given criteria.\n *\n * Parameters:\n- * i - {Number} X-axis pixel offset (from top left of tile)\n- * j - {Number} Y-axis pixel offset (from top left of tile)\n+ * property - {String} A control property to be matched.\n+ * match - {String | Object} A string to match. Can also be a regular\n+ * expression literal or object. In addition, it can be any object\n+ * with a method named test. For reqular expressions or other, if\n+ * match.test(control[property]) evaluates to true, the control will be\n+ * included in the array returned. If no controls are found, an empty\n+ * array is returned.\n *\n * Returns:\n- * {Object} The feature identifier corresponding to the given pixel offset.\n- * Returns null if pixel doesn't correspond to a feature.\n+ * {Array()} A list of controls matching the given criteria.\n+ * An empty array is returned if no matches are found.\n */\n- getFeatureId: function(i, j) {\n- var id = null;\n- if (this.json) {\n- var resolution = this.utfgridResolution;\n- var row = Math.floor(j / resolution);\n- var col = Math.floor(i / resolution);\n- var charCode = this.json.grid[row].charCodeAt(col);\n- var index = this.indexFromCharCode(charCode);\n- var keys = this.json.keys;\n- if (!isNaN(index) && (index in keys)) {\n- id = keys[index];\n- }\n- }\n- return id;\n+ getControlsBy: function(property, match) {\n+ var test = (typeof match.test == \"function\");\n+ var found = OpenLayers.Array.filter(this.controls, function(item) {\n+ return item[property] == match || (test && match.test(item[property]));\n+ });\n+ return found;\n },\n \n /**\n- * Method: indexFromCharCode\n- * Given a character code for one of the UTFGrid \"grid\" characters, \n- * resolve the integer index for the feature id in the UTFGrid \"keys\"\n- * array.\n+ * APIMethod: getControlsByName\n+ * Get a list of contorls with names matching the given name.\n *\n * Parameters:\n- * charCode - {Integer}\n+ * match - {String | Object} A control name. The name can also be a regular\n+ * expression literal or object. In addition, it can be any object\n+ * with a method named test. For reqular expressions or other, if\n+ * name.test(control.name) evaluates to true, the control will be included\n+ * in the list of controls returned. If no controls are found, an empty\n+ * array is returned.\n *\n * Returns:\n- * {Integer} Index for the feature id from the keys array.\n+ * {Array()} A list of controls matching the given name.\n+ * An empty array is returned if no matches are found.\n */\n- indexFromCharCode: function(charCode) {\n- if (charCode >= 93) {\n- charCode--;\n- }\n- if (charCode >= 35) {\n- charCode--;\n- }\n- return charCode - 32;\n+ getControlsByName: function(match) {\n+ return this.getControlsBy(\"name\", match);\n },\n \n /**\n- * Method: parseData\n- * Parse the JSON from a request\n+ * APIMethod: getControlsByClass\n+ * Get a list of controls of a given type (CLASS_NAME).\n *\n * Parameters:\n- * str - {String} UTFGrid as a JSON string. \n- * \n+ * match - {String | Object} A control class name. The type can also be a\n+ * regular expression literal or object. In addition, it can be any\n+ * object with a method named test. For reqular expressions or other,\n+ * if type.test(control.CLASS_NAME) evaluates to true, the control will\n+ * be included in the list of controls returned. If no controls are\n+ * found, an empty array is returned.\n+ *\n * Returns:\n- * {Object} parsed javascript data\n- */\n- parseData: function(str) {\n- if (!this.format) {\n- this.format = new OpenLayers.Format.JSON();\n- }\n- this.json = this.format.read(str);\n- },\n-\n- /** \n- * Method: clear\n- * Delete data stored with this tile.\n+ * {Array()} A list of controls matching the given type.\n+ * An empty array is returned if no matches are found.\n */\n- clear: function() {\n- this.json = null;\n+ getControlsByClass: function(match) {\n+ return this.getControlsBy(\"CLASS_NAME\", match);\n },\n \n- CLASS_NAME: \"OpenLayers.Tile.UTFGrid\"\n-\n+ CLASS_NAME: \"OpenLayers.Control.Panel\"\n });\n+\n /* ======================================================================\n- OpenLayers/Layer/UTFGrid.js\n+ OpenLayers/Control/DragPan.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Layer/XYZ.js\n- * @requires OpenLayers/Tile/UTFGrid.js\n+ * @requires OpenLayers/Control.js\n+ * @requires OpenLayers/Handler/Drag.js\n */\n \n-/** \n- * Class: OpenLayers.Layer.UTFGrid\n- * This Layer reads from UTFGrid tiled data sources. Since UTFGrids are \n- * essentially JSON-based ASCII art with attached attributes, they are not \n- * visibly rendered. In order to use them in the map, you must add a \n- * control as well.\n- *\n- * Example:\n- *\n- * (start code)\n- * var world_utfgrid = new OpenLayers.Layer.UTFGrid({\n- * url: \"/tiles/world_utfgrid/${z}/${x}/${y}.json\",\n- * utfgridResolution: 4,\n- * displayInLayerSwitcher: false\n- * );\n- * map.addLayer(world_utfgrid);\n- * \n- * var control = new OpenLayers.Control.UTFGrid({\n- * layers: [world_utfgrid],\n- * handlerMode: 'move',\n- * callback: function(dataLookup) {\n- * // do something with returned data\n- * }\n- * })\n- * (end code)\n+/**\n+ * Class: OpenLayers.Control.DragPan\n+ * The DragPan control pans the map with a drag of the mouse.\n *\n- * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.UTFGrid = OpenLayers.Class(OpenLayers.Layer.XYZ, {\n+OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {\n \n- /**\n- * APIProperty: isBaseLayer\n- * Default is false, as UTFGrids are designed to be a transparent overlay layer. \n+ /** \n+ * Property: type\n+ * {OpenLayers.Control.TYPES}\n */\n- isBaseLayer: false,\n+ type: OpenLayers.Control.TYPE_TOOL,\n \n /**\n- * APIProperty: projection\n- * {}\n- * Source projection for the UTFGrids. Default is \"EPSG:900913\".\n+ * Property: panned\n+ * {Boolean} The map moved.\n */\n- projection: new OpenLayers.Projection(\"EPSG:900913\"),\n+ panned: false,\n \n /**\n- * Property: useJSONP\n- * {Boolean}\n- * Should we use a JSONP script approach instead of a standard AJAX call?\n- *\n- * Set to true for using utfgrids from another server. \n- * Avoids same-domain policy restrictions. \n- * Note that this only works if the server accepts \n- * the callback GET parameter and dynamically \n- * wraps the returned json in a function call.\n- * \n- * Default is false\n+ * Property: interval\n+ * {Integer} The number of milliseconds that should ellapse before\n+ * panning the map again. Defaults to 0 milliseconds, which means that\n+ * no separate cycle is used for panning. In most cases you won't want\n+ * to change this value. For slow machines/devices larger values can be\n+ * tried out.\n */\n- useJSONP: false,\n+ interval: 0,\n \n /**\n- * APIProperty: url\n- * {String}\n- * URL tempate for UTFGrid tiles. Include x, y, and z parameters.\n- * E.g. \"/tiles/${z}/${x}/${y}.json\"\n+ * APIProperty: documentDrag\n+ * {Boolean} If set to true, mouse dragging will continue even if the\n+ * mouse cursor leaves the map viewport. Default is false.\n */\n+ documentDrag: false,\n \n /**\n- * APIProperty: utfgridResolution\n- * {Number}\n- * Ratio of the pixel width to the width of a UTFGrid data point. If an \n- * entry in the grid represents a 4x4 block of pixels, the \n- * utfgridResolution would be 4. Default is 2 (specified in \n- * ).\n+ * Property: kinetic\n+ * {} The OpenLayers.Kinetic object.\n */\n+ kinetic: null,\n \n /**\n- * Property: tileClass\n- * {} The tile class to use for this layer.\n- * Defaults is .\n+ * APIProperty: enableKinetic\n+ * {Boolean} Set this option to enable \"kinetic dragging\". Can be\n+ * set to true or to an object. If set to an object this\n+ * object will be passed to the {}\n+ * constructor. Defaults to true.\n+ * To get kinetic dragging, ensure that OpenLayers/Kinetic.js is\n+ * included in your build config.\n */\n- tileClass: OpenLayers.Tile.UTFGrid,\n+ enableKinetic: true,\n \n /**\n- * Constructor: OpenLayers.Layer.UTFGrid\n- * Create a new UTFGrid layer.\n- *\n- * Parameters:\n- * config - {Object} Configuration properties for the layer.\n- *\n- * Required configuration properties:\n- * url - {String} The url template for UTFGrid tiles. See the property.\n+ * APIProperty: kineticInterval\n+ * {Integer} Interval in milliseconds between 2 steps in the \"kinetic\n+ * scrolling\". Applies only if enableKinetic is set. Defaults\n+ * to 10 milliseconds.\n */\n- initialize: function(options) {\n- OpenLayers.Layer.Grid.prototype.initialize.apply(\n- this, [options.name, options.url, {}, options]\n- );\n- this.tileOptions = OpenLayers.Util.extend({\n- utfgridResolution: this.utfgridResolution\n- }, this.tileOptions);\n- },\n+ kineticInterval: 10,\n+\n \n /**\n- * Method: createBackBuffer\n- * The UTFGrid cannot create a back buffer, so this method is overriden.\n+ * Method: draw\n+ * Creates a Drag handler, using and\n+ * as callbacks.\n */\n- createBackBuffer: function() {},\n+ draw: function() {\n+ if (this.enableKinetic && OpenLayers.Kinetic) {\n+ var config = {\n+ interval: this.kineticInterval\n+ };\n+ if (typeof this.enableKinetic === \"object\") {\n+ config = OpenLayers.Util.extend(config, this.enableKinetic);\n+ }\n+ this.kinetic = new OpenLayers.Kinetic(config);\n+ }\n+ this.handler = new OpenLayers.Handler.Drag(this, {\n+ \"move\": this.panMap,\n+ \"done\": this.panMapDone,\n+ \"down\": this.panMapStart\n+ }, {\n+ interval: this.interval,\n+ documentDrag: this.documentDrag\n+ });\n+ },\n \n /**\n- * APIMethod: clone\n- * Create a clone of this layer\n- *\n- * Parameters:\n- * obj - {Object} Only used by a subclass of this layer.\n- * \n- * Returns:\n- * {} An exact clone of this OpenLayers.Layer.UTFGrid\n+ * Method: panMapStart\n */\n- clone: function(obj) {\n- if (obj == null) {\n- obj = new OpenLayers.Layer.UTFGrid(this.getOptions());\n+ panMapStart: function() {\n+ if (this.kinetic) {\n+ this.kinetic.begin();\n }\n-\n- // get all additions from superclasses\n- obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);\n-\n- return obj;\n },\n \n /**\n- * APIProperty: getFeatureInfo\n- * Get details about a feature associated with a map location. The object\n- * returned will have id and data properties. If the given location\n- * doesn't correspond to a feature, null will be returned.\n+ * Method: panMap\n *\n * Parameters:\n- * location - {} map location\n- *\n- * Returns:\n- * {Object} Object representing the feature id and UTFGrid data \n- * corresponding to the given map location. Returns null if the given\n- * location doesn't hit a feature.\n+ * xy - {} Pixel of the mouse position\n */\n- getFeatureInfo: function(location) {\n- var info = null;\n- var tileInfo = this.getTileData(location);\n- if (tileInfo && tileInfo.tile) {\n- info = tileInfo.tile.getFeatureInfo(tileInfo.i, tileInfo.j);\n+ panMap: function(xy) {\n+ if (this.kinetic) {\n+ this.kinetic.update(xy);\n }\n- return info;\n+ this.panned = true;\n+ this.map.pan(\n+ this.handler.last.x - xy.x,\n+ this.handler.last.y - xy.y, {\n+ dragging: true,\n+ animate: false\n+ }\n+ );\n },\n \n /**\n- * APIMethod: getFeatureId\n- * Get the identifier for the feature associated with a map location.\n+ * Method: panMapDone\n+ * Finish the panning operation. Only call setCenter (through )\n+ * if the map has actually been moved.\n *\n * Parameters:\n- * location - {} map location\n- *\n- * Returns:\n- * {String} The feature identifier corresponding to the given map location.\n- * Returns null if the location doesn't hit a feature.\n+ * xy - {} Pixel of the mouse position\n */\n- getFeatureId: function(location) {\n- var id = null;\n- var info = this.getTileData(location);\n- if (info.tile) {\n- id = info.tile.getFeatureId(info.i, info.j);\n+ panMapDone: function(xy) {\n+ if (this.panned) {\n+ var res = null;\n+ if (this.kinetic) {\n+ res = this.kinetic.end(xy);\n+ }\n+ this.map.pan(\n+ this.handler.last.x - xy.x,\n+ this.handler.last.y - xy.y, {\n+ dragging: !!res,\n+ animate: false\n+ }\n+ );\n+ if (res) {\n+ var self = this;\n+ this.kinetic.move(res, function(x, y, end) {\n+ self.map.pan(x, y, {\n+ dragging: !end,\n+ animate: false\n+ });\n+ });\n+ }\n+ this.panned = false;\n }\n- return id;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.UTFGrid\"\n+ CLASS_NAME: \"OpenLayers.Control.DragPan\"\n });\n /* ======================================================================\n- OpenLayers/Layer/Bing.js\n+ OpenLayers/Control/Navigation.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Layer/XYZ.js\n+ * @requires OpenLayers/Control/ZoomBox.js\n+ * @requires OpenLayers/Control/DragPan.js\n+ * @requires OpenLayers/Handler/MouseWheel.js\n+ * @requires OpenLayers/Handler/Click.js\n */\n \n-/** \n- * Class: OpenLayers.Layer.Bing\n- * Bing layer using direct tile access as provided by Bing Maps REST Services.\n- * See http://msdn.microsoft.com/en-us/library/ff701713.aspx for more\n- * information. Note: Terms of Service compliant use requires the map to be\n- * configured with an control and the\n- * attribution placed on or near the map.\n+/**\n+ * Class: OpenLayers.Control.Navigation\n+ * The navigation control handles map browsing with mouse events (dragging,\n+ * double-clicking, and scrolling the wheel). Create a new navigation \n+ * control with the control. \n * \n- * Inherits from:\n- * - \n+ * Note that this control is added to the map by default (if no controls \n+ * array is sent in the options object to the \n+ * constructor).\n+ * \n+ * Inherits:\n+ * - \n */\n-OpenLayers.Layer.Bing = OpenLayers.Class(OpenLayers.Layer.XYZ, {\n+OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {\n+\n+ /** \n+ * Property: dragPan\n+ * {} \n+ */\n+ dragPan: null,\n \n /**\n- * Property: key\n- * {String} API key for Bing maps, get your own key \n- * at http://bingmapsportal.com/ .\n+ * APIProperty: dragPanOptions\n+ * {Object} Options passed to the DragPan control.\n */\n- key: null,\n+ dragPanOptions: null,\n \n /**\n- * Property: serverResolutions\n- * {Array} the resolutions provided by the Bing servers.\n+ * Property: pinchZoom\n+ * {}\n */\n- serverResolutions: [\n- 156543.03390625, 78271.516953125, 39135.7584765625,\n- 19567.87923828125, 9783.939619140625, 4891.9698095703125,\n- 2445.9849047851562, 1222.9924523925781, 611.4962261962891,\n- 305.74811309814453, 152.87405654907226, 76.43702827453613,\n- 38.218514137268066, 19.109257068634033, 9.554628534317017,\n- 4.777314267158508, 2.388657133579254, 1.194328566789627,\n- 0.5971642833948135, 0.29858214169740677, 0.14929107084870338,\n- 0.07464553542435169\n- ],\n+ pinchZoom: null,\n \n /**\n- * Property: attributionTemplate\n- * {String}\n+ * APIProperty: pinchZoomOptions\n+ * {Object} Options passed to the PinchZoom control.\n */\n- attributionTemplate: '' +\n- '${copyrights}' +\n- '' +\n- 'Terms of Use',\n+ pinchZoomOptions: null,\n \n /**\n- * Property: metadata\n- * {Object} Metadata for this layer, as returned by the callback script\n+ * APIProperty: documentDrag\n+ * {Boolean} Allow panning of the map by dragging outside map viewport.\n+ * Default is false.\n */\n- metadata: null,\n+ documentDrag: false,\n+\n+ /** \n+ * Property: zoomBox\n+ * {}\n+ */\n+ zoomBox: null,\n \n /**\n- * Property: protocolRegex\n- * {RegExp} Regular expression to match and replace http: in bing urls\n+ * APIProperty: zoomBoxEnabled\n+ * {Boolean} Whether the user can draw a box to zoom\n */\n- protocolRegex: /^http:/i,\n+ zoomBoxEnabled: true,\n \n /**\n- * APIProperty: type\n- * {String} The layer identifier. Any non-birdseye imageryType\n- * from http://msdn.microsoft.com/en-us/library/ff701716.aspx can be\n- * used. Default is \"Road\".\n+ * APIProperty: zoomWheelEnabled\n+ * {Boolean} Whether the mousewheel should zoom the map\n */\n- type: \"Road\",\n+ zoomWheelEnabled: true,\n \n /**\n- * APIProperty: culture\n- * {String} The culture identifier. See http://msdn.microsoft.com/en-us/library/ff701709.aspx\n- * for the definition and the possible values. Default is \"en-US\".\n+ * Property: mouseWheelOptions\n+ * {Object} Options passed to the MouseWheel control (only useful if\n+ * is set to true). Default is no options for maps\n+ * with fractionalZoom set to true, otherwise\n+ * {cumulative: false, interval: 50, maxDelta: 6} \n */\n- culture: \"en-US\",\n+ mouseWheelOptions: null,\n \n /**\n- * APIProperty: metadataParams\n- * {Object} Optional url parameters for the Get Imagery Metadata request\n- * as described here: http://msdn.microsoft.com/en-us/library/ff701716.aspx\n+ * APIProperty: handleRightClicks\n+ * {Boolean} Whether or not to handle right clicks. Default is false.\n */\n- metadataParams: null,\n+ handleRightClicks: false,\n \n- /** APIProperty: tileOptions\n- * {Object} optional configuration options for instances\n- * created by this Layer. Default is\n- *\n- * (code)\n- * {crossOriginKeyword: 'anonymous'}\n- * (end)\n+ /**\n+ * APIProperty: zoomBoxKeyMask\n+ * {Integer} key code of the key, which has to be\n+ * pressed, while drawing the zoom box with the mouse on the screen. \n+ * You should probably set handleRightClicks to true if you use this\n+ * with MOD_CTRL, to disable the context menu for machines which use\n+ * CTRL-Click as a right click.\n+ * Default: \n */\n- tileOptions: null,\n+ zoomBoxKeyMask: OpenLayers.Handler.MOD_SHIFT,\n \n- /** APIProperty: protocol\n- * {String} Protocol to use to fetch Imagery Metadata, tiles and bing logo\n- * Can be 'http:' 'https:' or ''\n- *\n- * Warning: tiles may not be available under both HTTP and HTTPS protocols.\n- * Microsoft approved use of both HTTP and HTTPS urls for tiles. However\n- * this is undocumented and the Imagery Metadata API always returns HTTP\n- * urls.\n- *\n- * Default is '', unless when executed from a file:/// uri, in which case\n- * it is 'http:'.\n+ /**\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * true.\n */\n- protocol: ~window.location.href.indexOf('http') ? '' : 'http:',\n+ autoActivate: true,\n \n /**\n- * Constructor: OpenLayers.Layer.Bing\n- * Create a new Bing layer.\n- *\n- * Example:\n- * (code)\n- * var road = new OpenLayers.Layer.Bing({\n- * name: \"My Bing Aerial Layer\",\n- * type: \"Aerial\",\n- * key: \"my-api-key-here\",\n- * });\n- * (end)\n- *\n+ * Constructor: OpenLayers.Control.Navigation\n+ * Create a new navigation control\n+ * \n * Parameters:\n- * options - {Object} Configuration properties for the layer.\n- *\n- * Required configuration properties:\n- * key - {String} Bing Maps API key for your application. Get one at\n- * http://bingmapsportal.com/.\n- * type - {String} The layer identifier. Any non-birdseye imageryType\n- * from http://msdn.microsoft.com/en-us/library/ff701716.aspx can be\n- * used.\n- *\n- * Any other documented layer properties can be provided in the config object.\n+ * options - {Object} An optional object whose properties will be set on\n+ * the control\n */\n initialize: function(options) {\n- options = OpenLayers.Util.applyDefaults({\n- sphericalMercator: true\n- }, options);\n- var name = options.name || \"Bing \" + (options.type || this.type);\n-\n- var newArgs = [name, null, options];\n- OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArgs);\n- this.tileOptions = OpenLayers.Util.extend({\n- crossOriginKeyword: 'anonymous'\n- }, this.options.tileOptions);\n- this.loadMetadata();\n+ this.handlers = {};\n+ OpenLayers.Control.prototype.initialize.apply(this, arguments);\n },\n \n /**\n- * Method: loadMetadata\n+ * Method: destroy\n+ * The destroy method is used to perform any clean up before the control\n+ * is dereferenced. Typically this is where event listeners are removed\n+ * to prevent memory leaks.\n */\n- loadMetadata: function() {\n- this._callbackId = \"_callback_\" + this.id.replace(/\\./g, \"_\");\n- // link the processMetadata method to the global scope and bind it\n- // to this instance\n- window[this._callbackId] = OpenLayers.Function.bind(\n- OpenLayers.Layer.Bing.processMetadata, this\n- );\n- var params = OpenLayers.Util.applyDefaults({\n- key: this.key,\n- jsonp: this._callbackId,\n- include: \"ImageryProviders\"\n- }, this.metadataParams);\n- var url = this.protocol + \"//dev.virtualearth.net/REST/v1/Imagery/Metadata/\" +\n- this.type + \"?\" + OpenLayers.Util.getParameterString(params);\n- var script = document.createElement(\"script\");\n- script.type = \"text/javascript\";\n- script.src = url;\n- script.id = this._callbackId;\n- document.getElementsByTagName(\"head\")[0].appendChild(script);\n+ destroy: function() {\n+ this.deactivate();\n+\n+ if (this.dragPan) {\n+ this.dragPan.destroy();\n+ }\n+ this.dragPan = null;\n+\n+ if (this.zoomBox) {\n+ this.zoomBox.destroy();\n+ }\n+ this.zoomBox = null;\n+\n+ if (this.pinchZoom) {\n+ this.pinchZoom.destroy();\n+ }\n+ this.pinchZoom = null;\n+\n+ OpenLayers.Control.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: initLayer\n- *\n- * Sets layer properties according to the metadata provided by the API\n+ * Method: activate\n */\n- initLayer: function() {\n- var res = this.metadata.resourceSets[0].resources[0];\n- var url = res.imageUrl.replace(\"{quadkey}\", \"${quadkey}\");\n- url = url.replace(\"{culture}\", this.culture);\n- url = url.replace(this.protocolRegex, this.protocol);\n- this.url = [];\n- for (var i = 0; i < res.imageUrlSubdomains.length; ++i) {\n- this.url.push(url.replace(\"{subdomain}\", res.imageUrlSubdomains[i]));\n+ activate: function() {\n+ this.dragPan.activate();\n+ if (this.zoomWheelEnabled) {\n+ this.handlers.wheel.activate();\n }\n- this.addOptions({\n- maxResolution: Math.min(\n- this.serverResolutions[res.zoomMin],\n- this.maxResolution || Number.POSITIVE_INFINITY\n- ),\n- numZoomLevels: Math.min(\n- res.zoomMax + 1 - res.zoomMin, this.numZoomLevels\n- )\n- }, true);\n- if (!this.isBaseLayer) {\n- this.redraw();\n+ this.handlers.click.activate();\n+ if (this.zoomBoxEnabled) {\n+ this.zoomBox.activate();\n }\n- this.updateAttribution();\n+ if (this.pinchZoom) {\n+ this.pinchZoom.activate();\n+ }\n+ return OpenLayers.Control.prototype.activate.apply(this, arguments);\n },\n \n /**\n- * Method: getURL\n- *\n- * Paramters:\n- * bounds - {}\n+ * Method: deactivate\n */\n- getURL: function(bounds) {\n- if (!this.url) {\n- return;\n- }\n- var xyz = this.getXYZ(bounds),\n- x = xyz.x,\n- y = xyz.y,\n- z = xyz.z;\n- var quadDigits = [];\n- for (var i = z; i > 0; --i) {\n- var digit = '0';\n- var mask = 1 << (i - 1);\n- if ((x & mask) != 0) {\n- digit++;\n- }\n- if ((y & mask) != 0) {\n- digit++;\n- digit++;\n- }\n- quadDigits.push(digit);\n+ deactivate: function() {\n+ if (this.pinchZoom) {\n+ this.pinchZoom.deactivate();\n }\n- var quadKey = quadDigits.join(\"\");\n- var url = this.selectUrl('' + x + y + z, this.url);\n-\n- return OpenLayers.String.format(url, {\n- 'quadkey': quadKey\n- });\n+ this.zoomBox.deactivate();\n+ this.dragPan.deactivate();\n+ this.handlers.click.deactivate();\n+ this.handlers.wheel.deactivate();\n+ return OpenLayers.Control.prototype.deactivate.apply(this, arguments);\n },\n \n /**\n- * Method: updateAttribution\n- * Updates the attribution according to the requirements outlined in\n- * http://gis.638310.n2.nabble.com/Bing-imagery-td5789168.html\n+ * Method: draw\n */\n- updateAttribution: function() {\n- var metadata = this.metadata;\n- if (!metadata.resourceSets || !this.map || !this.map.center) {\n- return;\n+ draw: function() {\n+ // disable right mouse context menu for support of right click events\n+ if (this.handleRightClicks) {\n+ this.map.viewPortDiv.oncontextmenu = OpenLayers.Function.False;\n }\n- var res = metadata.resourceSets[0].resources[0];\n- var extent = this.map.getExtent().transform(\n- this.map.getProjectionObject(),\n- new OpenLayers.Projection(\"EPSG:4326\")\n+\n+ var clickCallbacks = {\n+ 'click': this.defaultClick,\n+ 'dblclick': this.defaultDblClick,\n+ 'dblrightclick': this.defaultDblRightClick\n+ };\n+ var clickOptions = {\n+ 'double': true,\n+ 'stopDouble': true\n+ };\n+ this.handlers.click = new OpenLayers.Handler.Click(\n+ this, clickCallbacks, clickOptions\n );\n- var providers = res.imageryProviders || [],\n- zoom = OpenLayers.Util.indexOf(this.serverResolutions,\n- this.getServerResolution()),\n- copyrights = \"\",\n- provider, i, ii, j, jj, bbox, coverage;\n- for (i = 0, ii = providers.length; i < ii; ++i) {\n- provider = providers[i];\n- for (j = 0, jj = provider.coverageAreas.length; j < jj; ++j) {\n- coverage = provider.coverageAreas[j];\n- // axis order provided is Y,X\n- bbox = OpenLayers.Bounds.fromArray(coverage.bbox, true);\n- if (extent.intersectsBounds(bbox) &&\n- zoom <= coverage.zoomMax && zoom >= coverage.zoomMin) {\n- copyrights += provider.attribution + \" \";\n- }\n- }\n- }\n- var logo = metadata.brandLogoUri.replace(this.protocolRegex, this.protocol);\n- this.attribution = OpenLayers.String.format(this.attributionTemplate, {\n- type: this.type.toLowerCase(),\n- logo: logo,\n- copyrights: copyrights\n- });\n- this.map && this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"attribution\"\n+ this.dragPan = new OpenLayers.Control.DragPan(\n+ OpenLayers.Util.extend({\n+ map: this.map,\n+ documentDrag: this.documentDrag\n+ }, this.dragPanOptions)\n+ );\n+ this.zoomBox = new OpenLayers.Control.ZoomBox({\n+ map: this.map,\n+ keyMask: this.zoomBoxKeyMask\n });\n+ this.dragPan.draw();\n+ this.zoomBox.draw();\n+ var wheelOptions = this.map.fractionalZoom ? {} : {\n+ cumulative: false,\n+ interval: 50,\n+ maxDelta: 6\n+ };\n+ this.handlers.wheel = new OpenLayers.Handler.MouseWheel(\n+ this, {\n+ up: this.wheelUp,\n+ down: this.wheelDown\n+ },\n+ OpenLayers.Util.extend(wheelOptions, this.mouseWheelOptions)\n+ );\n+ if (OpenLayers.Control.PinchZoom) {\n+ this.pinchZoom = new OpenLayers.Control.PinchZoom(\n+ OpenLayers.Util.extend({\n+ map: this.map\n+ }, this.pinchZoomOptions));\n+ }\n },\n \n /**\n- * Method: setMap\n+ * Method: defaultClick\n+ *\n+ * Parameters:\n+ * evt - {Event}\n */\n- setMap: function() {\n- OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments);\n- this.map.events.register(\"moveend\", this, this.updateAttribution);\n+ defaultClick: function(evt) {\n+ if (evt.lastTouches && evt.lastTouches.length == 2) {\n+ this.map.zoomOut();\n+ }\n },\n \n /**\n- * APIMethod: clone\n+ * Method: defaultDblClick \n * \n * Parameters:\n- * obj - {Object}\n- * \n- * Returns:\n- * {} An exact clone of this \n+ * evt - {Event} \n */\n- clone: function(obj) {\n- if (obj == null) {\n- obj = new OpenLayers.Layer.Bing(this.options);\n- }\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]);\n- // copy/set any non-init, non-simple values here\n- return obj;\n+ defaultDblClick: function(evt) {\n+ this.map.zoomTo(this.map.zoom + 1, evt.xy);\n },\n \n /**\n- * Method: destroy\n+ * Method: defaultDblRightClick \n+ * \n+ * Parameters:\n+ * evt - {Event} \n */\n- destroy: function() {\n- this.map &&\n- this.map.events.unregister(\"moveend\", this, this.updateAttribution);\n- OpenLayers.Layer.XYZ.prototype.destroy.apply(this, arguments);\n+ defaultDblRightClick: function(evt) {\n+ this.map.zoomTo(this.map.zoom - 1, evt.xy);\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.Bing\"\n-});\n-\n-/**\n- * Function: OpenLayers.Layer.Bing.processMetadata\n- * This function will be bound to an instance, linked to the global scope with\n- * an id, and called by the JSONP script returned by the API.\n- *\n- * Parameters:\n- * metadata - {Object} metadata as returned by the API\n- */\n-OpenLayers.Layer.Bing.processMetadata = function(metadata) {\n- this.metadata = metadata;\n- this.initLayer();\n- var script = document.getElementById(this._callbackId);\n- script.parentNode.removeChild(script);\n- window[this._callbackId] = undefined; // cannot delete from window in IE\n- delete this._callbackId;\n-};\n-/* ======================================================================\n- OpenLayers/Layer/Markers.js\n- ====================================================================== */\n-\n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/Layer.js\n- */\n-\n-/**\n- * Class: OpenLayers.Layer.Markers\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Layer.Markers = OpenLayers.Class(OpenLayers.Layer, {\n-\n- /** \n- * APIProperty: isBaseLayer \n- * {Boolean} Markers layer is never a base layer. \n- */\n- isBaseLayer: false,\n-\n- /** \n- * APIProperty: markers \n- * {Array()} internal marker list \n- */\n- markers: null,\n-\n-\n- /** \n- * Property: drawn \n- * {Boolean} internal state of drawing. This is a workaround for the fact\n- * that the map does not call moveTo with a zoomChanged when the map is\n- * first starting up. This lets us catch the case where we have *never*\n- * drawn the layer, and draw it even if the zoom hasn't changed.\n- */\n- drawn: false,\n-\n /**\n- * Constructor: OpenLayers.Layer.Markers \n- * Create a Markers layer.\n+ * Method: wheelChange \n *\n * Parameters:\n- * name - {String} \n- * options - {Object} Hashtable of extra options to tag onto the layer\n- */\n- initialize: function(name, options) {\n- OpenLayers.Layer.prototype.initialize.apply(this, arguments);\n- this.markers = [];\n- },\n-\n- /**\n- * APIMethod: destroy \n+ * evt - {Event}\n+ * deltaZ - {Integer}\n */\n- destroy: function() {\n- this.clearMarkers();\n- this.markers = null;\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n+ wheelChange: function(evt, deltaZ) {\n+ if (!this.map.fractionalZoom) {\n+ deltaZ = Math.round(deltaZ);\n+ }\n+ var currentZoom = this.map.getZoom(),\n+ newZoom = currentZoom + deltaZ;\n+ newZoom = Math.max(newZoom, 0);\n+ newZoom = Math.min(newZoom, this.map.getNumZoomLevels());\n+ if (newZoom === currentZoom) {\n+ return;\n+ }\n+ this.map.zoomTo(newZoom, evt.xy);\n },\n \n- /**\n- * APIMethod: setOpacity\n- * Sets the opacity for all the markers.\n+ /** \n+ * Method: wheelUp\n+ * User spun scroll wheel up\n * \n * Parameters:\n- * opacity - {Float}\n+ * evt - {Event}\n+ * delta - {Integer}\n */\n- setOpacity: function(opacity) {\n- if (opacity != this.opacity) {\n- this.opacity = opacity;\n- for (var i = 0, len = this.markers.length; i < len; i++) {\n- this.markers[i].setOpacity(this.opacity);\n- }\n- }\n+ wheelUp: function(evt, delta) {\n+ this.wheelChange(evt, delta || 1);\n },\n \n /** \n- * Method: moveTo\n- *\n+ * Method: wheelDown\n+ * User spun scroll wheel down\n+ * \n * Parameters:\n- * bounds - {} \n- * zoomChanged - {Boolean} \n- * dragging - {Boolean} \n+ * evt - {Event}\n+ * delta - {Integer}\n */\n- moveTo: function(bounds, zoomChanged, dragging) {\n- OpenLayers.Layer.prototype.moveTo.apply(this, arguments);\n-\n- if (zoomChanged || !this.drawn) {\n- for (var i = 0, len = this.markers.length; i < len; i++) {\n- this.drawMarker(this.markers[i]);\n- }\n- this.drawn = true;\n- }\n+ wheelDown: function(evt, delta) {\n+ this.wheelChange(evt, delta || -1);\n },\n \n /**\n- * APIMethod: addMarker\n- *\n- * Parameters:\n- * marker - {} \n+ * Method: disableZoomBox\n */\n- addMarker: function(marker) {\n- this.markers.push(marker);\n-\n- if (this.opacity < 1) {\n- marker.setOpacity(this.opacity);\n- }\n-\n- if (this.map && this.map.getExtent()) {\n- marker.map = this.map;\n- this.drawMarker(marker);\n- }\n+ disableZoomBox: function() {\n+ this.zoomBoxEnabled = false;\n+ this.zoomBox.deactivate();\n },\n \n /**\n- * APIMethod: removeMarker\n- *\n- * Parameters:\n- * marker - {} \n+ * Method: enableZoomBox\n */\n- removeMarker: function(marker) {\n- if (this.markers && this.markers.length) {\n- OpenLayers.Util.removeItem(this.markers, marker);\n- marker.erase();\n+ enableZoomBox: function() {\n+ this.zoomBoxEnabled = true;\n+ if (this.active) {\n+ this.zoomBox.activate();\n }\n },\n \n /**\n- * Method: clearMarkers\n- * This method removes all markers from a layer. The markers are not\n- * destroyed by this function, but are removed from the list of markers.\n+ * Method: disableZoomWheel\n */\n- clearMarkers: function() {\n- if (this.markers != null) {\n- while (this.markers.length > 0) {\n- this.removeMarker(this.markers[0]);\n- }\n- }\n- },\n \n- /** \n- * Method: drawMarker\n- * Calculate the pixel location for the marker, create it, and \n- * add it to the layer's div\n- *\n- * Parameters:\n- * marker - {} \n- */\n- drawMarker: function(marker) {\n- var px = this.map.getLayerPxFromLonLat(marker.lonlat);\n- if (px == null) {\n- marker.display(false);\n- } else {\n- if (!marker.isDrawn()) {\n- var markerImg = marker.draw(px);\n- this.div.appendChild(markerImg);\n- } else if (marker.icon) {\n- marker.icon.moveTo(px);\n- }\n- }\n+ disableZoomWheel: function() {\n+ this.zoomWheelEnabled = false;\n+ this.handlers.wheel.deactivate();\n },\n \n- /** \n- * APIMethod: getDataExtent\n- * Calculates the max extent which includes all of the markers.\n- * \n- * Returns:\n- * {}\n+ /**\n+ * Method: enableZoomWheel\n */\n- getDataExtent: function() {\n- var maxExtent = null;\n \n- if (this.markers && (this.markers.length > 0)) {\n- var maxExtent = new OpenLayers.Bounds();\n- for (var i = 0, len = this.markers.length; i < len; i++) {\n- var marker = this.markers[i];\n- maxExtent.extend(marker.lonlat);\n- }\n+ enableZoomWheel: function() {\n+ this.zoomWheelEnabled = true;\n+ if (this.active) {\n+ this.handlers.wheel.activate();\n }\n-\n- return maxExtent;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.Markers\"\n+ CLASS_NAME: \"OpenLayers.Control.Navigation\"\n });\n /* ======================================================================\n- OpenLayers/Format/Text.js\n+ OpenLayers/Control/EditingToolbar.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n /**\n- * @requires OpenLayers/Feature/Vector.js\n- * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/Control/Panel.js\n+ * @requires OpenLayers/Control/Navigation.js\n+ * @requires OpenLayers/Control/DrawFeature.js\n+ * @requires OpenLayers/Handler/Point.js\n+ * @requires OpenLayers/Handler/Path.js\n+ * @requires OpenLayers/Handler/Polygon.js\n */\n \n /**\n- * Class: OpenLayers.Format.Text\n- * Read Text format. Create a new instance with the \n- * constructor. This reads text which is formatted like CSV text, using\n- * tabs as the seperator by default. It provides parsing of data originally\n- * used in the MapViewerService, described on the wiki. This Format is used\n- * by the class.\n- *\n+ * Class: OpenLayers.Control.EditingToolbar \n+ * The EditingToolbar is a panel of 4 controls to draw polygons, lines, \n+ * points, or to navigate the map by panning. By default it appears in the \n+ * upper right corner of the map.\n+ * \n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Format.Text = OpenLayers.Class(OpenLayers.Format, {\n-\n- /**\n- * APIProperty: defaultStyle\n- * defaultStyle allows one to control the default styling of the features.\n- * It should be a symbolizer hash. By default, this is set to match the\n- * Layer.Text behavior, which is to use the default OpenLayers Icon.\n- */\n- defaultStyle: null,\n-\n- /**\n- * APIProperty: extractStyles\n- * set to true to extract styles from the TSV files, using information\n- * from the image or icon, iconSize and iconOffset fields. This will result\n- * in features with a symbolizer (style) property set, using the\n- * default symbolizer specified in . Set to false if you\n- * wish to use a styleMap or OpenLayers.Style options to style your\n- * layer instead.\n- */\n- extractStyles: true,\n-\n- /**\n- * Constructor: OpenLayers.Format.Text\n- * Create a new parser for TSV Text.\n- *\n- * Parameters:\n- * options - {Object} An optional object whose properties will be set on\n- * this instance.\n- */\n- initialize: function(options) {\n- options = options || {};\n-\n- if (options.extractStyles !== false) {\n- options.defaultStyle = {\n- 'externalGraphic': OpenLayers.Util.getImageLocation(\"marker.png\"),\n- 'graphicWidth': 21,\n- 'graphicHeight': 25,\n- 'graphicXOffset': -10.5,\n- 'graphicYOffset': -12.5\n- };\n- }\n-\n- OpenLayers.Format.prototype.initialize.apply(this, [options]);\n- },\n+OpenLayers.Control.EditingToolbar = OpenLayers.Class(\n+ OpenLayers.Control.Panel, {\n \n- /**\n- * APIMethod: read\n- * Return a list of features from a Tab Seperated Values text string.\n- * \n- * Parameters:\n- * text - {String} \n- *\n- * Returns:\n- * Array({})\n- */\n- read: function(text) {\n- var lines = text.split('\\n');\n- var columns;\n- var features = [];\n- // length - 1 to allow for trailing new line\n- for (var lcv = 0; lcv < (lines.length - 1); lcv++) {\n- var currLine = lines[lcv].replace(/^\\s*/, '').replace(/\\s*$/, '');\n+ /**\n+ * APIProperty: citeCompliant\n+ * {Boolean} If set to true, coordinates of features drawn in a map extent\n+ * crossing the date line won't exceed the world bounds. Default is false.\n+ */\n+ citeCompliant: false,\n \n- if (currLine.charAt(0) != '#') {\n- /* not a comment */\n+ /**\n+ * Constructor: OpenLayers.Control.EditingToolbar\n+ * Create an editing toolbar for a given layer. \n+ *\n+ * Parameters:\n+ * layer - {} \n+ * options - {Object} \n+ */\n+ initialize: function(layer, options) {\n+ OpenLayers.Control.Panel.prototype.initialize.apply(this, [options]);\n \n- if (!columns) {\n- //First line is columns\n- columns = currLine.split('\\t');\n- } else {\n- var vals = currLine.split('\\t');\n- var geometry = new OpenLayers.Geometry.Point(0, 0);\n- var attributes = {};\n- var style = this.defaultStyle ?\n- OpenLayers.Util.applyDefaults({}, this.defaultStyle) :\n- null;\n- var icon, iconSize, iconOffset, overflow;\n- var set = false;\n- for (var valIndex = 0; valIndex < vals.length; valIndex++) {\n- if (vals[valIndex]) {\n- if (columns[valIndex] == 'point') {\n- var coords = vals[valIndex].split(',');\n- geometry.y = parseFloat(coords[0]);\n- geometry.x = parseFloat(coords[1]);\n- set = true;\n- } else if (columns[valIndex] == 'lat') {\n- geometry.y = parseFloat(vals[valIndex]);\n- set = true;\n- } else if (columns[valIndex] == 'lon') {\n- geometry.x = parseFloat(vals[valIndex]);\n- set = true;\n- } else if (columns[valIndex] == 'title')\n- attributes['title'] = vals[valIndex];\n- else if (columns[valIndex] == 'image' ||\n- columns[valIndex] == 'icon' && style) {\n- style['externalGraphic'] = vals[valIndex];\n- } else if (columns[valIndex] == 'iconSize' && style) {\n- var size = vals[valIndex].split(',');\n- style['graphicWidth'] = parseFloat(size[0]);\n- style['graphicHeight'] = parseFloat(size[1]);\n- } else if (columns[valIndex] == 'iconOffset' && style) {\n- var offset = vals[valIndex].split(',');\n- style['graphicXOffset'] = parseFloat(offset[0]);\n- style['graphicYOffset'] = parseFloat(offset[1]);\n- } else if (columns[valIndex] == 'description') {\n- attributes['description'] = vals[valIndex];\n- } else if (columns[valIndex] == 'overflow') {\n- attributes['overflow'] = vals[valIndex];\n- } else {\n- // For StyleMap filtering, allow additional\n- // columns to be stored as attributes.\n- attributes[columns[valIndex]] = vals[valIndex];\n- }\n- }\n+ this.addControls(\n+ [new OpenLayers.Control.Navigation()]\n+ );\n+ var controls = [\n+ new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Point, {\n+ displayClass: 'olControlDrawFeaturePoint',\n+ handlerOptions: {\n+ citeCompliant: this.citeCompliant\n }\n- if (set) {\n- if (this.internalProjection && this.externalProjection) {\n- geometry.transform(this.externalProjection,\n- this.internalProjection);\n- }\n- var feature = new OpenLayers.Feature.Vector(geometry, attributes, style);\n- features.push(feature);\n+ }),\n+ new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {\n+ displayClass: 'olControlDrawFeaturePath',\n+ handlerOptions: {\n+ citeCompliant: this.citeCompliant\n }\n- }\n+ }),\n+ new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Polygon, {\n+ displayClass: 'olControlDrawFeaturePolygon',\n+ handlerOptions: {\n+ citeCompliant: this.citeCompliant\n+ }\n+ })\n+ ];\n+ this.addControls(controls);\n+ },\n+\n+ /**\n+ * Method: draw\n+ * calls the default draw, and then activates mouse defaults.\n+ *\n+ * Returns:\n+ * {DOMElement}\n+ */\n+ draw: function() {\n+ var div = OpenLayers.Control.Panel.prototype.draw.apply(this, arguments);\n+ if (this.defaultControl === null) {\n+ this.defaultControl = this.controls[0];\n }\n- }\n- return features;\n- },\n+ return div;\n+ },\n \n- CLASS_NAME: \"OpenLayers.Format.Text\"\n-});\n+ CLASS_NAME: \"OpenLayers.Control.EditingToolbar\"\n+ });\n /* ======================================================================\n- OpenLayers/Layer/Text.js\n+ OpenLayers/Control/PanZoomBar.js\n ====================================================================== */\n \n /* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n * full list of contributors). Published under the 2-clause BSD license.\n * See license.txt in the OpenLayers distribution or repository for the\n * full text of the license. */\n \n \n /**\n- * @requires OpenLayers/Layer/Markers.js\n- * @requires OpenLayers/Format/Text.js\n- * @requires OpenLayers/Request/XMLHttpRequest.js\n+ * @requires OpenLayers/Control/PanZoom.js\n */\n \n /**\n- * Class: OpenLayers.Layer.Text\n- * This layer creates markers given data in a text file. The \n- * property of the layer (specified as a property of the options argument\n- * in the constructor) points to a tab delimited\n- * file with data used to create markers.\n- *\n- * The first row of the data file should be a header line with the column names\n- * of the data. Each column should be delimited by a tab space. The\n- * possible columns are:\n- * - *point* lat,lon of the point where a marker is to be placed\n- * - *lat* Latitude of the point where a marker is to be placed\n- * - *lon* Longitude of the point where a marker is to be placed\n- * - *icon* or *image* URL of marker icon to use.\n- * - *iconSize* Size of Icon to use.\n- * - *iconOffset* Where the top-left corner of the icon is to be placed\n- * relative to the latitude and longitude of the point.\n- * - *title* The text of the 'title' is placed inside an 'h2' marker\n- * inside a popup, which opens when the marker is clicked.\n- * - *description* The text of the 'description' is placed below the h2\n- * in the popup. this can be plain text or HTML.\n- *\n- * Example text file:\n- * (code)\n- * lat\tlon\ttitle\tdescription\ticonSize\ticonOffset\ticon\n- * 10\t20\ttitle\tdescription\t21,25\t\t-10,-25\t\thttp://www.openlayers.org/dev/img/marker.png\n- * (end)\n+ * Class: OpenLayers.Control.PanZoomBar\n+ * The PanZoomBar is a visible control composed of a\n+ * and a . \n+ * By default it is displayed in the upper left corner of the map as 4\n+ * directional arrows above a vertical slider.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, {\n+OpenLayers.Control.PanZoomBar = OpenLayers.Class(OpenLayers.Control.PanZoom, {\n \n- /**\n- * APIProperty: location \n- * {String} URL of text file. Must be specified in the \"options\" argument\n- * of the constructor. Can not be changed once passed in. \n+ /** \n+ * APIProperty: zoomStopWidth\n */\n- location: null,\n+ zoomStopWidth: 18,\n \n /** \n- * Property: features\n- * {Array()} \n+ * APIProperty: zoomStopHeight\n */\n- features: null,\n+ zoomStopHeight: 11,\n \n- /**\n- * APIProperty: formatOptions\n- * {Object} Hash of options which should be passed to the format when it is\n- * created. Must be passed in the constructor.\n+ /** \n+ * Property: slider\n */\n- formatOptions: null,\n+ slider: null,\n \n /** \n- * Property: selectedFeature\n- * {}\n+ * Property: sliderEvents\n+ * {}\n */\n- selectedFeature: null,\n+ sliderEvents: null,\n+\n+ /** \n+ * Property: zoombarDiv\n+ * {DOMElement}\n+ */\n+ zoombarDiv: null,\n+\n+ /** \n+ * APIProperty: zoomWorldIcon\n+ * {Boolean}\n+ */\n+ zoomWorldIcon: false,\n \n /**\n- * Constructor: OpenLayers.Layer.Text\n- * Create a text layer.\n- * \n- * Parameters:\n- * name - {String} \n- * options - {Object} Object with properties to be set on the layer.\n- * Must include property.\n+ * APIProperty: panIcons\n+ * {Boolean} Set this property to false not to display the pan icons. If\n+ * false the zoom world icon is placed under the zoom bar. Defaults to\n+ * true.\n */\n- initialize: function(name, options) {\n- OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);\n- this.features = [];\n- },\n+ panIcons: true,\n \n /**\n- * APIMethod: destroy \n+ * APIProperty: forceFixedZoomLevel\n+ * {Boolean} Force a fixed zoom level even though the map has \n+ * fractionalZoom\n */\n- destroy: function() {\n- // Warning: Layer.Markers.destroy() must be called prior to calling\n- // clearFeatures() here, otherwise we leak memory. Indeed, if\n- // Layer.Markers.destroy() is called after clearFeatures(), it won't be\n- // able to remove the marker image elements from the layer's div since\n- // the markers will have been destroyed by clearFeatures().\n- OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);\n- this.clearFeatures();\n- this.features = null;\n- },\n+ forceFixedZoomLevel: false,\n \n /**\n- * Method: loadText\n- * Start the load of the Text data. Don't do this when we first add the layer,\n- * since we may not be visible at any point, and it would therefore be a waste.\n+ * Property: mouseDragStart\n+ * {}\n */\n- loadText: function() {\n- if (!this.loaded) {\n- if (this.location != null) {\n+ mouseDragStart: null,\n \n- var onFail = function(e) {\n- this.events.triggerEvent(\"loadend\");\n- };\n+ /**\n+ * Property: deltaY\n+ * {Number} The cumulative vertical pixel offset during a zoom bar drag.\n+ */\n+ deltaY: null,\n \n- this.events.triggerEvent(\"loadstart\");\n- OpenLayers.Request.GET({\n- url: this.location,\n- success: this.parseData,\n- failure: onFail,\n- scope: this\n- });\n- this.loaded = true;\n- }\n- }\n+ /**\n+ * Property: zoomStart\n+ * {}\n+ */\n+ zoomStart: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Control.PanZoomBar\n+ */\n+\n+ /**\n+ * APIMethod: destroy\n+ */\n+ destroy: function() {\n+\n+ this._removeZoomBar();\n+\n+ this.map.events.un({\n+ \"changebaselayer\": this.redraw,\n+ \"updatesize\": this.redraw,\n+ scope: this\n+ });\n+\n+ OpenLayers.Control.PanZoom.prototype.destroy.apply(this, arguments);\n+\n+ delete this.mouseDragStart;\n+ delete this.zoomStart;\n },\n \n /**\n- * Method: moveTo\n- * If layer is visible and Text has not been loaded, load Text. \n+ * Method: setMap\n * \n * Parameters:\n- * bounds - {Object} \n- * zoomChanged - {Object} \n- * minor - {Object} \n+ * map - {} \n */\n- moveTo: function(bounds, zoomChanged, minor) {\n- OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);\n- if (this.visibility && !this.loaded) {\n- this.loadText();\n+ setMap: function(map) {\n+ OpenLayers.Control.PanZoom.prototype.setMap.apply(this, arguments);\n+ this.map.events.on({\n+ \"changebaselayer\": this.redraw,\n+ \"updatesize\": this.redraw,\n+ scope: this\n+ });\n+ },\n+\n+ /** \n+ * Method: redraw\n+ * clear the div and start over.\n+ */\n+ redraw: function() {\n+ if (this.div != null) {\n+ this.removeButtons();\n+ this._removeZoomBar();\n }\n+ this.draw();\n },\n \n /**\n- * Method: parseData\n+ * Method: draw \n *\n * Parameters:\n- * ajaxRequest - {} \n+ * px - {} \n */\n- parseData: function(ajaxRequest) {\n- var text = ajaxRequest.responseText;\n-\n- var options = {};\n-\n- OpenLayers.Util.extend(options, this.formatOptions);\n-\n- if (this.map && !this.projection.equals(this.map.getProjectionObject())) {\n- options.externalProjection = this.projection;\n- options.internalProjection = this.map.getProjectionObject();\n- }\n-\n- var parser = new OpenLayers.Format.Text(options);\n- var features = parser.read(text);\n- for (var i = 0, len = features.length; i < len; i++) {\n- var data = {};\n- var feature = features[i];\n- var location;\n- var iconSize, iconOffset;\n+ draw: function(px) {\n+ // initialize our internal div\n+ OpenLayers.Control.prototype.draw.apply(this, arguments);\n+ px = this.position.clone();\n \n- location = new OpenLayers.LonLat(feature.geometry.x,\n- feature.geometry.y);\n+ // place the controls\n+ this.buttons = [];\n \n- if (feature.style.graphicWidth &&\n- feature.style.graphicHeight) {\n- iconSize = new OpenLayers.Size(\n- feature.style.graphicWidth,\n- feature.style.graphicHeight);\n- }\n+ var sz = {\n+ w: 18,\n+ h: 18\n+ };\n+ if (this.panIcons) {\n+ var centered = new OpenLayers.Pixel(px.x + sz.w / 2, px.y);\n+ var wposition = sz.w;\n \n- // FIXME: At the moment, we only use this if we have an \n- // externalGraphic, because icon has no setOffset API Method.\n- /**\n- * FIXME FIRST!!\n- * The Text format does all sorts of parseFloating\n- * The result of a parseFloat for a bogus string is NaN. That\n- * means the three possible values here are undefined, NaN, or a\n- * number. The previous check was an identity check for null. This\n- * means it was failing for all undefined or NaN. A slightly better\n- * check is for undefined. An even better check is to see if the\n- * value is a number (see #1441).\n- */\n- if (feature.style.graphicXOffset !== undefined &&\n- feature.style.graphicYOffset !== undefined) {\n- iconOffset = new OpenLayers.Pixel(\n- feature.style.graphicXOffset,\n- feature.style.graphicYOffset);\n+ if (this.zoomWorldIcon) {\n+ centered = new OpenLayers.Pixel(px.x + sz.w, px.y);\n }\n \n- if (feature.style.externalGraphic != null) {\n- data.icon = new OpenLayers.Icon(feature.style.externalGraphic,\n- iconSize,\n- iconOffset);\n- } else {\n- data.icon = OpenLayers.Marker.defaultIcon();\n-\n- //allows for the case where the image url is not \n- // specified but the size is. use a default icon\n- // but change the size\n- if (iconSize != null) {\n- data.icon.setSize(iconSize);\n- }\n- }\n+ this._addButton(\"panup\", \"north-mini.png\", centered, sz);\n+ px.y = centered.y + sz.h;\n+ this._addButton(\"panleft\", \"west-mini.png\", px, sz);\n+ if (this.zoomWorldIcon) {\n+ this._addButton(\"zoomworld\", \"zoom-world-mini.png\", px.add(sz.w, 0), sz);\n \n- if ((feature.attributes.title != null) &&\n- (feature.attributes.description != null)) {\n- data['popupContentHTML'] =\n- '

' + feature.attributes.title + '

' +\n- '

' + feature.attributes.description + '

';\n+ wposition *= 2;\n }\n-\n- data['overflow'] = feature.attributes.overflow || \"auto\";\n-\n- var markerFeature = new OpenLayers.Feature(this, location, data);\n- this.features.push(markerFeature);\n- var marker = markerFeature.createMarker();\n- if ((feature.attributes.title != null) &&\n- (feature.attributes.description != null)) {\n- marker.events.register('click', markerFeature, this.markerClick);\n+ this._addButton(\"panright\", \"east-mini.png\", px.add(wposition, 0), sz);\n+ this._addButton(\"pandown\", \"south-mini.png\", centered.add(0, sz.h * 2), sz);\n+ this._addButton(\"zoomin\", \"zoom-plus-mini.png\", centered.add(0, sz.h * 3 + 5), sz);\n+ centered = this._addZoomBar(centered.add(0, sz.h * 4 + 5));\n+ this._addButton(\"zoomout\", \"zoom-minus-mini.png\", centered, sz);\n+ } else {\n+ this._addButton(\"zoomin\", \"zoom-plus-mini.png\", px, sz);\n+ centered = this._addZoomBar(px.add(0, sz.h));\n+ this._addButton(\"zoomout\", \"zoom-minus-mini.png\", centered, sz);\n+ if (this.zoomWorldIcon) {\n+ centered = centered.add(0, sz.h + 3);\n+ this._addButton(\"zoomworld\", \"zoom-world-mini.png\", centered, sz);\n }\n- this.addMarker(marker);\n }\n- this.events.triggerEvent(\"loadend\");\n+ return this.div;\n },\n \n- /**\n- * Property: markerClick\n+ /** \n+ * Method: _addZoomBar\n * \n * Parameters:\n- * evt - {Event} \n- *\n- * Context:\n- * - {}\n+ * centered - {} where zoombar drawing is to start.\n */\n- markerClick: function(evt) {\n- var sameMarkerClicked = (this == this.layer.selectedFeature);\n- this.layer.selectedFeature = (!sameMarkerClicked) ? this : null;\n- for (var i = 0, len = this.layer.map.popups.length; i < len; i++) {\n- this.layer.map.removePopup(this.layer.map.popups[i]);\n- }\n- if (!sameMarkerClicked) {\n- this.layer.map.addPopup(this.createPopup());\n- }\n- OpenLayers.Event.stop(evt);\n- },\n+ _addZoomBar: function(centered) {\n+ var imgLocation = OpenLayers.Util.getImageLocation(\"slider.png\");\n+ var id = this.id + \"_\" + this.map.id;\n+ var minZoom = this.map.getMinZoom();\n+ var zoomsToEnd = this.map.getNumZoomLevels() - 1 - this.map.getZoom();\n+ var slider = OpenLayers.Util.createAlphaImageDiv(id,\n+ centered.add(-1, zoomsToEnd * this.zoomStopHeight), {\n+ w: 20,\n+ h: 9\n+ },\n+ imgLocation,\n+ \"absolute\");\n+ slider.style.cursor = \"move\";\n+ this.slider = slider;\n \n- /**\n- * Method: clearFeatures\n- */\n- clearFeatures: function() {\n- if (this.features != null) {\n- while (this.features.length > 0) {\n- var feature = this.features[0];\n- OpenLayers.Util.removeItem(this.features, feature);\n- feature.destroy();\n- }\n+ this.sliderEvents = new OpenLayers.Events(this, slider, null, true, {\n+ includeXY: true\n+ });\n+ this.sliderEvents.on({\n+ \"touchstart\": this.zoomBarDown,\n+ \"touchmove\": this.zoomBarDrag,\n+ \"touchend\": this.zoomBarUp,\n+ \"mousedown\": this.zoomBarDown,\n+ \"mousemove\": this.zoomBarDrag,\n+ \"mouseup\": this.zoomBarUp\n+ });\n+\n+ var sz = {\n+ w: this.zoomStopWidth,\n+ h: this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom)\n+ };\n+ var imgLocation = OpenLayers.Util.getImageLocation(\"zoombar.png\");\n+ var div = null;\n+\n+ if (OpenLayers.Util.alphaHack()) {\n+ var id = this.id + \"_\" + this.map.id;\n+ div = OpenLayers.Util.createAlphaImageDiv(id, centered, {\n+ w: sz.w,\n+ h: this.zoomStopHeight\n+ },\n+ imgLocation,\n+ \"absolute\", null, \"crop\");\n+ div.style.height = sz.h + \"px\";\n+ } else {\n+ div = OpenLayers.Util.createDiv(\n+ 'OpenLayers_Control_PanZoomBar_Zoombar' + this.map.id,\n+ centered,\n+ sz,\n+ imgLocation);\n }\n- },\n+ div.style.cursor = \"pointer\";\n+ div.className = \"olButton\";\n+ this.zoombarDiv = div;\n \n- CLASS_NAME: \"OpenLayers.Layer.Text\"\n-});\n-/* ======================================================================\n- OpenLayers/Layer/WMTS.js\n- ====================================================================== */\n+ this.div.appendChild(div);\n \n-/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for\n- * full list of contributors). Published under the 2-clause BSD license.\n- * See license.txt in the OpenLayers distribution or repository for the\n- * full text of the license. */\n+ this.startTop = parseInt(div.style.top);\n+ this.div.appendChild(slider);\n \n-/**\n- * @requires OpenLayers/Layer/Grid.js\n- */\n+ this.map.events.register(\"zoomend\", this, this.moveZoomBar);\n \n-/**\n- * Class: OpenLayers.Layer.WMTS\n- * Instances of the WMTS class allow viewing of tiles from a service that \n- * implements the OGC WMTS specification version 1.0.0.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n-\n- /**\n- * APIProperty: isBaseLayer\n- * {Boolean} The layer will be considered a base layer. Default is true.\n- */\n- isBaseLayer: true,\n-\n- /**\n- * Property: version\n- * {String} WMTS version. Default is \"1.0.0\".\n- */\n- version: \"1.0.0\",\n-\n- /**\n- * APIProperty: requestEncoding\n- * {String} Request encoding. Can be \"REST\" or \"KVP\". Default is \"KVP\".\n- */\n- requestEncoding: \"KVP\",\n-\n- /**\n- * APIProperty: url\n- * {String|Array(String)} The base URL or request URL template for the WMTS\n- * service. Must be provided. Array is only supported for base URLs, not\n- * for request URL templates. URL templates are only supported for\n- * REST .\n- */\n- url: null,\n-\n- /**\n- * APIProperty: layer\n- * {String} The layer identifier advertised by the WMTS service. Must be \n- * provided.\n- */\n- layer: null,\n-\n- /** \n- * APIProperty: matrixSet\n- * {String} One of the advertised matrix set identifiers. Must be provided.\n- */\n- matrixSet: null,\n-\n- /** \n- * APIProperty: style\n- * {String} One of the advertised layer styles. Must be provided.\n- */\n- style: null,\n-\n- /** \n- * APIProperty: format\n- * {String} The image MIME type. Default is \"image/jpeg\".\n- */\n- format: \"image/jpeg\",\n-\n- /**\n- * APIProperty: tileOrigin\n- * {} The top-left corner of the tile matrix in map \n- * units. If the tile origin for each matrix in a set is different,\n- * the should include a topLeftCorner property. If\n- * not provided, the tile origin will default to the top left corner\n- * of the layer .\n- */\n- tileOrigin: null,\n-\n- /**\n- * APIProperty: tileFullExtent\n- * {} The full extent of the tile set. If not supplied,\n- * the layer's property will be used.\n- */\n- tileFullExtent: null,\n-\n- /**\n- * APIProperty: formatSuffix\n- * {String} For REST request encoding, an image format suffix must be \n- * included in the request. If not provided, the suffix will be derived\n- * from the property.\n- */\n- formatSuffix: null,\n-\n- /**\n- * APIProperty: matrixIds\n- * {Array} A list of tile matrix identifiers. If not provided, the matrix\n- * identifiers will be assumed to be integers corresponding to the \n- * map zoom level. If a list of strings is provided, each item should\n- * be the matrix identifier that corresponds to the map zoom level.\n- * Additionally, a list of objects can be provided. Each object should\n- * describe the matrix as presented in the WMTS capabilities. These\n- * objects should have the propertes shown below.\n- * \n- * Matrix properties:\n- * identifier - {String} The matrix identifier (required).\n- * scaleDenominator - {Number} The matrix scale denominator.\n- * topLeftCorner - {} The top left corner of the \n- * matrix. Must be provided if different than the layer .\n- * tileWidth - {Number} The tile width for the matrix. Must be provided \n- * if different than the width given in the layer .\n- * tileHeight - {Number} The tile height for the matrix. Must be provided \n- * if different than the height given in the layer .\n- */\n- matrixIds: null,\n-\n- /**\n- * APIProperty: dimensions\n- * {Array} For RESTful request encoding, extra dimensions may be specified.\n- * Items in this list should be property names in the object.\n- * Values of extra dimensions will be determined from the corresponding\n- * values in the object.\n- */\n- dimensions: null,\n-\n- /**\n- * APIProperty: params\n- * {Object} Extra parameters to include in tile requests. For KVP \n- * , these properties will be encoded in the request \n- * query string. For REST , these properties will\n- * become part of the request path, with order determined by the \n- * list.\n- */\n- params: null,\n+ centered = centered.add(0,\n+ this.zoomStopHeight * (this.map.getNumZoomLevels() - minZoom));\n+ return centered;\n+ },\n \n /**\n- * APIProperty: zoomOffset\n- * {Number} If your cache has more levels than you want to provide\n- * access to with this layer, supply a zoomOffset. This zoom offset\n- * is added to the current map zoom level to determine the level\n- * for a requested tile. For example, if you supply a zoomOffset\n- * of 3, when the map is at the zoom 0, tiles will be requested from\n- * level 3 of your cache. Default is 0 (assumes cache level and map\n- * zoom are equivalent). Additionally, if this layer is to be used\n- * as an overlay and the cache has fewer zoom levels than the base\n- * layer, you can supply a negative zoomOffset. For example, if a\n- * map zoom level of 1 corresponds to your cache level zero, you would\n- * supply a -1 zoomOffset (and set the maxResolution of the layer\n- * appropriately). The zoomOffset value has no effect if complete\n- * matrix definitions (including scaleDenominator) are supplied in\n- * the property. Defaults to 0 (no zoom offset).\n+ * Method: _removeZoomBar\n */\n- zoomOffset: 0,\n+ _removeZoomBar: function() {\n+ this.sliderEvents.un({\n+ \"touchstart\": this.zoomBarDown,\n+ \"touchmove\": this.zoomBarDrag,\n+ \"touchend\": this.zoomBarUp,\n+ \"mousedown\": this.zoomBarDown,\n+ \"mousemove\": this.zoomBarDrag,\n+ \"mouseup\": this.zoomBarUp\n+ });\n+ this.sliderEvents.destroy();\n \n- /**\n- * APIProperty: serverResolutions\n- * {Array} A list of all resolutions available on the server. Only set this\n- * property if the map resolutions differ from the server. This\n- * property serves two purposes. (a) can include\n- * resolutions that the server supports and that you don't want to\n- * provide with this layer; you can also look at , which is\n- * an alternative to for that specific purpose.\n- * (b) The map can work with resolutions that aren't supported by\n- * the server, i.e. that aren't in . When the\n- * map is displayed in such a resolution data for the closest\n- * server-supported resolution is loaded and the layer div is\n- * stretched as necessary.\n- */\n- serverResolutions: null,\n+ this.div.removeChild(this.zoombarDiv);\n+ this.zoombarDiv = null;\n+ this.div.removeChild(this.slider);\n+ this.slider = null;\n \n- /**\n- * Property: formatSuffixMap\n- * {Object} a map between WMTS 'format' request parameter and tile image file suffix\n- */\n- formatSuffixMap: {\n- \"image/png\": \"png\",\n- \"image/png8\": \"png\",\n- \"image/png24\": \"png\",\n- \"image/png32\": \"png\",\n- \"png\": \"png\",\n- \"image/jpeg\": \"jpg\",\n- \"image/jpg\": \"jpg\",\n- \"jpeg\": \"jpg\",\n- \"jpg\": \"jpg\"\n+ this.map.events.unregister(\"zoomend\", this, this.moveZoomBar);\n },\n \n /**\n- * Property: matrix\n- * {Object} Matrix definition for the current map resolution. Updated by\n- * the method.\n- */\n- matrix: null,\n-\n- /**\n- * Constructor: OpenLayers.Layer.WMTS\n- * Create a new WMTS layer.\n- *\n- * Example:\n- * (code)\n- * var wmts = new OpenLayers.Layer.WMTS({\n- * name: \"My WMTS Layer\",\n- * url: \"http://example.com/wmts\", \n- * layer: \"layer_id\",\n- * style: \"default\",\n- * matrixSet: \"matrix_id\"\n- * });\n- * (end)\n+ * Method: onButtonClick\n *\n * Parameters:\n- * config - {Object} Configuration properties for the layer.\n- *\n- * Required configuration properties:\n- * url - {String} The base url for the service. See the property.\n- * layer - {String} The layer identifier. See the property.\n- * style - {String} The layer style identifier. See the