{"diffoscope-json-version": 1, "source1": "/srv/reproducible-results/rbuild-debian/r-b-build.bLgHiLH6/b1/openlayers_2.13.1+ds2-10_armhf.changes", "source2": "/srv/reproducible-results/rbuild-debian/r-b-build.bLgHiLH6/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- 9f01c9c96ae38156af9859f3be439e64 719880 javascript optional libjs-openlayers_2.13.1+ds2-10_all.deb\n+ f3dc48632174b06cb5ba5666912fad85 720948 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 716008 2023-01-14 13:27:41.000000 data.tar.xz\n+-rw-r--r-- 0 0 0 3684 2023-01-14 13:27:41.000000 control.tar.xz\n+-rw-r--r-- 0 0 0 717072 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": "@@ -5083,323 +5083,2109 @@\n return this._hasString(this.options.corners, \"all\", \"bottom\", \"bl\", \"br\");\n },\n _hasSingleTextChild: function(el) {\n return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3;\n }\n };\n /* ======================================================================\n- OpenLayers/Symbolizer.js\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.Symbolizer\n- * Base class representing a symbolizer used for feature rendering.\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.Symbolizer = OpenLayers.Class({\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: 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+ * 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- zIndex: 0,\n+ eventListeners: null,\n \n /**\n- * Constructor: OpenLayers.Symbolizer\n- * Instances of this class are not useful. See one of the subclasses.\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- * config - {Object} An object containing properties to be set on the \n- * symbolizer. Any documented symbolizer property can be set at \n- * construction.\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- * A new symbolizer.\n+ * {Boolean} Whether or not the tile should actually be drawn. Returns null\n+ * if a beforedraw listener returned false.\n */\n- initialize: function(config) {\n- OpenLayers.Util.extend(this, config);\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- * APIMethod: clone\n- * Create a copy of this symbolizer.\n+ * Method: moveTo\n+ * Reposition the tile.\n *\n- * Returns a symbolizer of the same type with the same properties.\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/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- var Type = eval(this.CLASS_NAME);\n- return new Type(OpenLayers.Util.extend({}, this));\n+ return new OpenLayers.Feature.Vector(\n+ this.geometry ? this.geometry.clone() : null,\n+ this.attributes,\n+ this.style);\n },\n \n- CLASS_NAME: \"OpenLayers.Symbolizer\"\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/Strategy.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/Util.js\n+ * @requires OpenLayers/Feature/Vector.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+ * Class: OpenLayers.Style\n+ * This class represents a UserStyle obtained\n+ * from a SLD, containing styling rules.\n */\n-OpenLayers.Strategy = OpenLayers.Class({\n+OpenLayers.Style = OpenLayers.Class({\n \n /**\n- * Property: layer\n- * {} The layer this strategy belongs to.\n+ * Property: id\n+ * {String} A unique id for this session.\n */\n- layer: null,\n+ id: null,\n \n /**\n- * Property: options\n- * {Object} Any options sent to the constructor.\n+ * APIProperty: name\n+ * {String}\n */\n- options: null,\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: active \n- * {Boolean} The control is active.\n+ * Property: rules \n+ * {Array()}\n */\n- active: null,\n+ rules: 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+ * 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- autoActivate: true,\n+ context: null,\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+ * 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- autoDestroy: true,\n+ defaultStyle: null,\n \n /**\n- * Constructor: OpenLayers.Strategy\n- * Abstract class for vector strategies. Create instances of a subclass.\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- * options - {Object} Optional object whose properties will be set on the\n- * instance.\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(options) {\n+ initialize: function(style, options) {\n+\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+ 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+ /** \n * APIMethod: destroy\n- * Clean up the strategy.\n+ * nullify references to prevent circular references and memory leaks\n */\n destroy: function() {\n- this.deactivate();\n- this.layer = null;\n- this.options = null;\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: setLayer\n- * Called to set the property.\n- *\n+ * Method: createSymbolizer\n+ * creates a style by applying all feature-dependent rules to the base\n+ * style.\n+ * \n * Parameters:\n- * layer - {}\n+ * feature - {} feature to evaluate rules for\n+ * \n+ * Returns:\n+ * {Object} symbolizer hash\n */\n- setLayer: function(layer) {\n- this.layer = layer;\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: activate\n- * Activate the strategy. Register any listeners, do appropriate setup.\n+ * Method: applySymbolizer\n+ *\n+ * Parameters:\n+ * rule - {}\n+ * style - {Object}\n+ * feature - {}\n *\n * Returns:\n- * {Boolean} True if the strategy was successfully activated or false if\n- * the strategy was already active.\n+ * {Object} A style with new symbolizer applied.\n */\n- activate: function() {\n- if (!this.active) {\n- this.active = true;\n- return true;\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- return false;\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: deactivate\n- * Deactivate the strategy. Unregister any listeners, do appropriate\n- * tear-down.\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- * {Boolean} True if the strategy was successfully deactivated or false if\n- * the strategy was already inactive.\n+ * {Object} the modified style\n */\n- deactivate: function() {\n- if (this.active) {\n- this.active = false;\n- return true;\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 false;\n+ return style;\n },\n \n- CLASS_NAME: \"OpenLayers.Strategy\"\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/Format.js\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 * full text of the license. */\n \n+\n /**\n * @requires OpenLayers/BaseTypes/Class.js\n * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Style.js\n */\n \n /**\n- * Class: OpenLayers.Format\n- * Base class for format reading/writing a variety of formats. Subclasses\n- * of OpenLayers.Format are expected to have read and write methods.\n+ * Class: OpenLayers.Rule\n+ * This class represents an SLD Rule, as being used for rule-based SLD styling.\n */\n-OpenLayers.Format = OpenLayers.Class({\n+OpenLayers.Rule = OpenLayers.Class({\n \n /**\n- * Property: options\n- * {Object} A reference to options passed to the constructor.\n+ * Property: id\n+ * {String} A unique id for this session.\n */\n- options: null,\n+ id: null,\n \n /**\n- * APIProperty: externalProjection\n- * {} When passed a externalProjection and\n- * internalProjection, the format will reproject the geometries it\n- * reads or writes. The externalProjection is the projection used by\n- * the content which is passed into read or which comes out of write.\n- * In order to reproject, a projection transformation function for the\n- * specified projections must be available. This support may be \n- * provided via proj4js or via a custom transformation function. See\n- * {} for more information on\n- * custom transformations.\n+ * APIProperty: name\n+ * {String} name of this rule\n */\n- externalProjection: null,\n+ name: null,\n \n /**\n- * APIProperty: internalProjection\n- * {} When passed a externalProjection and\n- * internalProjection, the format will reproject the geometries it\n- * reads or writes. The internalProjection is the projection used by\n- * the geometries which are returned by read or which are passed into\n- * write. In order to reproject, a projection transformation function\n- * for the specified projections must be available. This support may be\n- * provided via proj4js or via a custom transformation function. See\n- * {} for more information on\n- * custom transformations.\n+ * Property: title\n+ * {String} Title of this rule (set if included in SLD)\n */\n- internalProjection: null,\n+ title: null,\n \n /**\n- * APIProperty: data\n- * {Object} When is true, this is the parsed string sent to\n- * .\n+ * Property: description\n+ * {String} Description of this rule (set if abstract is included in SLD)\n */\n- data: null,\n+ description: null,\n \n /**\n- * APIProperty: keepData\n- * {Object} Maintain a reference () to the most recently read data.\n- * Default is false.\n+ * Property: context\n+ * {Object} An optional object with properties that the rule should be\n+ * evaluated against. If no context is specified, feature.attributes will\n+ * be used.\n */\n- keepData: false,\n+ context: null,\n \n /**\n- * Constructor: OpenLayers.Format\n- * Instances of this class are not useful. See one of the subclasses.\n+ * Property: filter\n+ * {} Optional filter for the rule.\n+ */\n+ filter: null,\n+\n+ /**\n+ * Property: elseFilter\n+ * {Boolean} Determines whether this rule is only to be applied only if\n+ * no other rules match (ElseFilter according to the SLD specification). \n+ * Default is false. For instances of OpenLayers.Rule, if elseFilter is\n+ * false, the rule will always apply. For subclasses, the else property is \n+ * ignored.\n+ */\n+ elseFilter: false,\n+\n+ /**\n+ * Property: symbolizer\n+ * {Object} Symbolizer or hash of symbolizers for this rule. If hash of\n+ * symbolizers, keys are one or more of [\"Point\", \"Line\", \"Polygon\"]. The\n+ * latter if useful if it is required to style e.g. vertices of a line\n+ * with a point symbolizer. Note, however, that this is not implemented\n+ * yet in OpenLayers, but it is the way how symbolizers are defined in\n+ * SLD.\n+ */\n+ symbolizer: null,\n+\n+ /**\n+ * Property: symbolizers\n+ * {Array} Collection of symbolizers associated with this rule. If \n+ * provided at construction, the symbolizers array has precedence\n+ * over the deprecated symbolizer property. Note that multiple \n+ * symbolizers are not currently supported by the vector renderers.\n+ * Rules with multiple symbolizers are currently only useful for\n+ * maintaining elements in an SLD document.\n+ */\n+ symbolizers: null,\n+\n+ /**\n+ * APIProperty: minScaleDenominator\n+ * {Number} or {String} minimum scale at which to draw the feature.\n+ * In the case of a String, this can be a combination of text and\n+ * propertyNames in the form \"literal ${propertyName}\"\n+ */\n+ minScaleDenominator: null,\n+\n+ /**\n+ * APIProperty: maxScaleDenominator\n+ * {Number} or {String} maximum scale at which to draw the feature.\n+ * In the case of a String, this can be a combination of text and\n+ * propertyNames in the form \"literal ${propertyName}\"\n+ */\n+ maxScaleDenominator: null,\n+\n+ /** \n+ * Constructor: OpenLayers.Rule\n+ * Creates a Rule.\n *\n * Parameters:\n * options - {Object} An optional object with properties to set on the\n- * format\n- *\n- * Valid options:\n- * keepData - {Boolean} If true, upon , the data property will be\n- * set to the parsed object (e.g. the json or xml object).\n- *\n+ * rule\n+ * \n * Returns:\n- * An instance of OpenLayers.Format\n+ * {}\n+ */\n+ initialize: function(options) {\n+ this.symbolizer = {};\n+ OpenLayers.Util.extend(this, options);\n+ if (this.symbolizers) {\n+ delete this.symbolizer;\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 in this.symbolizer) {\n+ this.symbolizer[i] = null;\n+ }\n+ this.symbolizer = null;\n+ delete this.symbolizers;\n+ },\n+\n+ /**\n+ * APIMethod: evaluate\n+ * evaluates this rule for a specific feature\n+ * \n+ * Parameters:\n+ * feature - {} feature to apply the rule to.\n+ * \n+ * Returns:\n+ * {Boolean} true if the rule applies, false if it does not.\n+ * This rule is the default rule and always returns true.\n+ */\n+ evaluate: function(feature) {\n+ var context = this.getContext(feature);\n+ var applies = true;\n+\n+ if (this.minScaleDenominator || this.maxScaleDenominator) {\n+ var scale = feature.layer.map.getScale();\n+ }\n+\n+ // check if within minScale/maxScale bounds\n+ if (this.minScaleDenominator) {\n+ applies = scale >= OpenLayers.Style.createLiteral(\n+ this.minScaleDenominator, context);\n+ }\n+ if (applies && this.maxScaleDenominator) {\n+ applies = scale < OpenLayers.Style.createLiteral(\n+ this.maxScaleDenominator, context);\n+ }\n+\n+ // check if optional filter applies\n+ if (applies && this.filter) {\n+ // feature id filters get the feature, others get the context\n+ if (this.filter.CLASS_NAME == \"OpenLayers.Filter.FeatureId\") {\n+ applies = this.filter.evaluate(feature);\n+ } else {\n+ applies = this.filter.evaluate(context);\n+ }\n+ }\n+\n+ return applies;\n+ },\n+\n+ /**\n+ * Method: getContext\n+ * Gets the context for evaluating this rule\n+ * \n+ * Paramters:\n+ * feature - {} feature to take the context from if\n+ * none is specified.\n+ */\n+ getContext: function(feature) {\n+ var context = this.context;\n+ if (!context) {\n+ context = feature.attributes || feature.data;\n+ }\n+ if (typeof this.context == \"function\") {\n+ context = this.context(feature);\n+ }\n+ return context;\n+ },\n+\n+ /**\n+ * APIMethod: clone\n+ * Clones this rule.\n+ * \n+ * Returns:\n+ * {} Clone of this rule.\n+ */\n+ clone: function() {\n+ var options = OpenLayers.Util.extend({}, this);\n+ if (this.symbolizers) {\n+ // clone symbolizers\n+ var len = this.symbolizers.length;\n+ options.symbolizers = new Array(len);\n+ for (var i = 0; i < len; ++i) {\n+ options.symbolizers[i] = this.symbolizers[i].clone();\n+ }\n+ } else {\n+ // clone symbolizer\n+ options.symbolizer = {};\n+ var value, type;\n+ for (var key in this.symbolizer) {\n+ value = this.symbolizer[key];\n+ type = typeof value;\n+ if (type === \"object\") {\n+ options.symbolizer[key] = OpenLayers.Util.extend({}, value);\n+ } else if (type === \"string\") {\n+ options.symbolizer[key] = value;\n+ }\n+ }\n+ }\n+ // clone filter\n+ options.filter = this.filter && this.filter.clone();\n+ // clone context\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/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+ * Property: defaultFilter\n+ * {} Optional default filter to read requests\n+ */\n+ defaultFilter: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Protocol\n+ * Abstract class for vector protocols. 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+ options = options || {};\n OpenLayers.Util.extend(this, options);\n this.options = options;\n },\n \n /**\n+ * Method: mergeWithDefaultFilter\n+ * Merge filter passed to the read method with the default one\n+ *\n+ * Parameters:\n+ * filter - {}\n+ */\n+ mergeWithDefaultFilter: function(filter) {\n+ var merged;\n+ if (filter && this.defaultFilter) {\n+ merged = new OpenLayers.Filter.Logical({\n+ type: OpenLayers.Filter.Logical.AND,\n+ filters: [this.defaultFilter, filter]\n+ });\n+ } else {\n+ merged = filter || this.defaultFilter || undefined;\n+ }\n+ return merged;\n+ },\n+\n+ /**\n * APIMethod: destroy\n- * Clean up.\n+ * Clean up the protocol.\n */\n- destroy: function() {},\n+ destroy: function() {\n+ this.options = null;\n+ this.format = null;\n+ },\n \n /**\n- * Method: read\n- * Read data from a string, and return an object whose type depends on the\n- * subclass. \n- * \n+ * APIMethod: read\n+ * Construct a request for reading new features.\n+ *\n * Parameters:\n- * data - {string} Data to read/parse.\n+ * options - {Object} Optional object for configuring the request.\n *\n * Returns:\n- * Depends on the subclass\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n */\n- read: function(data) {\n- throw new Error('Read not implemented.');\n+ read: function(options) {\n+ options = options || {};\n+ options.filter = this.mergeWithDefaultFilter(options.filter);\n },\n \n+\n /**\n- * Method: write\n- * Accept an object, and return a string. \n+ * APIMethod: create\n+ * Construct a request for writing newly created features.\n *\n * Parameters:\n- * object - {Object} Object to be serialized\n+ * features - {Array({})} or\n+ * {}\n+ * options - {Object} Optional object for configuring the request.\n *\n * Returns:\n- * {String} A string representation of the object.\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n */\n- write: function(object) {\n- throw new Error('Write not implemented.');\n+ create: function() {},\n+\n+ /**\n+ * APIMethod: update\n+ * Construct a request updating modified features.\n+ *\n+ * Parameters:\n+ * features - {Array({})} or\n+ * {}\n+ * options - {Object} Optional object for configuring the request.\n+ *\n+ * Returns:\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n+ */\n+ update: function() {},\n+\n+ /**\n+ * APIMethod: delete\n+ * Construct a request deleting a removed feature.\n+ *\n+ * Parameters:\n+ * feature - {}\n+ * options - {Object} Optional object for configuring the request.\n+ *\n+ * Returns:\n+ * {} An \n+ * object, the same object will be passed to the callback function passed\n+ * if one exists in the options object.\n+ */\n+ \"delete\": function() {},\n+\n+ /**\n+ * APIMethod: commit\n+ * Go over the features and for each take action\n+ * based on the feature state. Possible actions are create,\n+ * update and delete.\n+ *\n+ * Parameters:\n+ * features - {Array({})}\n+ * options - {Object} Object whose possible keys are \"create\", \"update\",\n+ * \"delete\", \"callback\" and \"scope\", the values referenced by the\n+ * first three are objects as passed to the \"create\", \"update\", and\n+ * \"delete\" methods, the value referenced by the \"callback\" key is\n+ * a function which is called when the commit operation is complete\n+ * using the scope referenced by the \"scope\" key.\n+ *\n+ * Returns:\n+ * {Array({})} An array of\n+ * objects.\n+ */\n+ commit: function() {},\n+\n+ /**\n+ * Method: abort\n+ * Abort an ongoing request.\n+ *\n+ * Parameters:\n+ * response - {}\n+ */\n+ abort: function(response) {},\n+\n+ /**\n+ * Method: createCallback\n+ * Returns a function that applies the given public method with resp and\n+ * options arguments.\n+ *\n+ * Parameters:\n+ * method - {Function} The method to be applied by the callback.\n+ * response - {} The protocol response object.\n+ * options - {Object} Options sent to the protocol method\n+ */\n+ createCallback: function(method, response, options) {\n+ return OpenLayers.Function.bind(function() {\n+ method.apply(this, [response, options]);\n+ }, this);\n },\n \n- CLASS_NAME: \"OpenLayers.Format\"\n+ CLASS_NAME: \"OpenLayers.Protocol\"\n+});\n+\n+/**\n+ * Class: OpenLayers.Protocol.Response\n+ * Protocols return Response objects to their users.\n+ */\n+OpenLayers.Protocol.Response = OpenLayers.Class({\n+ /**\n+ * Property: code\n+ * {Number} - OpenLayers.Protocol.Response.SUCCESS or\n+ * OpenLayers.Protocol.Response.FAILURE\n+ */\n+ code: null,\n+\n+ /**\n+ * Property: requestType\n+ * {String} The type of request this response corresponds to. Either\n+ * \"create\", \"read\", \"update\" or \"delete\".\n+ */\n+ requestType: null,\n+\n+ /**\n+ * Property: last\n+ * {Boolean} - true if this is the last response expected in a commit,\n+ * false otherwise, defaults to true.\n+ */\n+ last: true,\n+\n+ /**\n+ * Property: features\n+ * {Array({})} or {}\n+ * The features returned in the response by the server. Depending on the \n+ * protocol's read payload, either features or data will be populated.\n+ */\n+ features: null,\n+\n+ /**\n+ * Property: data\n+ * {Object}\n+ * The data returned in the response by the server. Depending on the \n+ * protocol's read payload, either features or data will be populated.\n+ */\n+ data: null,\n+\n+ /**\n+ * Property: reqFeatures\n+ * {Array({})} or {}\n+ * The features provided by the user and placed in the request by the\n+ * protocol.\n+ */\n+ reqFeatures: null,\n+\n+ /**\n+ * Property: priv\n+ */\n+ priv: null,\n+\n+ /**\n+ * Property: error\n+ * {Object} The error object in case a service exception was encountered.\n+ */\n+ error: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Protocol.Response\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+ },\n+\n+ /**\n+ * Method: success\n+ *\n+ * Returns:\n+ * {Boolean} - true on success, false otherwise\n+ */\n+ success: function() {\n+ return this.code > 0;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Protocol.Response\"\n });\n+\n+OpenLayers.Protocol.Response.SUCCESS = 1;\n+OpenLayers.Protocol.Response.FAILURE = 0;\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@@ -5640,1274 +7426,378 @@\n requestFrame: requestFrame,\n start: start,\n stop: stop\n };\n \n })(window);\n /* ======================================================================\n- OpenLayers/Kinetic.js\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-OpenLayers.Kinetic = OpenLayers.Class({\n+/**\n+ * Namespace: OpenLayers.Tween\n+ */\n+OpenLayers.Tween = OpenLayers.Class({\n \n /**\n- * Property: threshold\n- * In most cases changing the threshold isn't needed.\n- * In px/ms, default to 0.\n+ * APIProperty: easing\n+ * {(Function)} Easing equation used for the animation\n+ * Defaultly set to OpenLayers.Easing.Expo.easeOut\n */\n- threshold: 0,\n+ easing: null,\n \n /**\n- * Property: deceleration\n- * {Float} the deseleration in px/ms\u00b2, default to 0.0035.\n+ * APIProperty: begin\n+ * {Object} Values to start the animation with\n */\n- deceleration: 0.0035,\n+ begin: null,\n \n /**\n- * Property: nbPoints\n- * {Integer} the number of points we use to calculate the kinetic\n- * initial values.\n+ * APIProperty: finish\n+ * {Object} Values to finish the animation with\n */\n- nbPoints: 100,\n+ finish: null,\n \n /**\n- * Property: delay\n- * {Float} time to consider to calculate the kinetic initial values.\n- * In ms, default to 200.\n+ * APIProperty: duration\n+ * {int} duration of the tween (number of steps)\n */\n- delay: 200,\n+ duration: null,\n \n /**\n- * Property: points\n- * List of points use to calculate the kinetic initial values.\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- points: undefined,\n+ callbacks: null,\n \n /**\n- * Property: timerId\n- * ID of the timer.\n+ * Property: time\n+ * {int} Step counter\n */\n- timerId: undefined,\n+ time: null,\n \n /**\n- * Constructor: OpenLayers.Kinetic\n- *\n- * Parameters:\n- * options - {Object}\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- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- },\n+ minFrameRate: null,\n \n /**\n- * Method: begin\n- * Begins the dragging.\n+ * Property: startTime\n+ * {Number} The timestamp of the first execution step. Used for skipping\n+ * frames\n */\n- begin: function() {\n- OpenLayers.Animation.stop(this.timerId);\n- this.timerId = undefined;\n- this.points = [];\n- },\n+ startTime: null,\n \n /**\n- * Method: update\n- * Updates during the dragging.\n- *\n- * Parameters:\n- * xy - {} The new position.\n+ * Property: animationId\n+ * {int} Loop id returned by OpenLayers.Animation.start\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- },\n+ animationId: null,\n \n /**\n- * Method: end\n- * Ends the dragging, start the kinetic.\n- *\n- * Parameters:\n- * xy - {} The last position.\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+ * Property: playing\n+ * {Boolean} Tells if the easing is currently playing\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- }\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- }\n- return {\n- speed: speed,\n- theta: theta\n- };\n- },\n+ playing: false,\n \n- /**\n- * Method: move\n- * Launch the kinetic move pan.\n+ /** \n+ * Constructor: OpenLayers.Tween\n+ * Creates a Tween.\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+ * easing - {(Function)} easing function method to use\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-\n- var lastX = 0;\n- var lastY = 0;\n-\n- var timerCallback = function() {\n- if (this.timerId == null) {\n- return;\n- }\n-\n- var t = new Date().getTime() - initialTime;\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- var args = {};\n- args.end = false;\n- var v = -this.deceleration * t + v0;\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- this.timerId = OpenLayers.Animation.start(\n- OpenLayers.Function.bind(timerCallback, this)\n- );\n+ initialize: function(easing) {\n+ this.easing = (easing) ? easing : OpenLayers.Easing.Expo.easeOut;\n },\n \n- CLASS_NAME: \"OpenLayers.Kinetic\"\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+ * APIMethod: start\n+ * Plays the Tween, and calls the callback method on each step\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+ * 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- 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+ 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- * 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+ * APIMethod: stop\n+ * Stops the Tween, and calls the done callback\n+ * Doesn't do anything if animation is already finished\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+ stop: function() {\n+ if (!this.playing) {\n+ return;\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+ if (this.callbacks && this.callbacks.done) {\n+ this.callbacks.done.call(this, this.finish);\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+ OpenLayers.Animation.stop(this.animationId);\n+ this.animationId = null;\n+ this.playing = false;\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+ * Method: play\n+ * Calls the appropriate easing method\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+ 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-\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+ var c = f - b;\n+ value[i] = this.easing.apply(this, [this.time, b, c, this.duration]);\n }\n+ this.time++;\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+ 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 \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+ if (this.time > this.duration) {\n+ this.stop();\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+ * Create empty functions for all easing methods.\n */\n- toggle: function() {\n- if (this.visible()) {\n- this.hide();\n- } else {\n- this.show();\n- }\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- * Method: show\n- * Makes the popup visible.\n+ * Create empty functions for all easing methods.\n */\n- show: function() {\n- this.div.style.display = '';\n-\n- if (this.panMapIfOutOfView) {\n- this.panIntoView();\n- }\n- },\n+ CLASS_NAME: \"OpenLayers.Easing\"\n+};\n \n- /**\n- * Method: hide\n- * Makes the popup invisible.\n- */\n- hide: function() {\n- this.div.style.display = 'none';\n- },\n+/**\n+ * Namespace: OpenLayers.Easing.Linear\n+ */\n+OpenLayers.Easing.Linear = {\n \n /**\n- * Method: setSize\n- * Used to adjust the size of the popup. \n- *\n+ * Function: easeIn\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+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n *\n- * Parameters:\n- * color - {String} the background color. eg \"#FFBBBB\"\n+ * Returns:\n+ * {Float}\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+ easeIn: function(t, b, c, d) {\n+ return c * t / d + b;\n },\n \n /**\n- * Method: setOpacity\n- * Sets the opacity of the popup.\n+ * Function: easeOut\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+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n *\n- * Parameters:\n- * border - {String} The border style value. eg 2px \n+ * Returns:\n+ * {Float}\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+ easeOut: function(t, b, c, d) {\n+ return c * t / d + b;\n },\n \n /**\n- * Method: setContentHTML\n- * Allows the user to set the HTML content of the popup.\n- *\n+ * Function: easeInOut\n+ * \n * Parameters:\n- * contentHTML - {String} HTML for the div.\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- 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+ easeInOut: function(t, b, c, d) {\n+ return c * t / d + b;\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+ CLASS_NAME: \"OpenLayers.Easing.Linear\"\n+};\n \n- OpenLayers.Event.observe(img, 'load', img._onImgLoad);\n- }\n- }\n- },\n+/**\n+ * Namespace: OpenLayers.Easing.Expo\n+ */\n+OpenLayers.Easing.Expo = {\n \n /**\n- * APIMethod: getSafeContentSize\n+ * Function: easeIn\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+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\n *\n * Returns:\n- * {}\n+ * {Float}\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+ easeIn: function(t, b, c, d) {\n+ return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;\n },\n \n /**\n- * Method: addCloseBox\n+ * Function: easeOut\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+ * t - {Float} time\n+ * b - {Float} beginning position\n+ * c - {Float} total change\n+ * d - {Float} duration of the transition\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+ * Returns:\n+ * {Float}\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+ 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- * 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+ * Function: easeInOut\n * \n * Parameters:\n- * evt - {Event} \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- onmousedown: function(evt) {\n- this.mousedown = true;\n- OpenLayers.Event.stop(evt, true);\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- /** \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+ CLASS_NAME: \"OpenLayers.Easing.Expo\"\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+ * Namespace: OpenLayers.Easing.Quad\n+ */\n+OpenLayers.Easing.Quad = {\n \n /**\n- * Method: onclick\n- * Ignore clicks, but allowing default browser handling\n+ * Function: easeIn\n * \n * Parameters:\n- * evt - {Event} \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- onclick: function(evt) {\n- OpenLayers.Event.stop(evt, true);\n+ easeIn: function(t, b, c, d) {\n+ return c * (t /= d) * t + b;\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+ * Function: easeOut\n * \n * Parameters:\n- * evt - {Event} \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- onmouseout: function(evt) {\n- this.mousedown = false;\n+ easeOut: function(t, b, c, d) {\n+ return -c * (t /= d) * (t - 2) + b;\n },\n \n- /** \n- * Method: ondblclick\n- * Ignore double-clicks, but allowing default browser handling\n+ /**\n+ * Function: easeInOut\n * \n * Parameters:\n- * evt - {Event} \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- ondblclick: function(evt) {\n- OpenLayers.Event.stop(evt, true);\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.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+ CLASS_NAME: \"OpenLayers.Easing.Quad\"\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@@ -8077,10159 +8967,2356 @@\n \n OpenLayers.Event.observe(element, 'MSPointerUp', cb);\n },\n \n CLASS_NAME: \"OpenLayers.Events\"\n });\n /* ======================================================================\n- OpenLayers/Tween.js\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 * 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+ * Class: OpenLayers.Geometry\n+ * A Geometry is a description of a geographic object. Create an instance of\n+ * this class with the constructor. This is a base class,\n+ * typical geometry types are described by subclasses of this class.\n+ *\n+ * Note that if you use the method, you must\n+ * explicitly include the OpenLayers.Format.WKT in your build.\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+OpenLayers.Geometry = OpenLayers.Class({\n \n /**\n- * Property: time\n- * {int} Step counter\n+ * Property: id\n+ * {String} A unique identifier for this geometry.\n */\n- time: null,\n+ id: 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+ * Property: parent\n+ * {}This is set when a Geometry is added as component\n+ * of another geometry\n */\n- minFrameRate: null,\n+ parent: null,\n \n /**\n- * Property: startTime\n- * {Number} The timestamp of the first execution step. Used for skipping\n- * frames\n+ * Property: bounds \n+ * {} The bounds of this geometry\n */\n- startTime: null,\n+ bounds: null,\n \n /**\n- * Property: animationId\n- * {int} Loop id returned by OpenLayers.Animation.start\n+ * Constructor: OpenLayers.Geometry\n+ * Creates a geometry object. \n */\n- animationId: null,\n+ initialize: function() {\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n+ },\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+ * Method: destroy\n+ * Destroy this geometry.\n */\n- initialize: function(easing) {\n- this.easing = (easing) ? easing : OpenLayers.Easing.Expo.easeOut;\n+ destroy: function() {\n+ this.id = null;\n+ this.bounds = null;\n },\n \n /**\n- * APIMethod: start\n- * Plays the Tween, and calls the callback method on each step\n+ * APIMethod: clone\n+ * Create a clone of this geometry. Does not set any non-standard\n+ * properties of the cloned geometry.\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+ * Returns:\n+ * {} An exact clone of this geometry.\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+ clone: function() {\n+ return new OpenLayers.Geometry();\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: setBounds\n+ * Set the bounds for this Geometry.\n+ * \n+ * Parameters:\n+ * bounds - {} \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+ setBounds: function(bounds) {\n+ if (bounds) {\n+ this.bounds = bounds.clone();\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+ * Method: clearBounds\n+ * Nullify this components bounds and that of its parent as well.\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+ clearBounds: function() {\n+ this.bounds = null;\n+ if (this.parent) {\n+ this.parent.clearBounds();\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+ * Method: extendBounds\n+ * Extend the existing bounds to include the new bounds. \n+ * If geometry's bounds is not yet set, then set a new Bounds.\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+ * newBounds - {} \n */\n- easeIn: function(t, b, c, d) {\n- return c * t / d + b;\n+ extendBounds: function(newBounds) {\n+ var bounds = this.getBounds();\n+ if (!bounds) {\n+ this.setBounds(newBounds);\n+ } else {\n+ this.bounds.extend(newBounds);\n+ }\n },\n \n /**\n- * Function: easeOut\n+ * APIMethod: getBounds\n+ * Get the bounds for this Geometry. If bounds is not set, it \n+ * is calculated again, this makes queries faster.\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 */\n- easeOut: function(t, b, c, d) {\n- return c * t / d + b;\n+ getBounds: function() {\n+ if (this.bounds == null) {\n+ this.calculateBounds();\n+ }\n+ return this.bounds;\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+ * APIMethod: calculateBounds\n+ * Recalculate the bounds for the geometry. \n */\n- easeInOut: function(t, b, c, d) {\n- return c * t / d + b;\n+ calculateBounds: function() {\n+ //\n+ // This should be overridden by subclasses.\n+ //\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+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\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+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\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+ * Valid options depend on the specific geometry type.\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+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\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+ distanceTo: function(geometry, options) {},\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+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\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+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n *\n * Returns:\n- * {Float}\n+ * {Array} A list of all vertices in the geometry.\n */\n- easeOut: function(t, b, c, d) {\n- return -c * (t /= d) * (t - 2) + b;\n- },\n+ getVertices: function(nodes) {},\n \n /**\n- * Function: easeInOut\n+ * Method: atPoint\n+ * Note - This is only an approximation based on the bounds of the \n+ * geometry.\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+ * 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- * {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-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Namespace: OpenLayers.Projection\n- * Methods for coordinate transforms between coordinate systems. By default,\n- * OpenLayers ships with the ability to transform coordinates between\n- * geographic (EPSG:4326) and web or spherical mercator (EPSG:900913 et al.)\n- * coordinate reference systems. See the method for details\n- * on usage.\n- *\n- * Additional transforms may be added by using the \n- * library. If the proj4js library is included, the method \n- * will work between any two coordinate reference systems with proj4js \n- * definitions.\n- *\n- * If the proj4js library is not included, or if you wish to allow transforms\n- * between arbitrary coordinate reference systems, use the \n- * method to register a custom transform method.\n- */\n-OpenLayers.Projection = OpenLayers.Class({\n-\n- /**\n- * Property: proj\n- * {Object} Proj4js.Proj instance.\n+ * {Boolean} Whether or not the geometry is at the specified location\n */\n- proj: null,\n+ atPoint: function(lonlat, toleranceLon, toleranceLat) {\n+ var atPoint = false;\n+ var bounds = this.getBounds();\n+ if ((bounds != null) && (lonlat != null)) {\n \n- /**\n- * Property: projCode\n- * {String}\n- */\n- projCode: null,\n+ var dX = (toleranceLon != null) ? toleranceLon : 0;\n+ var dY = (toleranceLat != null) ? toleranceLat : 0;\n \n- /**\n- * Property: titleRegEx\n- * {RegExp} regular expression to strip the title from a proj4js definition\n- */\n- titleRegEx: /\\+title=[^\\+]*/,\n+ var toleranceBounds =\n+ new OpenLayers.Bounds(this.bounds.left - dX,\n+ this.bounds.bottom - dY,\n+ this.bounds.right + dX,\n+ this.bounds.top + dY);\n \n- /**\n- * Constructor: OpenLayers.Projection\n- * This class offers several methods for interacting with a wrapped \n- * pro4js projection object. \n- *\n- * Parameters:\n- * projCode - {String} A string identifying the Well Known Identifier for\n- * the projection.\n- * options - {Object} An optional object to set additional properties\n- * on the projection.\n- *\n- * Returns:\n- * {} A projection object.\n- */\n- initialize: function(projCode, options) {\n- OpenLayers.Util.extend(this, options);\n- this.projCode = projCode;\n- if (typeof Proj4js == \"object\") {\n- this.proj = new Proj4js.Proj(projCode);\n+ atPoint = toleranceBounds.containsLonLat(lonlat);\n }\n+ return atPoint;\n },\n \n /**\n- * APIMethod: getCode\n- * Get the string SRS code.\n- *\n+ * Method: getLength\n+ * Calculate the length of this geometry. This method is defined in\n+ * subclasses.\n+ * \n * Returns:\n- * {String} The SRS code.\n+ * {Float} The length of the collection by summing its parts\n */\n- getCode: function() {\n- return this.proj ? this.proj.srsCode : this.projCode;\n+ getLength: function() {\n+ //to be overridden by geometries that actually have a length\n+ //\n+ return 0.0;\n },\n \n /**\n- * APIMethod: getUnits\n- * Get the units string for the projection -- returns null if \n- * proj4js is not available.\n- *\n+ * Method: getArea\n+ * Calculate the area of this geometry. This method is defined in subclasses.\n+ * \n * Returns:\n- * {String} The units abbreviation.\n+ * {Float} The area of the collection by summing its parts\n */\n- getUnits: function() {\n- return this.proj ? this.proj.units : null;\n+ getArea: function() {\n+ //to be overridden by geometries that actually have an area\n+ //\n+ return 0.0;\n },\n \n /**\n- * Method: toString\n- * Convert projection to string (getCode wrapper).\n+ * APIMethod: getCentroid\n+ * Calculate the centroid of this geometry. This method is defined in subclasses.\n *\n * Returns:\n- * {String} The projection code.\n+ * {} The centroid of the collection\n */\n- toString: function() {\n- return this.getCode();\n+ getCentroid: function() {\n+ return null;\n },\n \n /**\n- * Method: equals\n- * Test equality of two projection instances. Determines equality based\n- * soley on the projection code.\n+ * Method: toString\n+ * Returns a text representation of the geometry. If the WKT format is\n+ * included in a build, this will be the Well-Known Text \n+ * representation.\n *\n * Returns:\n- * {Boolean} The two projections are equivalent.\n+ * {String} String representation of this geometry.\n */\n- equals: function(projection) {\n- var p = projection,\n- equals = false;\n- if (p) {\n- if (!(p instanceof OpenLayers.Projection)) {\n- p = new OpenLayers.Projection(p);\n- }\n- if ((typeof Proj4js == \"object\") && this.proj.defData && p.proj.defData) {\n- equals = this.proj.defData.replace(this.titleRegEx, \"\") ==\n- p.proj.defData.replace(this.titleRegEx, \"\");\n- } else if (p.getCode) {\n- var source = this.getCode(),\n- target = p.getCode();\n- equals = source == target ||\n- !!OpenLayers.Projection.transforms[source] &&\n- OpenLayers.Projection.transforms[source][target] ===\n- OpenLayers.Projection.nullTransform;\n- }\n+ toString: function() {\n+ var string;\n+ if (OpenLayers.Format && OpenLayers.Format.WKT) {\n+ string = OpenLayers.Format.WKT.prototype.write(\n+ new OpenLayers.Feature.Vector(this)\n+ );\n+ } else {\n+ string = Object.prototype.toString.call(this);\n }\n- return equals;\n- },\n-\n- /* Method: destroy\n- * Destroy projection object.\n- */\n- destroy: function() {\n- delete this.proj;\n- delete this.projCode;\n+ return string;\n },\n \n- CLASS_NAME: \"OpenLayers.Projection\"\n+ CLASS_NAME: \"OpenLayers.Geometry\"\n });\n \n /**\n- * Property: transforms\n- * {Object} Transforms is an object, with from properties, each of which may\n- * have a to property. This allows you to define projections without \n- * requiring support for proj4js to be included.\n+ * Function: OpenLayers.Geometry.fromWKT\n+ * Generate a geometry given a Well-Known Text string. For this method to\n+ * work, you must include the OpenLayers.Format.WKT in your build \n+ * explicitly.\n *\n- * This object has keys which correspond to a 'source' projection object. The\n- * keys should be strings, corresponding to the projection.getCode() value.\n- * Each source projection object should have a set of destination projection\n- * keys included in the object. \n- * \n- * Each value in the destination object should be a transformation function,\n- * where the function is expected to be passed an object with a .x and a .y\n- * property. The function should return the object, with the .x and .y\n- * transformed according to the transformation function.\n+ * Parameters:\n+ * wkt - {String} A string representing the geometry in Well-Known Text.\n *\n- * Note - Properties on this object should not be set directly. To add a\n- * transform method to this object, use the method. For an\n- * example of usage, see the OpenLayers.Layer.SphericalMercator file.\n- */\n-OpenLayers.Projection.transforms = {};\n-\n-/**\n- * APIProperty: defaults\n- * {Object} Defaults for the SRS codes known to OpenLayers (currently\n- * EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,\n- * EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,\n- * maxExtent (the validity extent for the SRS) and yx (true if this SRS is\n- * known to have a reverse axis order).\n+ * Returns:\n+ * {} A geometry of the appropriate class.\n */\n-OpenLayers.Projection.defaults = {\n- \"EPSG:4326\": {\n- units: \"degrees\",\n- maxExtent: [-180, -90, 180, 90],\n- yx: true\n- },\n- \"CRS:84\": {\n- units: \"degrees\",\n- maxExtent: [-180, -90, 180, 90]\n- },\n- \"EPSG:900913\": {\n- units: \"m\",\n- maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]\n+OpenLayers.Geometry.fromWKT = function(wkt) {\n+ var geom;\n+ if (OpenLayers.Format && OpenLayers.Format.WKT) {\n+ var format = OpenLayers.Geometry.fromWKT.format;\n+ if (!format) {\n+ format = new OpenLayers.Format.WKT();\n+ OpenLayers.Geometry.fromWKT.format = format;\n+ }\n+ var result = format.read(wkt);\n+ if (result instanceof OpenLayers.Feature.Vector) {\n+ geom = result.geometry;\n+ } else if (OpenLayers.Util.isArray(result)) {\n+ var len = result.length;\n+ var components = new Array(len);\n+ for (var i = 0; i < len; ++i) {\n+ components[i] = result[i].geometry;\n+ }\n+ geom = new OpenLayers.Geometry.Collection(components);\n+ }\n }\n+ return geom;\n };\n \n /**\n- * APIMethod: addTransform\n- * Set a custom transform method between two projections. Use this method in\n- * cases where the proj4js lib is not available or where custom projections\n- * need to be handled.\n+ * Method: OpenLayers.Geometry.segmentsIntersect\n+ * Determine whether two line segments intersect. Optionally calculates\n+ * and returns the intersection point. This function is optimized for\n+ * cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those\n+ * obvious cases where there is no intersection, the function should\n+ * not be called.\n *\n * Parameters:\n- * from - {String} The code for the source projection\n- * to - {String} the code for the destination projection\n- * method - {Function} A function that takes a point as an argument and\n- * transforms that point from the source to the destination projection\n- * in place. The original point should be modified.\n- */\n-OpenLayers.Projection.addTransform = function(from, to, method) {\n- if (method === OpenLayers.Projection.nullTransform) {\n- var defaults = OpenLayers.Projection.defaults[from];\n- if (defaults && !OpenLayers.Projection.defaults[to]) {\n- OpenLayers.Projection.defaults[to] = defaults;\n- }\n- }\n- if (!OpenLayers.Projection.transforms[from]) {\n- OpenLayers.Projection.transforms[from] = {};\n- }\n- OpenLayers.Projection.transforms[from][to] = method;\n-};\n-\n-/**\n- * APIMethod: transform\n- * Transform a point coordinate from one projection to another. Note that\n- * the input point is transformed in place.\n- * \n- * Parameters:\n- * point - { | Object} An object with x and y\n- * properties representing coordinates in those dimensions.\n- * source - {OpenLayers.Projection} Source map coordinate system\n- * dest - {OpenLayers.Projection} Destination map coordinate system\n+ * seg1 - {Object} Object representing a segment with properties x1, y1, x2,\n+ * and y2. The start point is represented by x1 and y1. The end point\n+ * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n+ * seg2 - {Object} Object representing a segment with properties x1, y1, x2,\n+ * and y2. The start point is represented by x1 and y1. The end point\n+ * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n+ * options - {Object} Optional properties for calculating the intersection.\n+ *\n+ * Valid options:\n+ * point - {Boolean} Return the intersection point. If false, the actual\n+ * intersection point will not be calculated. If true and the segments\n+ * intersect, the intersection point will be returned. If true and\n+ * the segments do not intersect, false will be returned. If true and\n+ * the segments are coincident, true will be returned.\n+ * tolerance - {Number} If a non-null value is provided, if the segments are\n+ * within the tolerance distance, this will be considered an intersection.\n+ * In addition, if the point option is true and the calculated intersection\n+ * is within the tolerance distance of an end point, the endpoint will be\n+ * returned instead of the calculated intersection. Further, if the\n+ * intersection is within the tolerance of endpoints on both segments, or\n+ * if two segment endpoints are within the tolerance distance of eachother\n+ * (but no intersection is otherwise calculated), an endpoint on the\n+ * first segment provided will be returned.\n *\n * Returns:\n- * point - {object} A transformed coordinate. The original point is modified.\n+ * {Boolean | } The two segments intersect.\n+ * If the point argument is true, the return will be the intersection\n+ * point or false if none exists. If point is true and the segments\n+ * are coincident, return will be true (and the instersection is equal\n+ * to the shorter segment).\n */\n-OpenLayers.Projection.transform = function(point, source, dest) {\n- if (source && dest) {\n- if (!(source instanceof OpenLayers.Projection)) {\n- source = new OpenLayers.Projection(source);\n+OpenLayers.Geometry.segmentsIntersect = function(seg1, seg2, options) {\n+ var point = options && options.point;\n+ var tolerance = options && options.tolerance;\n+ var intersection = false;\n+ var x11_21 = seg1.x1 - seg2.x1;\n+ var y11_21 = seg1.y1 - seg2.y1;\n+ var x12_11 = seg1.x2 - seg1.x1;\n+ var y12_11 = seg1.y2 - seg1.y1;\n+ var y22_21 = seg2.y2 - seg2.y1;\n+ var x22_21 = seg2.x2 - seg2.x1;\n+ var d = (y22_21 * x12_11) - (x22_21 * y12_11);\n+ var n1 = (x22_21 * y11_21) - (y22_21 * x11_21);\n+ var n2 = (x12_11 * y11_21) - (y12_11 * x11_21);\n+ if (d == 0) {\n+ // parallel\n+ if (n1 == 0 && n2 == 0) {\n+ // coincident\n+ intersection = true;\n }\n- if (!(dest instanceof OpenLayers.Projection)) {\n- dest = new OpenLayers.Projection(dest);\n+ } else {\n+ var along1 = n1 / d;\n+ var along2 = n2 / d;\n+ if (along1 >= 0 && along1 <= 1 && along2 >= 0 && along2 <= 1) {\n+ // intersect\n+ if (!point) {\n+ intersection = true;\n+ } else {\n+ // calculate the intersection point\n+ var x = seg1.x1 + (along1 * x12_11);\n+ var y = seg1.y1 + (along1 * y12_11);\n+ intersection = new OpenLayers.Geometry.Point(x, y);\n+ }\n }\n- if (source.proj && dest.proj) {\n- point = Proj4js.transform(source.proj, dest.proj, point);\n+ }\n+ if (tolerance) {\n+ var dist;\n+ if (intersection) {\n+ if (point) {\n+ var segs = [seg1, seg2];\n+ var seg, x, y;\n+ // check segment endpoints for proximity to intersection\n+ // set intersection to first endpoint within the tolerance\n+ outer: for (var i = 0; i < 2; ++i) {\n+ seg = segs[i];\n+ for (var j = 1; j < 3; ++j) {\n+ x = seg[\"x\" + j];\n+ y = seg[\"y\" + j];\n+ dist = Math.sqrt(\n+ Math.pow(x - intersection.x, 2) +\n+ Math.pow(y - intersection.y, 2)\n+ );\n+ if (dist < tolerance) {\n+ intersection.x = x;\n+ intersection.y = y;\n+ break outer;\n+ }\n+ }\n+ }\n+\n+ }\n } else {\n- var sourceCode = source.getCode();\n- var destCode = dest.getCode();\n- var transforms = OpenLayers.Projection.transforms;\n- if (transforms[sourceCode] && transforms[sourceCode][destCode]) {\n- transforms[sourceCode][destCode](point);\n+ // no calculated intersection, but segments could be within\n+ // the tolerance of one another\n+ var segs = [seg1, seg2];\n+ var source, target, x, y, p, result;\n+ // check segment endpoints for proximity to intersection\n+ // set intersection to first endpoint within the tolerance\n+ outer: for (var i = 0; i < 2; ++i) {\n+ source = segs[i];\n+ target = segs[(i + 1) % 2];\n+ for (var j = 1; j < 3; ++j) {\n+ p = {\n+ x: source[\"x\" + j],\n+ y: source[\"y\" + j]\n+ };\n+ result = OpenLayers.Geometry.distanceToSegment(p, target);\n+ if (result.distance < tolerance) {\n+ if (point) {\n+ intersection = new OpenLayers.Geometry.Point(p.x, p.y);\n+ } else {\n+ intersection = true;\n+ }\n+ break outer;\n+ }\n+ }\n }\n }\n }\n- return point;\n+ return intersection;\n };\n \n /**\n- * APIFunction: nullTransform\n- * A null transformation - useful for defining projection aliases when\n- * proj4js is not available:\n+ * Function: OpenLayers.Geometry.distanceToSegment\n *\n- * (code)\n- * OpenLayers.Projection.addTransform(\"EPSG:3857\", \"EPSG:900913\",\n- * OpenLayers.Projection.nullTransform);\n- * OpenLayers.Projection.addTransform(\"EPSG:900913\", \"EPSG:3857\",\n- * OpenLayers.Projection.nullTransform);\n- * (end)\n+ * Parameters:\n+ * point - {Object} An object with x and y properties representing the\n+ * point coordinates.\n+ * segment - {Object} An object with x1, y1, x2, and y2 properties\n+ * representing endpoint coordinates.\n+ *\n+ * Returns:\n+ * {Object} An object with distance, along, x, and y properties. The distance\n+ * will be the shortest distance between the input point and segment.\n+ * The x and y properties represent the coordinates along the segment\n+ * where the shortest distance meets the segment. The along attribute\n+ * describes how far between the two segment points the given point is.\n */\n-OpenLayers.Projection.nullTransform = function(point) {\n- return point;\n+OpenLayers.Geometry.distanceToSegment = function(point, segment) {\n+ var result = OpenLayers.Geometry.distanceSquaredToSegment(point, segment);\n+ result.distance = Math.sqrt(result.distance);\n+ return result;\n };\n \n /**\n- * Note: Transforms for web mercator <-> geographic\n- * OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.\n- * OpenLayers originally started referring to EPSG:900913 as web mercator.\n- * The EPSG has declared EPSG:3857 to be web mercator.\n- * ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as\n- * equivalent. See http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/11/20/ArcGIS-Online-moving-to-Google-_2F00_-Bing-tiling-scheme_3A00_-What-does-this-mean-for-you_3F00_.aspx#12084.\n- * For geographic, OpenLayers recognizes EPSG:4326, CRS:84 and\n- * urn:ogc:def:crs:EPSG:6.6:4326. OpenLayers also knows about the reverse axis\n- * order for EPSG:4326. \n+ * Function: OpenLayers.Geometry.distanceSquaredToSegment\n+ *\n+ * Usually the distanceToSegment function should be used. This variant however\n+ * can be used for comparisons where the exact distance is not important.\n+ *\n+ * Parameters:\n+ * point - {Object} An object with x and y properties representing the\n+ * point coordinates.\n+ * segment - {Object} An object with x1, y1, x2, and y2 properties\n+ * representing endpoint coordinates.\n+ *\n+ * Returns:\n+ * {Object} An object with squared distance, along, x, and y properties.\n+ * The distance will be the shortest distance between the input point and\n+ * segment. The x and y properties represent the coordinates along the\n+ * segment where the shortest distance meets the segment. The along\n+ * attribute describes how far between the two segment points the given\n+ * point is.\n */\n-(function() {\n-\n- var pole = 20037508.34;\n-\n- function inverseMercator(xy) {\n- xy.x = 180 * xy.x / pole;\n- xy.y = 180 / Math.PI * (2 * Math.atan(Math.exp((xy.y / pole) * Math.PI)) - Math.PI / 2);\n- return xy;\n- }\n-\n- function forwardMercator(xy) {\n- xy.x = xy.x * pole / 180;\n- var y = Math.log(Math.tan((90 + xy.y) * Math.PI / 360)) / Math.PI * pole;\n- xy.y = Math.max(-20037508.34, Math.min(y, 20037508.34));\n- return xy;\n- }\n-\n- function map(base, codes) {\n- var add = OpenLayers.Projection.addTransform;\n- var same = OpenLayers.Projection.nullTransform;\n- var i, len, code, other, j;\n- for (i = 0, len = codes.length; i < len; ++i) {\n- code = codes[i];\n- add(base, code, forwardMercator);\n- add(code, base, inverseMercator);\n- for (j = i + 1; j < len; ++j) {\n- other = codes[j];\n- add(code, other, same);\n- add(other, code, same);\n- }\n- }\n- }\n-\n- // list of equivalent codes for web mercator\n- var mercator = [\"EPSG:900913\", \"EPSG:3857\", \"EPSG:102113\", \"EPSG:102100\"],\n- geographic = [\"CRS:84\", \"urn:ogc:def:crs:EPSG:6.6:4326\", \"EPSG:4326\"],\n- i;\n- for (i = mercator.length - 1; i >= 0; --i) {\n- map(mercator[i], geographic);\n- }\n- for (i = geographic.length - 1; i >= 0; --i) {\n- map(geographic[i], mercator);\n+OpenLayers.Geometry.distanceSquaredToSegment = function(point, segment) {\n+ var x0 = point.x;\n+ var y0 = point.y;\n+ var x1 = segment.x1;\n+ var y1 = segment.y1;\n+ var x2 = segment.x2;\n+ var y2 = segment.y2;\n+ var dx = x2 - x1;\n+ var dy = y2 - y1;\n+ var along = ((dx * (x0 - x1)) + (dy * (y0 - y1))) /\n+ (Math.pow(dx, 2) + Math.pow(dy, 2));\n+ var x, y;\n+ if (along <= 0.0) {\n+ x = x1;\n+ y = y1;\n+ } else if (along >= 1.0) {\n+ x = x2;\n+ y = y2;\n+ } else {\n+ x = x1 + along * dx;\n+ y = y1 + along * dy;\n }\n-\n-})();\n+ return {\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/Map.js\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 \n /**\n * @requires OpenLayers/BaseTypes/Class.js\n * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Util/vendorPrefix.js\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Tween.js\n- * @requires OpenLayers/Projection.js\n */\n \n /**\n- * Class: OpenLayers.Map\n- * Instances of OpenLayers.Map are interactive maps embedded in a web page.\n- * Create a new map with the constructor.\n- * \n- * On their own maps do not provide much functionality. To extend a map\n- * it's necessary to add controls () and \n- * layers () to the map. \n+ * Class: OpenLayers.Format\n+ * Base class for format reading/writing a variety of formats. Subclasses\n+ * of OpenLayers.Format are expected to have read and write methods.\n */\n-OpenLayers.Map = OpenLayers.Class({\n+OpenLayers.Format = OpenLayers.Class({\n \n /**\n- * Constant: Z_INDEX_BASE\n- * {Object} Base z-indexes for different classes of thing \n+ * Property: options\n+ * {Object} A reference to options passed to the constructor.\n */\n- Z_INDEX_BASE: {\n- BaseLayer: 100,\n- Overlay: 325,\n- Feature: 725,\n- Popup: 750,\n- Control: 1000\n- },\n+ options: null,\n \n /**\n- * APIProperty: events\n- * {}\n- *\n- * Register a listener for a particular event with the following syntax:\n- * (code)\n- * map.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 map.events.object.\n- * element - {DOMElement} A reference to map.events.element.\n- *\n- * Browser events have the following additional properties:\n- * xy - {} The pixel location of the event (relative\n- * to the the map viewport).\n- *\n- * Supported map event types:\n- * preaddlayer - triggered before a layer has been added. The event\n- * object will include a *layer* property that references the layer \n- * to be added. When a listener returns \"false\" the adding will be \n- * aborted.\n- * addlayer - triggered after a layer has been added. The event object\n- * will include a *layer* property that references the added layer.\n- * preremovelayer - triggered before a layer has been removed. The event\n- * object will include a *layer* property that references the layer \n- * to be removed. When a listener returns \"false\" the removal will be \n- * aborted.\n- * removelayer - triggered after a layer has been removed. The event\n- * object will include a *layer* property that references the removed\n- * layer.\n- * changelayer - triggered after a layer name change, order change,\n- * opacity change, params change, visibility change (actual visibility,\n- * not the layer's visibility property) or attribution change (due to\n- * extent change). Listeners will receive an event object with *layer*\n- * and *property* properties. The *layer* property will be a reference\n- * to the changed layer. The *property* property will be a key to the\n- * changed property (name, order, opacity, params, visibility or\n- * attribution).\n- * movestart - triggered after the start of a drag, pan, or zoom. The event\n- * object may include a *zoomChanged* property that tells whether the\n- * zoom has changed.\n- * move - triggered after each drag, pan, or zoom\n- * moveend - triggered after a drag, pan, or zoom completes\n- * zoomend - triggered after a zoom completes\n- * mouseover - triggered after mouseover the map\n- * mouseout - triggered after mouseout the map\n- * mousemove - triggered after mousemove the map\n- * changebaselayer - triggered after the base layer changes\n- * updatesize - triggered after the method was executed\n+ * APIProperty: externalProjection\n+ * {} When passed a externalProjection and\n+ * internalProjection, the format will reproject the geometries it\n+ * reads or writes. The externalProjection is the projection used by\n+ * the content which is passed into read or which comes out of write.\n+ * In order to reproject, a projection transformation function for the\n+ * specified projections must be available. This support may be \n+ * provided via proj4js or via a custom transformation function. See\n+ * {} for more information on\n+ * custom transformations.\n */\n+ externalProjection: null,\n \n /**\n- * Property: id\n- * {String} Unique identifier for the map\n+ * APIProperty: internalProjection\n+ * {} When passed a externalProjection and\n+ * internalProjection, the format will reproject the geometries it\n+ * reads or writes. The internalProjection is the projection used by\n+ * the geometries which are returned by read or which are passed into\n+ * write. In order to reproject, a projection transformation function\n+ * for the specified projections must be available. This support may be\n+ * provided via proj4js or via a custom transformation function. See\n+ * {} for more information on\n+ * custom transformations.\n */\n- id: null,\n+ internalProjection: null,\n \n /**\n- * Property: fractionalZoom\n- * {Boolean} For a base layer that supports it, allow the map resolution\n- * to be set to a value between one of the values in the resolutions\n- * array. Default is false.\n- *\n- * When fractionalZoom is set to true, it is possible to zoom to\n- * an arbitrary extent. This requires a base layer from a source\n- * that supports requests for arbitrary extents (i.e. not cached\n- * tiles on a regular lattice). This means that fractionalZoom\n- * will not work with commercial layers (Google, Yahoo, VE), layers\n- * using TileCache, or any other pre-cached data sources.\n- *\n- * If you are using fractionalZoom, then you should also use\n- * instead of layer.resolutions[zoom] as the\n- * former works for non-integer zoom levels.\n+ * APIProperty: data\n+ * {Object} When is true, this is the parsed string sent to\n+ * .\n */\n- fractionalZoom: false,\n+ data: null,\n \n /**\n- * APIProperty: events\n- * {} An events object that handles all \n- * events on the map\n+ * APIProperty: keepData\n+ * {Object} Maintain a reference () to the most recently read data.\n+ * Default is false.\n */\n- events: null,\n+ keepData: false,\n \n /**\n- * APIProperty: allOverlays\n- * {Boolean} Allow the map to function with \"overlays\" only. Defaults to\n- * false. If true, the lowest layer in the draw order will act as\n- * the base layer. In addition, if set to true, all layers will\n- * have isBaseLayer set to false when they are added to the map.\n+ * Constructor: OpenLayers.Format\n+ * Instances of this class are not useful. See one of the subclasses.\n *\n- * Note:\n- * If you set map.allOverlays to true, then you *cannot* use\n- * map.setBaseLayer or layer.setIsBaseLayer. With allOverlays true,\n- * the lowest layer in the draw layer is the base layer. So, to change\n- * the base layer, use or to set the layer\n- * index to 0.\n- */\n- allOverlays: false,\n-\n- /**\n- * APIProperty: div\n- * {DOMElement|String} The element that contains the map (or an id for\n- * that element). If the constructor is called\n- * with two arguments, this should be provided as the first argument.\n- * Alternatively, the map constructor can be called with the options\n- * object as the only argument. In this case (one argument), a\n- * div property may or may not be provided. If the div property\n- * is not provided, the map can be rendered to a container later\n- * using the method.\n- * \n- * Note:\n- * If you are calling after map construction, do not use\n- * auto. Instead, divide your by your\n- * maximum expected dimension.\n- */\n- div: null,\n-\n- /**\n- * Property: dragging\n- * {Boolean} The map is currently being dragged.\n- */\n- dragging: false,\n-\n- /**\n- * Property: size\n- * {} Size of the main div (this.div)\n- */\n- size: null,\n-\n- /**\n- * Property: viewPortDiv\n- * {HTMLDivElement} The element that represents the map viewport\n- */\n- viewPortDiv: null,\n-\n- /**\n- * Property: layerContainerOrigin\n- * {} The lonlat at which the later container was\n- * re-initialized (on-zoom)\n- */\n- layerContainerOrigin: null,\n-\n- /**\n- * Property: layerContainerDiv\n- * {HTMLDivElement} The element that contains the layers.\n- */\n- layerContainerDiv: null,\n-\n- /**\n- * APIProperty: layers\n- * {Array()} Ordered list of layers in the map\n- */\n- layers: null,\n-\n- /**\n- * APIProperty: controls\n- * {Array()} List of controls associated with the map.\n+ * Parameters:\n+ * options - {Object} An optional object with properties to set on the\n+ * format\n *\n- * If not provided in the map options at construction, the map will\n- * by default be given the following controls if present in the build:\n- * - or \n- * - or \n- * - \n- * - \n- */\n- controls: null,\n-\n- /**\n- * Property: popups\n- * {Array()} List of popups associated with the map\n- */\n- popups: null,\n-\n- /**\n- * APIProperty: baseLayer\n- * {} The currently selected base layer. This determines\n- * min/max zoom level, projection, etc.\n- */\n- baseLayer: null,\n-\n- /**\n- * Property: center\n- * {} The current center of the map\n- */\n- center: null,\n-\n- /**\n- * Property: resolution\n- * {Float} The resolution of the map.\n- */\n- resolution: null,\n-\n- /**\n- * Property: zoom\n- * {Integer} The current zoom level of the map\n- */\n- zoom: 0,\n-\n- /**\n- * Property: panRatio\n- * {Float} The ratio of the current extent within\n- * which panning will tween.\n- */\n- panRatio: 1.5,\n-\n- /**\n- * APIProperty: options\n- * {Object} The options object passed to the class constructor. Read-only.\n- */\n- options: null,\n-\n- // Options\n-\n- /**\n- * APIProperty: tileSize\n- * {} Set in the map options to override the default tile\n- * size for this map.\n- */\n- tileSize: null,\n-\n- /**\n- * APIProperty: projection\n- * {String} Set in the map options to specify the default projection \n- * for layers added to this map. When using a projection other than EPSG:4326\n- * (CRS:84, Geographic) or EPSG:3857 (EPSG:900913, Web Mercator),\n- * also set maxExtent, maxResolution or resolutions. Default is \"EPSG:4326\".\n- * Note that the projection of the map is usually determined\n- * by that of the current baseLayer (see and ).\n- */\n- projection: \"EPSG:4326\",\n-\n- /**\n- * APIProperty: units\n- * {String} The map units. Possible values are 'degrees' (or 'dd'), 'm', \n- * 'ft', 'km', 'mi', 'inches'. 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: resolutions\n- * {Array(Float)} A list of map resolutions (map units per pixel) in \n- * descending order. If this is not set in the layer constructor, it \n- * will be set based on other resolution related properties \n- * (maxExtent, maxResolution, maxScale, etc.).\n- */\n- resolutions: null,\n-\n- /**\n- * APIProperty: maxResolution\n- * {Float} Required if you are not displaying the whole world on a tile\n- * with the size specified in .\n- */\n- maxResolution: null,\n-\n- /**\n- * APIProperty: minResolution\n- * {Float}\n+ * Valid options:\n+ * keepData - {Boolean} If true, upon , the data property will be\n+ * set to the parsed object (e.g. the json or xml object).\n+ *\n+ * Returns:\n+ * An instance of OpenLayers.Format\n */\n- minResolution: null,\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.options = options;\n+ },\n \n /**\n- * APIProperty: maxScale\n- * {Float}\n+ * APIMethod: destroy\n+ * Clean up.\n */\n- maxScale: null,\n+ destroy: function() {},\n \n /**\n- * APIProperty: minScale\n- * {Float}\n+ * Method: read\n+ * Read data from a string, and return an object whose type depends on the\n+ * subclass. \n+ * \n+ * Parameters:\n+ * data - {string} Data to read/parse.\n+ *\n+ * Returns:\n+ * Depends on the subclass\n */\n- minScale: null,\n+ read: function(data) {\n+ throw new Error('Read not implemented.');\n+ },\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 map.\n- * Default depends on projection; if this is one of those defined in OpenLayers.Projection.defaults\n- * (EPSG:4326 or web mercator), maxExtent will be set to the value defined there;\n- * else, defaults to null.\n- * To restrict user panning and zooming of the map, use instead.\n- * The value for will change calculations for tile URLs.\n+ * Method: write\n+ * Accept an object, and return a string. \n+ *\n+ * Parameters:\n+ * object - {Object} Object to be serialized\n+ *\n+ * Returns:\n+ * {String} A string representation of the object.\n */\n- maxExtent: null,\n+ write: function(object) {\n+ throw new Error('Write not implemented.');\n+ },\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 map. Defaults to null.\n- */\n- minExtent: null,\n+ CLASS_NAME: \"OpenLayers.Format\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/Point.js\n+ ====================================================================== */\n \n- /**\n- * APIProperty: restrictedExtent\n- * {|Array} If provided as an array, the array\n- * should consist of four values (left, bottom, right, top).\n- * Limit map navigation to this extent where possible.\n- * If a non-null restrictedExtent is set, panning will be restricted\n- * to the given bounds. In addition, zooming to a resolution that\n- * displays more than the restricted extent will center the map\n- * on the restricted extent. If you wish to limit the zoom level\n- * or resolution, use maxResolution.\n- */\n- restrictedExtent: null,\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- * APIProperty: numZoomLevels\n- * {Integer} Number of zoom levels for the map. Defaults to 16. Set a\n- * different value in the map options if needed.\n- */\n- numZoomLevels: 16,\n+/**\n+ * @requires OpenLayers/Geometry.js\n+ */\n \n- /**\n- * APIProperty: theme\n- * {String} Relative path to a CSS file from which to load theme styles.\n- * Specify null in the map options (e.g. {theme: null}) if you \n- * want to get cascading style declarations - by putting links to \n- * stylesheets or style declarations directly in your page.\n- */\n- theme: null,\n+/**\n+ * Class: OpenLayers.Geometry.Point\n+ * Point geometry class. \n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {\n \n /** \n- * APIProperty: displayProjection\n- * {} Requires proj4js support for projections other\n- * than EPSG:4326 or EPSG:900913/EPSG:3857. Projection used by\n- * several controls to display data to user. If this property is set,\n- * it will be set on any control which has a null displayProjection\n- * property at the time the control is added to the map. \n- */\n- displayProjection: null,\n-\n- /**\n- * APIProperty: tileManager\n- * {|Object} By default, and if the build contains\n- * TileManager.js, the map will use the TileManager to queue image requests\n- * and to cache tile image elements. To create a map without a TileManager\n- * configure the map with tileManager: null. To create a TileManager with\n- * non-default options, supply the options instead or alternatively supply\n- * an instance of {}.\n- */\n-\n- /**\n- * APIProperty: fallThrough\n- * {Boolean} Should OpenLayers allow events on the map to fall through to\n- * other elements on the page, or should it swallow them? (#457)\n- * Default is to swallow.\n- */\n- fallThrough: false,\n-\n- /**\n- * APIProperty: autoUpdateSize\n- * {Boolean} Should OpenLayers automatically update the size of the map\n- * when the resize event is fired. Default is true.\n- */\n- autoUpdateSize: true,\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- * Property: panTween\n- * {} Animated panning tween object, see panTo()\n- */\n- panTween: null,\n-\n- /**\n- * APIProperty: panMethod\n- * {Function} The Easing function to be used for tweening. Default is\n- * OpenLayers.Easing.Expo.easeOut. Setting this to 'null' turns off\n- * animated panning.\n- */\n- panMethod: OpenLayers.Easing.Expo.easeOut,\n-\n- /**\n- * Property: panDuration\n- * {Integer} The number of steps to be passed to the\n- * OpenLayers.Tween.start() method when the map is\n- * panned.\n- * Default is 50.\n+ * APIProperty: x \n+ * {float} \n */\n- panDuration: 50,\n+ x: null,\n \n- /**\n- * Property: zoomTween\n- * {} Animated zooming tween object, see zoomTo()\n+ /** \n+ * APIProperty: y \n+ * {float} \n */\n- zoomTween: null,\n+ y: null,\n \n /**\n- * APIProperty: zoomMethod\n- * {Function} The Easing function to be used for tweening. Default is\n- * OpenLayers.Easing.Quad.easeOut. Setting this to 'null' turns off\n- * animated zooming.\n+ * Constructor: OpenLayers.Geometry.Point\n+ * Construct a point geometry.\n+ *\n+ * Parameters:\n+ * x - {float} \n+ * y - {float}\n+ * \n */\n- zoomMethod: OpenLayers.Easing.Quad.easeOut,\n+ initialize: function(x, y) {\n+ OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n \n- /**\n- * Property: zoomDuration\n- * {Integer} The number of steps to be passed to the\n- * OpenLayers.Tween.start() method when the map is zoomed.\n- * Default is 20.\n- */\n- zoomDuration: 20,\n+ this.x = parseFloat(x);\n+ this.y = parseFloat(y);\n+ },\n \n /**\n- * Property: paddingForPopups\n- * {} Outside margin of the popup. Used to prevent \n- * the popup from getting too close to the map border.\n+ * APIMethod: clone\n+ * \n+ * Returns:\n+ * {} An exact clone of this OpenLayers.Geometry.Point\n */\n- paddingForPopups: null,\n+ clone: function(obj) {\n+ if (obj == null) {\n+ obj = new OpenLayers.Geometry.Point(this.x, this.y);\n+ }\n \n- /**\n- * Property: layerContainerOriginPx\n- * {Object} Cached object representing the layer container origin (in pixels).\n- */\n- layerContainerOriginPx: null,\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(obj, this);\n \n- /**\n- * Property: minPx\n- * {Object} An object with a 'x' and 'y' values that is the lower\n- * left of maxExtent in viewport pixel space.\n- * Used to verify in moveByPx that the new location we're moving to\n- * is valid. It is also used in the getLonLatFromViewPortPx function\n- * of Layer.\n- */\n- minPx: null,\n+ return obj;\n+ },\n \n- /**\n- * Property: maxPx\n- * {Object} An object with a 'x' and 'y' values that is the top\n- * right of maxExtent in viewport pixel space.\n- * Used to verify in moveByPx that the new location we're moving to\n- * is valid.\n+ /** \n+ * Method: calculateBounds\n+ * Create a new Bounds based on the lon/lat\n */\n- maxPx: null,\n+ calculateBounds: function() {\n+ this.bounds = new OpenLayers.Bounds(this.x, this.y,\n+ this.x, this.y);\n+ },\n \n /**\n- * Constructor: OpenLayers.Map\n- * Constructor for a new OpenLayers.Map instance. There are two possible\n- * ways to call the map constructor. See the examples below.\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n *\n * Parameters:\n- * div - {DOMElement|String} The element or id of an element in your page\n- * that will contain the map. May be omitted if the
option is\n- * provided or if you intend to call the method later.\n- * options - {Object} Optional object with properties to tag onto the map.\n- *\n- * Valid options (in addition to the listed API properties):\n- * center - {|Array} The default initial center of the map.\n- * If provided as array, the first value is the x coordinate,\n- * and the 2nd value is the y coordinate.\n- * Only specify if is provided.\n- * Note that if an ArgParser/Permalink control is present,\n- * and the querystring contains coordinates, center will be set\n- * by that, and this option will be ignored.\n- * zoom - {Number} The initial zoom level for the map. Only specify if\n- * is provided.\n- * Note that if an ArgParser/Permalink control is present,\n- * and the querystring contains a zoom level, zoom will be set\n- * by that, and this option will be ignored.\n- * extent - {|Array} The initial extent of the map.\n- * If provided as an array, the array should consist of\n- * four values (left, bottom, right, top).\n- * Only specify if
and are not provided.\n- * \n- * Examples:\n- * (code)\n- * // create a map with default options in an element with the id \"map1\"\n- * var map = new OpenLayers.Map(\"map1\");\n- *\n- * // create a map with non-default options in an element with id \"map2\"\n- * var options = {\n- * projection: \"EPSG:3857\",\n- * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000),\n- * center: new OpenLayers.LonLat(-12356463.476333, 5621521.4854095)\n- * };\n- * var map = new OpenLayers.Map(\"map2\", options);\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n *\n- * // map with non-default options - same as above but with a single argument,\n- * // a restricted extent, and using arrays for bounds and center\n- * var map = new OpenLayers.Map({\n- * div: \"map_id\",\n- * projection: \"EPSG:3857\",\n- * maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146],\n- * restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962],\n- * center: [-12356463.476333, 5621521.4854095]\n- * });\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n *\n- * // create a map without a reference to a container - call render later\n- * var map = new OpenLayers.Map({\n- * projection: \"EPSG:3857\",\n- * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000)\n- * });\n- * (end)\n+ * Returns:\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- initialize: function(div, options) {\n-\n- // If only one argument is provided, check if it is an object.\n- if (arguments.length === 1 && typeof div === \"object\") {\n- options = div;\n- div = options && options.div;\n- }\n-\n- // Simple-type defaults are set in class definition. \n- // Now set complex-type defaults \n- this.tileSize = new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH,\n- OpenLayers.Map.TILE_HEIGHT);\n-\n- this.paddingForPopups = new OpenLayers.Bounds(15, 15, 15, 15);\n-\n- this.theme = OpenLayers._getScriptLocation() +\n- 'theme/default/style.css';\n-\n- // backup original options\n- this.options = OpenLayers.Util.extend({}, options);\n-\n- // now override default options \n- OpenLayers.Util.extend(this, options);\n-\n- var projCode = this.projection instanceof OpenLayers.Projection ?\n- this.projection.projCode : this.projection;\n- OpenLayers.Util.applyDefaults(this, OpenLayers.Projection.defaults[projCode]);\n-\n- // allow extents and center to be arrays\n- if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) {\n- this.maxExtent = new OpenLayers.Bounds(this.maxExtent);\n- }\n- if (this.minExtent && !(this.minExtent instanceof OpenLayers.Bounds)) {\n- this.minExtent = new OpenLayers.Bounds(this.minExtent);\n- }\n- if (this.restrictedExtent && !(this.restrictedExtent instanceof OpenLayers.Bounds)) {\n- this.restrictedExtent = new OpenLayers.Bounds(this.restrictedExtent);\n- }\n- if (this.center && !(this.center instanceof OpenLayers.LonLat)) {\n- this.center = new OpenLayers.LonLat(this.center);\n- }\n-\n- // initialize layers array\n- this.layers = [];\n-\n- this.id = OpenLayers.Util.createUniqueID(\"OpenLayers.Map_\");\n-\n- this.div = OpenLayers.Util.getElement(div);\n- if (!this.div) {\n- this.div = document.createElement(\"div\");\n- this.div.style.height = \"1px\";\n- this.div.style.width = \"1px\";\n- }\n-\n- OpenLayers.Element.addClass(this.div, 'olMap');\n-\n- // the viewPortDiv is the outermost div we modify\n- var id = this.id + \"_OpenLayers_ViewPort\";\n- this.viewPortDiv = OpenLayers.Util.createDiv(id, null, null, null,\n- \"relative\", null,\n- \"hidden\");\n- this.viewPortDiv.style.width = \"100%\";\n- this.viewPortDiv.style.height = \"100%\";\n- this.viewPortDiv.className = \"olMapViewport\";\n- this.div.appendChild(this.viewPortDiv);\n-\n- this.events = new OpenLayers.Events(\n- this, this.viewPortDiv, null, this.fallThrough, {\n- includeXY: true\n- }\n- );\n-\n- if (OpenLayers.TileManager && this.tileManager !== null) {\n- if (!(this.tileManager instanceof OpenLayers.TileManager)) {\n- this.tileManager = new OpenLayers.TileManager(this.tileManager);\n- }\n- this.tileManager.addMap(this);\n- }\n-\n- // the layerContainerDiv is the one that holds all the layers\n- id = this.id + \"_OpenLayers_Container\";\n- this.layerContainerDiv = OpenLayers.Util.createDiv(id);\n- this.layerContainerDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] - 1;\n- this.layerContainerOriginPx = {\n- x: 0,\n- y: 0\n- };\n- this.applyTransform();\n-\n- this.viewPortDiv.appendChild(this.layerContainerDiv);\n-\n- this.updateSize();\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n- }\n-\n- if (this.autoUpdateSize === true) {\n- // updateSize on catching the window's resize\n- // Note that this is ok, as updateSize() does nothing if the \n- // map's size has not actually changed.\n- this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,\n- this);\n- OpenLayers.Event.observe(window, 'resize',\n- this.updateSizeDestroy);\n- }\n-\n- // only append link stylesheet if the theme property is set\n- if (this.theme) {\n- // check existing links for equivalent url\n- var addNode = true;\n- var nodes = document.getElementsByTagName('link');\n- for (var i = 0, len = nodes.length; i < len; ++i) {\n- if (OpenLayers.Util.isEquivalentUrl(nodes.item(i).href,\n- this.theme)) {\n- addNode = false;\n- break;\n- }\n- }\n- // only add a new node if one with an equivalent url hasn't already\n- // been added\n- if (addNode) {\n- var cssNode = document.createElement('link');\n- cssNode.setAttribute('rel', 'stylesheet');\n- cssNode.setAttribute('type', 'text/css');\n- cssNode.setAttribute('href', this.theme);\n- document.getElementsByTagName('head')[0].appendChild(cssNode);\n- }\n- }\n-\n- if (this.controls == null) { // default controls\n- this.controls = [];\n- if (OpenLayers.Control != null) { // running full or lite?\n- // Navigation or TouchNavigation depending on what is in build\n- if (OpenLayers.Control.Navigation) {\n- this.controls.push(new OpenLayers.Control.Navigation());\n- } else if (OpenLayers.Control.TouchNavigation) {\n- this.controls.push(new OpenLayers.Control.TouchNavigation());\n- }\n- if (OpenLayers.Control.Zoom) {\n- this.controls.push(new OpenLayers.Control.Zoom());\n- } else if (OpenLayers.Control.PanZoom) {\n- this.controls.push(new OpenLayers.Control.PanZoom());\n- }\n-\n- if (OpenLayers.Control.ArgParser) {\n- this.controls.push(new OpenLayers.Control.ArgParser());\n- }\n- if (OpenLayers.Control.Attribution) {\n- this.controls.push(new OpenLayers.Control.Attribution());\n- }\n- }\n- }\n-\n- for (var i = 0, len = this.controls.length; i < len; i++) {\n- this.addControlToMap(this.controls[i]);\n- }\n-\n- this.popups = [];\n-\n- this.unloadDestroy = OpenLayers.Function.bind(this.destroy, this);\n-\n-\n- // always call map.destroy()\n- OpenLayers.Event.observe(window, 'unload', this.unloadDestroy);\n-\n- // add any initial layers\n- if (options && options.layers) {\n- /** \n- * If you have set options.center, the map center property will be\n- * set at this point. However, since setCenter has not been called,\n- * addLayers gets confused. So we delete the map center in this \n- * case. Because the check below uses options.center, it will\n- * be properly set below.\n- */\n- delete this.center;\n- delete this.zoom;\n- this.addLayers(options.layers);\n- // set center (and optionally zoom)\n- if (options.center && !this.getCenter()) {\n- // zoom can be undefined here\n- this.setCenter(options.center, options.zoom);\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var details = edge && options && options.details;\n+ var distance, x0, y0, x1, y1, result;\n+ if (geometry instanceof OpenLayers.Geometry.Point) {\n+ x0 = this.x;\n+ y0 = this.y;\n+ x1 = geometry.x;\n+ y1 = geometry.y;\n+ distance = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));\n+ result = !details ?\n+ distance : {\n+ x0: x0,\n+ y0: y0,\n+ x1: x1,\n+ y1: y1,\n+ distance: distance\n+ };\n+ } else {\n+ result = geometry.distanceTo(this, options);\n+ if (details) {\n+ // switch coord order since this geom is target\n+ result = {\n+ x0: result.x1,\n+ y0: result.y1,\n+ x1: result.x0,\n+ y1: result.y0,\n+ distance: result.distance\n+ };\n }\n }\n-\n- if (this.panMethod) {\n- this.panTween = new OpenLayers.Tween(this.panMethod);\n- }\n- if (this.zoomMethod && this.applyTransform.transform) {\n- this.zoomTween = new OpenLayers.Tween(this.zoomMethod);\n- }\n+ return result;\n },\n \n /** \n- * APIMethod: getViewport\n- * Get the DOMElement representing the view port.\n+ * APIMethod: equals\n+ * Determine whether another geometry is equivalent to this one. Geometries\n+ * are considered equivalent if all components have the same coordinates.\n+ * \n+ * Parameters:\n+ * geom - {} The geometry to test. \n *\n * Returns:\n- * {DOMElement}\n+ * {Boolean} The supplied geometry is equivalent to this geometry.\n */\n- getViewport: function() {\n- return this.viewPortDiv;\n+ equals: function(geom) {\n+ var equals = false;\n+ if (geom != null) {\n+ equals = ((this.x == geom.x && this.y == geom.y) ||\n+ (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y)));\n+ }\n+ return equals;\n },\n \n /**\n- * APIMethod: render\n- * Render the map to a specified container.\n- * \n- * Parameters:\n- * div - {String|DOMElement} The container that the map should be rendered\n- * to. If different than the current container, the map viewport\n- * will be moved from the current to the new container.\n+ * Method: toShortString\n+ *\n+ * Returns:\n+ * {String} Shortened String representation of Point object. \n+ * (ex. \"5, 42\")\n */\n- render: function(div) {\n- this.div = OpenLayers.Util.getElement(div);\n- OpenLayers.Element.addClass(this.div, 'olMap');\n- this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);\n- this.div.appendChild(this.viewPortDiv);\n- this.updateSize();\n+ toShortString: function() {\n+ return (this.x + \", \" + this.y);\n },\n \n /**\n- * Method: unloadDestroy\n- * Function that is called to destroy the map on page unload. stored here\n- * so that if map is manually destroyed, we can unregister this.\n- */\n- unloadDestroy: null,\n-\n- /**\n- * Method: updateSizeDestroy\n- * When the map is destroyed, we need to stop listening to updateSize\n- * events: this method stores the function we need to unregister in \n- * non-IE browsers.\n- */\n- updateSizeDestroy: null,\n-\n- /**\n- * APIMethod: destroy\n- * Destroy this map.\n- * Note that if you are using an application which removes a container\n- * of the map from the DOM, you need to ensure that you destroy the\n- * map *before* this happens; otherwise, the page unload handler\n- * will fail because the DOM elements that map.destroy() wants\n- * to clean up will be gone. (See \n- * http://trac.osgeo.org/openlayers/ticket/2277 for more information).\n- * This will apply to GeoExt and also to other applications which\n- * modify the DOM of the container of the OpenLayers Map.\n+ * APIMethod: move\n+ * Moves a geometry by the given displacement along positive x and y axes.\n+ * This modifies the position of the geometry and clears the cached\n+ * bounds.\n+ *\n+ * Parameters:\n+ * x - {Float} Distance to move geometry in positive x direction. \n+ * y - {Float} Distance to move geometry in positive y direction.\n */\n- destroy: function() {\n- // if unloadDestroy is null, we've already been destroyed\n- if (!this.unloadDestroy) {\n- return false;\n- }\n-\n- // make sure panning doesn't continue after destruction\n- if (this.panTween) {\n- this.panTween.stop();\n- this.panTween = null;\n- }\n- // make sure zooming doesn't continue after destruction\n- if (this.zoomTween) {\n- this.zoomTween.stop();\n- this.zoomTween = null;\n- }\n-\n- // map has been destroyed. dont do it again!\n- OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);\n- this.unloadDestroy = null;\n-\n- if (this.updateSizeDestroy) {\n- OpenLayers.Event.stopObserving(window, 'resize',\n- this.updateSizeDestroy);\n- }\n-\n- this.paddingForPopups = null;\n-\n- if (this.controls != null) {\n- for (var i = this.controls.length - 1; i >= 0; --i) {\n- this.controls[i].destroy();\n- }\n- this.controls = null;\n- }\n- if (this.layers != null) {\n- for (var i = this.layers.length - 1; i >= 0; --i) {\n- //pass 'false' to destroy so that map wont try to set a new \n- // baselayer after each baselayer is removed\n- this.layers[i].destroy(false);\n- }\n- this.layers = null;\n- }\n- if (this.viewPortDiv && this.viewPortDiv.parentNode) {\n- this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);\n- }\n- this.viewPortDiv = null;\n-\n- if (this.tileManager) {\n- this.tileManager.removeMap(this);\n- this.tileManager = null;\n- }\n-\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n- this.eventListeners = null;\n- }\n- this.events.destroy();\n- this.events = null;\n-\n- this.options = null;\n+ move: function(x, y) {\n+ this.x = this.x + x;\n+ this.y = this.y + y;\n+ this.clearBounds();\n },\n \n /**\n- * APIMethod: setOptions\n- * Change the map options\n+ * APIMethod: rotate\n+ * Rotate a point around another.\n *\n * Parameters:\n- * options - {Object} Hashtable of options to tag to the map\n+ * angle - {Float} Rotation angle in degrees (measured counterclockwise\n+ * from the positive x-axis)\n+ * origin - {} Center point for the rotation\n */\n- setOptions: function(options) {\n- var updatePxExtent = this.minPx &&\n- options.restrictedExtent != this.restrictedExtent;\n- OpenLayers.Util.extend(this, options);\n- // force recalculation of minPx and maxPx\n- updatePxExtent && this.moveTo(this.getCachedCenter(), this.zoom, {\n- forceZoomChange: true\n- });\n+ rotate: function(angle, origin) {\n+ angle *= Math.PI / 180;\n+ var radius = this.distanceTo(origin);\n+ var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);\n+ this.x = origin.x + (radius * Math.cos(theta));\n+ this.y = origin.y + (radius * Math.sin(theta));\n+ this.clearBounds();\n },\n \n /**\n- * APIMethod: getTileSize\n- * Get the tile size for the map\n+ * APIMethod: getCentroid\n *\n * Returns:\n- * {}\n+ * {} The centroid of the collection\n */\n- getTileSize: function() {\n- return this.tileSize;\n+ getCentroid: function() {\n+ return new OpenLayers.Geometry.Point(this.x, this.y);\n },\n \n-\n /**\n- * APIMethod: getBy\n- * Get a list of objects given a property and a match item.\n+ * APIMethod: resize\n+ * Resize a point relative to some origin. For points, this has the effect\n+ * of scaling a vector (from the origin to the point). This method is\n+ * more useful on geometry collection subclasses.\n *\n * Parameters:\n- * array - {String} A property on the map whose value is an array.\n- * property - {String} A property on each item of the given array.\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(map[array][i][property]) evaluates to true, the item will\n- * be included in the array returned. If no items are found, an empty\n- * array is returned.\n- *\n+ * scale - {Float} Ratio of the new distance from the origin to the old\n+ * distance from the origin. A scale of 2 doubles the\n+ * distance between the point and origin.\n+ * origin - {} Point of origin for resizing\n+ * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n+ * \n * Returns:\n- * {Array} An array of items where the given property matches the given\n- * criteria.\n+ * {} - The current geometry. \n */\n- getBy: function(array, property, match) {\n- var test = (typeof match.test == \"function\");\n- var found = OpenLayers.Array.filter(this[array], function(item) {\n- return item[property] == match || (test && match.test(item[property]));\n- });\n- return found;\n+ resize: function(scale, origin, ratio) {\n+ ratio = (ratio == undefined) ? 1 : ratio;\n+ this.x = origin.x + (scale * ratio * (this.x - origin.x));\n+ this.y = origin.y + (scale * (this.y - origin.y));\n+ this.clearBounds();\n+ return this;\n },\n \n /**\n- * APIMethod: getLayersBy\n- * Get a list of layers with properties matching the given criteria.\n+ * APIMethod: intersects\n+ * Determine if the input geometry intersects this one.\n *\n * Parameters:\n- * property - {String} A layer 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(layer[property]) evaluates to true, the layer will be\n- * included in the array returned. If no layers are found, an empty\n- * array is returned.\n+ * geometry - {} Any type of geometry.\n *\n * Returns:\n- * {Array()} A list of layers matching the given criteria.\n- * An empty array is returned if no matches are found.\n+ * {Boolean} The input geometry intersects this one.\n */\n- getLayersBy: function(property, match) {\n- return this.getBy(\"layers\", property, match);\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n+ intersect = this.equals(geometry);\n+ } else {\n+ intersect = geometry.intersects(this);\n+ }\n+ return intersect;\n },\n \n /**\n- * APIMethod: getLayersByName\n- * Get a list of layers with names matching the given name.\n- *\n+ * APIMethod: transform\n+ * Translate the x,y properties of the point from source to dest.\n+ * \n * Parameters:\n- * match - {String | Object} A layer 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(layer.name) evaluates to true, the layer will be included\n- * in the list of layers returned. If no layers are found, an empty\n- * array is returned.\n- *\n+ * source - {} \n+ * dest - {}\n+ * \n * Returns:\n- * {Array()} A list of layers matching the given name.\n- * An empty array is returned if no matches are found.\n+ * {} \n */\n- getLayersByName: function(match) {\n- return this.getLayersBy(\"name\", match);\n+ transform: function(source, dest) {\n+ if ((source && dest)) {\n+ OpenLayers.Projection.transform(\n+ this, source, dest);\n+ this.bounds = null;\n+ }\n+ return this;\n },\n \n /**\n- * APIMethod: getLayersByClass\n- * Get a list of layers of a given class (CLASS_NAME).\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n *\n * Parameters:\n- * match - {String | Object} A layer class name. The match 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(layer.CLASS_NAME) evaluates to true, the layer will\n- * be included in the list of layers returned. If no layers are\n- * found, an empty array is returned.\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n *\n * Returns:\n- * {Array()} A list of layers matching the given class.\n- * An empty array is returned if no matches are found.\n+ * {Array} A list of all vertices in the geometry.\n */\n- getLayersByClass: function(match) {\n- return this.getLayersBy(\"CLASS_NAME\", match);\n+ getVertices: function(nodes) {\n+ return [this];\n },\n \n+ CLASS_NAME: \"OpenLayers.Geometry.Point\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/Collection.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/Geometry.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Geometry.Collection\n+ * A Collection is exactly what it sounds like: A collection of different \n+ * Geometries. These are stored in the local parameter (which\n+ * can be passed as a parameter to the constructor). \n+ * \n+ * As new geometries are added to the collection, they are NOT cloned. \n+ * When removing geometries, they need to be specified by reference (ie you \n+ * have to pass in the *exact* geometry to be removed).\n+ * \n+ * The and functions here merely iterate through\n+ * the components, summing their respective areas and lengths.\n+ *\n+ * Create a new instance with the constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {\n+\n /**\n- * APIMethod: getControlsBy\n- * Get a list of controls with properties matching the given criteria.\n- *\n- * Parameters:\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(layer[property]) evaluates to true, the layer will be\n- * included in the array returned. If no layers are found, an empty\n- * array is returned.\n- *\n- * Returns:\n- * {Array()} A list of controls matching the given\n- * criteria. An empty array is returned if no matches are found.\n+ * APIProperty: components\n+ * {Array()} The component parts of this geometry\n */\n- getControlsBy: function(property, match) {\n- return this.getBy(\"controls\", property, match);\n- },\n+ components: null,\n \n /**\n- * APIMethod: getControlsByClass\n- * Get a list of controls of a given class (CLASS_NAME).\n- *\n- * Parameters:\n- * match - {String | Object} A control class name. The match 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- * {Array()} A list of controls matching the given class.\n- * An empty array is returned if no matches are found.\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n */\n- getControlsByClass: function(match) {\n- return this.getControlsBy(\"CLASS_NAME\", match);\n- },\n-\n- /********************************************************/\n- /* */\n- /* Layer Functions */\n- /* */\n- /* The following functions deal with adding and */\n- /* removing Layers to and from the Map */\n- /* */\n- /********************************************************/\n+ componentTypes: null,\n \n /**\n- * APIMethod: getLayer\n- * Get a layer based on its id\n+ * Constructor: OpenLayers.Geometry.Collection\n+ * Creates a Geometry Collection -- a list of geoms.\n *\n- * Parameters:\n- * id - {String} A layer id\n+ * Parameters: \n+ * components - {Array()} Optional array of geometries\n *\n- * Returns:\n- * {} The Layer with the corresponding id from the map's \n- * layer collection, or null if not found.\n */\n- getLayer: function(id) {\n- var foundLayer = null;\n- for (var i = 0, len = this.layers.length; i < len; i++) {\n- var layer = this.layers[i];\n- if (layer.id == id) {\n- foundLayer = layer;\n- break;\n- }\n+ initialize: function(components) {\n+ OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n+ this.components = [];\n+ if (components != null) {\n+ this.addComponents(components);\n }\n- return foundLayer;\n },\n \n /**\n- * Method: setLayerZIndex\n- * \n- * Parameters:\n- * layer - {} \n- * zIdx - {int} \n+ * APIMethod: destroy\n+ * Destroy this geometry.\n */\n- setLayerZIndex: function(layer, zIdx) {\n- layer.setZIndex(\n- this.Z_INDEX_BASE[layer.isBaseLayer ? 'BaseLayer' : 'Overlay'] +\n- zIdx * 5);\n+ destroy: function() {\n+ this.components.length = 0;\n+ this.components = null;\n+ OpenLayers.Geometry.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: resetLayersZIndex\n- * Reset each layer's z-index based on layer's array index\n+ * APIMethod: clone\n+ * Clone this geometry.\n+ *\n+ * Returns:\n+ * {} An exact clone of this collection\n */\n- resetLayersZIndex: function() {\n- for (var i = 0, len = this.layers.length; i < len; i++) {\n- var layer = this.layers[i];\n- this.setLayerZIndex(layer, i);\n+ clone: function() {\n+ var geometry = eval(\"new \" + this.CLASS_NAME + \"()\");\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ geometry.addComponent(this.components[i].clone());\n }\n+\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(geometry, this);\n+\n+ return geometry;\n },\n \n /**\n- * APIMethod: addLayer\n- *\n- * Parameters:\n- * layer - {} \n- *\n+ * Method: getComponentsString\n+ * Get a string representing the components for this collection\n+ * \n * Returns:\n- * {Boolean} True if the layer has been added to the map.\n+ * {String} A string representation of the components of this geometry\n */\n- addLayer: function(layer) {\n- for (var i = 0, len = this.layers.length; i < len; i++) {\n- if (this.layers[i] == layer) {\n- return false;\n- }\n- }\n- if (this.events.triggerEvent(\"preaddlayer\", {\n- layer: layer\n- }) === false) {\n- return false;\n- }\n- if (this.allOverlays) {\n- layer.isBaseLayer = false;\n- }\n-\n- layer.div.className = \"olLayerDiv\";\n- layer.div.style.overflow = \"\";\n- this.setLayerZIndex(layer, this.layers.length);\n-\n- if (layer.isFixed) {\n- this.viewPortDiv.appendChild(layer.div);\n- } else {\n- this.layerContainerDiv.appendChild(layer.div);\n+ getComponentsString: function() {\n+ var strings = [];\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ strings.push(this.components[i].toShortString());\n }\n- this.layers.push(layer);\n- layer.setMap(this);\n+ return strings.join(\",\");\n+ },\n \n- if (layer.isBaseLayer || (this.allOverlays && !this.baseLayer)) {\n- if (this.baseLayer == null) {\n- // set the first baselaye we add as the baselayer\n- this.setBaseLayer(layer);\n- } else {\n- layer.setVisibility(false);\n+ /**\n+ * APIMethod: calculateBounds\n+ * Recalculate the bounds by iterating through the components and \n+ * calling calling extendBounds() on each item.\n+ */\n+ calculateBounds: function() {\n+ this.bounds = null;\n+ var bounds = new OpenLayers.Bounds();\n+ var components = this.components;\n+ if (components) {\n+ for (var i = 0, len = components.length; i < len; i++) {\n+ bounds.extend(components[i].getBounds());\n }\n- } else {\n- layer.redraw();\n }\n-\n- this.events.triggerEvent(\"addlayer\", {\n- layer: layer\n- });\n- layer.events.triggerEvent(\"added\", {\n- map: this,\n- layer: layer\n- });\n- layer.afterAdd();\n-\n- return true;\n+ // to preserve old behavior, we only set bounds if non-null\n+ // in the future, we could add bounds.isEmpty()\n+ if (bounds.left != null && bounds.bottom != null &&\n+ bounds.right != null && bounds.top != null) {\n+ this.setBounds(bounds);\n+ }\n },\n \n /**\n- * APIMethod: addLayers \n+ * APIMethod: addComponents\n+ * Add components to this geometry.\n *\n * Parameters:\n- * layers - {Array()} \n+ * components - {Array()} An array of geometries to add\n */\n- addLayers: function(layers) {\n- for (var i = 0, len = layers.length; i < len; i++) {\n- this.addLayer(layers[i]);\n+ addComponents: function(components) {\n+ if (!(OpenLayers.Util.isArray(components))) {\n+ components = [components];\n+ }\n+ for (var i = 0, len = components.length; i < len; i++) {\n+ this.addComponent(components[i]);\n }\n },\n \n- /** \n- * APIMethod: removeLayer\n- * Removes a layer from the map by removing its visual element (the \n- * layer.div property), then removing it from the map's internal list \n- * of layers, setting the layer's map property to null. \n- * \n- * a \"removelayer\" event is triggered.\n- * \n- * very worthy of mention is that simply removing a layer from a map\n- * will not cause the removal of any popups which may have been created\n- * by the layer. this is due to the fact that it was decided at some\n- * point that popups would not belong to layers. thus there is no way \n- * for us to know here to which layer the popup belongs.\n- * \n- * A simple solution to this is simply to call destroy() on the layer.\n- * the default OpenLayers.Layer class's destroy() function\n- * automatically takes care to remove itself from whatever map it has\n- * been attached to. \n- * \n- * The correct solution is for the layer itself to register an \n- * event-handler on \"removelayer\" and when it is called, if it \n- * recognizes itself as the layer being removed, then it cycles through\n- * its own personal list of popups, removing them from the map.\n+ /**\n+ * Method: addComponent\n+ * Add a new component (geometry) to the collection. If this.componentTypes\n+ * is set, then the component class name must be in the componentTypes array.\n+ *\n+ * The bounds cache is reset.\n * \n * Parameters:\n- * layer - {} \n- * setNewBaseLayer - {Boolean} Default is true\n+ * component - {} A geometry to add\n+ * index - {int} Optional index into the array to insert the component\n+ *\n+ * Returns:\n+ * {Boolean} The component geometry was successfully added\n */\n- removeLayer: function(layer, setNewBaseLayer) {\n- if (this.events.triggerEvent(\"preremovelayer\", {\n- layer: layer\n- }) === false) {\n- return;\n- }\n- if (setNewBaseLayer == null) {\n- setNewBaseLayer = true;\n- }\n-\n- if (layer.isFixed) {\n- this.viewPortDiv.removeChild(layer.div);\n- } else {\n- this.layerContainerDiv.removeChild(layer.div);\n- }\n- OpenLayers.Util.removeItem(this.layers, layer);\n- layer.removeMap(this);\n- layer.map = null;\n+ addComponent: function(component, index) {\n+ var added = false;\n+ if (component) {\n+ if (this.componentTypes == null ||\n+ (OpenLayers.Util.indexOf(this.componentTypes,\n+ component.CLASS_NAME) > -1)) {\n \n- // if we removed the base layer, need to set a new one\n- if (this.baseLayer == layer) {\n- this.baseLayer = null;\n- if (setNewBaseLayer) {\n- for (var i = 0, len = this.layers.length; i < len; i++) {\n- var iLayer = this.layers[i];\n- if (iLayer.isBaseLayer || this.allOverlays) {\n- this.setBaseLayer(iLayer);\n- break;\n- }\n+ if (index != null && (index < this.components.length)) {\n+ var components1 = this.components.slice(0, index);\n+ var components2 = this.components.slice(index,\n+ this.components.length);\n+ components1.push(component);\n+ this.components = components1.concat(components2);\n+ } else {\n+ this.components.push(component);\n }\n+ component.parent = this;\n+ this.clearBounds();\n+ added = true;\n }\n }\n-\n- this.resetLayersZIndex();\n-\n- this.events.triggerEvent(\"removelayer\", {\n- layer: layer\n- });\n- layer.events.triggerEvent(\"removed\", {\n- map: this,\n- layer: layer\n- });\n+ return added;\n },\n \n /**\n- * APIMethod: getNumLayers\n- * \n- * Returns:\n- * {Int} The number of layers attached to the map.\n- */\n- getNumLayers: function() {\n- return this.layers.length;\n- },\n-\n- /** \n- * APIMethod: getLayerIndex\n+ * APIMethod: removeComponents\n+ * Remove components from this geometry.\n *\n * Parameters:\n- * layer - {}\n+ * components - {Array()} The components to be removed\n *\n- * Returns:\n- * {Integer} The current (zero-based) index of the given layer in the map's\n- * layer stack. Returns -1 if the layer isn't on the map.\n+ * Returns: \n+ * {Boolean} A component was removed.\n */\n- getLayerIndex: function(layer) {\n- return OpenLayers.Util.indexOf(this.layers, layer);\n- },\n+ removeComponents: function(components) {\n+ var removed = false;\n \n- /** \n- * APIMethod: setLayerIndex\n- * Move the given layer to the specified (zero-based) index in the layer\n- * list, changing its z-index in the map display. Use\n- * map.getLayerIndex() to find out the current index of a layer. Note\n- * that this cannot (or at least should not) be effectively used to\n- * raise base layers above overlays.\n- *\n- * Parameters:\n- * layer - {} \n- * idx - {int} \n- */\n- setLayerIndex: function(layer, idx) {\n- var base = this.getLayerIndex(layer);\n- if (idx < 0) {\n- idx = 0;\n- } else if (idx > this.layers.length) {\n- idx = this.layers.length;\n+ if (!(OpenLayers.Util.isArray(components))) {\n+ components = [components];\n }\n- if (base != idx) {\n- this.layers.splice(base, 1);\n- this.layers.splice(idx, 0, layer);\n- for (var i = 0, len = this.layers.length; i < len; i++) {\n- this.setLayerZIndex(this.layers[i], i);\n- }\n- this.events.triggerEvent(\"changelayer\", {\n- layer: layer,\n- property: \"order\"\n- });\n- if (this.allOverlays) {\n- if (idx === 0) {\n- this.setBaseLayer(layer);\n- } else if (this.baseLayer !== this.layers[0]) {\n- this.setBaseLayer(this.layers[0]);\n- }\n- }\n+ for (var i = components.length - 1; i >= 0; --i) {\n+ removed = this.removeComponent(components[i]) || removed;\n }\n+ return removed;\n },\n \n- /** \n- * APIMethod: raiseLayer\n- * Change the index of the given layer by delta. If delta is positive, \n- * the layer is moved up the map's layer stack; if delta is negative,\n- * the layer is moved down. Again, note that this cannot (or at least\n- * should not) be effectively used to raise base layers above overlays.\n+ /**\n+ * Method: removeComponent\n+ * Remove a component from this geometry.\n *\n- * Paremeters:\n- * layer - {} \n- * delta - {int} \n- */\n- raiseLayer: function(layer, delta) {\n- var idx = this.getLayerIndex(layer) + delta;\n- this.setLayerIndex(layer, idx);\n- },\n-\n- /** \n- * APIMethod: setBaseLayer\n- * Allows user to specify one of the currently-loaded layers as the Map's\n- * new base layer.\n- * \n * Parameters:\n- * newBaseLayer - {}\n+ * component - {} \n+ *\n+ * Returns: \n+ * {Boolean} The component was removed.\n */\n- setBaseLayer: function(newBaseLayer) {\n-\n- if (newBaseLayer != this.baseLayer) {\n-\n- // ensure newBaseLayer is already loaded\n- if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {\n-\n- // preserve center and scale when changing base layers\n- var center = this.getCachedCenter();\n- var newResolution = OpenLayers.Util.getResolutionFromScale(\n- this.getScale(), newBaseLayer.units\n- );\n-\n- // make the old base layer invisible \n- if (this.baseLayer != null && !this.allOverlays) {\n- this.baseLayer.setVisibility(false);\n- }\n-\n- // set new baselayer\n- this.baseLayer = newBaseLayer;\n-\n- if (!this.allOverlays || this.baseLayer.visibility) {\n- this.baseLayer.setVisibility(true);\n- // Layer may previously have been visible but not in range.\n- // In this case we need to redraw it to make it visible.\n- if (this.baseLayer.inRange === false) {\n- this.baseLayer.redraw();\n- }\n- }\n+ removeComponent: function(component) {\n \n- // recenter the map\n- if (center != null) {\n- // new zoom level derived from old scale\n- var newZoom = this.getZoomForResolution(\n- newResolution || this.resolution, true\n- );\n- // zoom and force zoom change\n- this.setCenter(center, newZoom, false, true);\n- }\n+ OpenLayers.Util.removeItem(this.components, component);\n \n- this.events.triggerEvent(\"changebaselayer\", {\n- layer: this.baseLayer\n- });\n- }\n- }\n+ // clearBounds() so that it gets recalculated on the next call\n+ // to this.getBounds();\n+ this.clearBounds();\n+ return true;\n },\n \n-\n- /********************************************************/\n- /* */\n- /* Control Functions */\n- /* */\n- /* The following functions deal with adding and */\n- /* removing Controls to and from the Map */\n- /* */\n- /********************************************************/\n-\n /**\n- * APIMethod: addControl\n- * Add the passed over control to the map. Optionally \n- * position the control at the given pixel.\n- * \n- * Parameters:\n- * control - {}\n- * px - {}\n+ * APIMethod: getLength\n+ * Calculate the length of this geometry\n+ *\n+ * Returns:\n+ * {Float} The length of the geometry\n */\n- addControl: function(control, px) {\n- this.controls.push(control);\n- this.addControlToMap(control, px);\n+ getLength: function() {\n+ var length = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ length += this.components[i].getLength();\n+ }\n+ return length;\n },\n \n /**\n- * APIMethod: addControls\n- * Add all of the passed over controls to the map. \n- * You can pass over an optional second array\n- * with pixel-objects to position the controls.\n- * The indices of the two arrays should match and\n- * you can add null as pixel for those controls \n- * you want to be autopositioned. \n- * \n- * Parameters:\n- * controls - {Array()}\n- * pixels - {Array()}\n+ * APIMethod: getArea\n+ * Calculate the area of this geometry. Note how this function is overridden\n+ * in .\n+ *\n+ * Returns:\n+ * {Float} The area of the collection by summing its parts\n */\n- addControls: function(controls, pixels) {\n- var pxs = (arguments.length === 1) ? [] : pixels;\n- for (var i = 0, len = controls.length; i < len; i++) {\n- var ctrl = controls[i];\n- var px = (pxs[i]) ? pxs[i] : null;\n- this.addControl(ctrl, px);\n+ getArea: function() {\n+ var area = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ area += this.components[i].getArea();\n }\n+ return area;\n },\n \n- /**\n- * Method: addControlToMap\n- * \n+ /** \n+ * APIMethod: getGeodesicArea\n+ * Calculate the approximate area of the polygon were it projected onto\n+ * the earth.\n+ *\n * Parameters:\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n * \n- * control - {}\n- * px - {}\n+ * Reference:\n+ * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n+ * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n+ * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n+ *\n+ * Returns:\n+ * {float} The approximate geodesic area of the geometry in square meters.\n */\n- addControlToMap: function(control, px) {\n- // If a control doesn't have a div at this point, it belongs in the\n- // viewport.\n- control.outsideViewport = (control.div != null);\n-\n- // If the map has a displayProjection, and the control doesn't, set \n- // the display projection.\n- if (this.displayProjection && !control.displayProjection) {\n- control.displayProjection = this.displayProjection;\n- }\n-\n- control.setMap(this);\n- var div = control.draw(px);\n- if (div) {\n- if (!control.outsideViewport) {\n- div.style.zIndex = this.Z_INDEX_BASE['Control'] +\n- this.controls.length;\n- this.viewPortDiv.appendChild(div);\n- }\n- }\n- if (control.autoActivate) {\n- control.activate();\n+ getGeodesicArea: function(projection) {\n+ var area = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ area += this.components[i].getGeodesicArea(projection);\n }\n+ return area;\n },\n \n /**\n- * APIMethod: getControl\n- * \n+ * APIMethod: getCentroid\n+ *\n+ * Compute the centroid for this geometry collection.\n+ *\n * Parameters:\n- * id - {String} ID of the control to return.\n- * \n+ * weighted - {Boolean} Perform the getCentroid computation recursively,\n+ * returning an area weighted average of all geometries in this collection.\n+ *\n * Returns:\n- * {} The control from the map's list of controls \n- * which has a matching 'id'. If none found, \n- * returns null.\n+ * {} The centroid of the collection\n */\n- getControl: function(id) {\n- var returnControl = null;\n- for (var i = 0, len = this.controls.length; i < len; i++) {\n- var control = this.controls[i];\n- if (control.id == id) {\n- returnControl = control;\n- break;\n- }\n+ getCentroid: function(weighted) {\n+ if (!weighted) {\n+ return this.components.length && this.components[0].getCentroid();\n+ }\n+ var len = this.components.length;\n+ if (!len) {\n+ return false;\n }\n- return returnControl;\n- },\n \n- /** \n- * APIMethod: removeControl\n- * Remove a control from the map. Removes the control both from the map \n- * object's internal array of controls, as well as from the map's \n- * viewPort (assuming the control was not added outsideViewport)\n- * \n- * Parameters:\n- * control - {} The control to remove.\n- */\n- removeControl: function(control) {\n- //make sure control is non-null and actually part of our map\n- if ((control) && (control == this.getControl(control.id))) {\n- if (control.div && (control.div.parentNode == this.viewPortDiv)) {\n- this.viewPortDiv.removeChild(control.div);\n+ var areas = [];\n+ var centroids = [];\n+ var areaSum = 0;\n+ var minArea = Number.MAX_VALUE;\n+ var component;\n+ for (var i = 0; i < len; ++i) {\n+ component = this.components[i];\n+ var area = component.getArea();\n+ var centroid = component.getCentroid(true);\n+ if (isNaN(area) || isNaN(centroid.x) || isNaN(centroid.y)) {\n+ continue;\n }\n- OpenLayers.Util.removeItem(this.controls, control);\n+ areas.push(area);\n+ areaSum += area;\n+ minArea = (area < minArea && area > 0) ? area : minArea;\n+ centroids.push(centroid);\n }\n- },\n-\n- /********************************************************/\n- /* */\n- /* Popup Functions */\n- /* */\n- /* The following functions deal with adding and */\n- /* removing Popups to and from the Map */\n- /* */\n- /********************************************************/\n-\n- /** \n- * APIMethod: addPopup\n- * \n- * Parameters:\n- * popup - {}\n- * exclusive - {Boolean} If true, closes all other popups first\n- */\n- addPopup: function(popup, exclusive) {\n-\n- if (exclusive) {\n- //remove all other popups from screen\n- for (var i = this.popups.length - 1; i >= 0; --i) {\n- this.removePopup(this.popups[i]);\n+ len = areas.length;\n+ if (areaSum === 0) {\n+ // all the components in this collection have 0 area\n+ // probably a collection of points -- weight all the points the same\n+ for (var i = 0; i < len; ++i) {\n+ areas[i] = 1;\n+ }\n+ areaSum = areas.length;\n+ } else {\n+ // normalize all the areas where the smallest area will get\n+ // a value of 1\n+ for (var i = 0; i < len; ++i) {\n+ areas[i] /= minArea;\n }\n+ areaSum /= minArea;\n }\n \n- popup.map = this;\n- this.popups.push(popup);\n- var popupDiv = popup.draw();\n- if (popupDiv) {\n- popupDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] +\n- this.popups.length;\n- this.layerContainerDiv.appendChild(popupDiv);\n+ var xSum = 0,\n+ ySum = 0,\n+ centroid, area;\n+ for (var i = 0; i < len; ++i) {\n+ centroid = centroids[i];\n+ area = areas[i];\n+ xSum += centroid.x * area;\n+ ySum += centroid.y * area;\n }\n- },\n \n- /** \n- * APIMethod: removePopup\n- * \n- * Parameters:\n- * popup - {}\n- */\n- removePopup: function(popup) {\n- OpenLayers.Util.removeItem(this.popups, popup);\n- if (popup.div) {\n- try {\n- this.layerContainerDiv.removeChild(popup.div);\n- } catch (e) {} // Popups sometimes apparently get disconnected\n- // from the layerContainerDiv, and cause complaints.\n- }\n- popup.map = null;\n+ return new OpenLayers.Geometry.Point(xSum / areaSum, ySum / areaSum);\n },\n \n- /********************************************************/\n- /* */\n- /* Container Div Functions */\n- /* */\n- /* The following functions deal with the access to */\n- /* and maintenance of the size of the container div */\n- /* */\n- /********************************************************/\n-\n /**\n- * APIMethod: getSize\n+ * APIMethod: getGeodesicLength\n+ * Calculate the approximate length of the geometry were it projected onto\n+ * the earth.\n+ *\n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n * \n * Returns:\n- * {} An object that represents the \n- * size, in pixels, of the div into which OpenLayers \n- * has been loaded. \n- * Note - A clone() of this locally cached variable is\n- * returned, so as not to allow users to modify it.\n+ * {Float} The appoximate geodesic length of the geometry in meters.\n */\n- getSize: function() {\n- var size = null;\n- if (this.size != null) {\n- size = this.size.clone();\n+ getGeodesicLength: function(projection) {\n+ var length = 0.0;\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ length += this.components[i].getGeodesicLength(projection);\n }\n- return size;\n+ return length;\n },\n \n /**\n- * APIMethod: updateSize\n- * This function should be called by any external code which dynamically\n- * changes the size of the map div (because mozilla wont let us catch \n- * the \"onresize\" for an element)\n+ * APIMethod: move\n+ * Moves a geometry by the given displacement along positive x and y axes.\n+ * This modifies the position of the geometry and clears the cached\n+ * bounds.\n+ *\n+ * Parameters:\n+ * x - {Float} Distance to move geometry in positive x direction. \n+ * y - {Float} Distance to move geometry in positive y direction.\n */\n- updateSize: function() {\n- // the div might have moved on the page, also\n- var newSize = this.getCurrentSize();\n- if (newSize && !isNaN(newSize.h) && !isNaN(newSize.w)) {\n- this.events.clearMouseCache();\n- var oldSize = this.getSize();\n- if (oldSize == null) {\n- this.size = oldSize = newSize;\n- }\n- if (!newSize.equals(oldSize)) {\n-\n- // store the new size\n- this.size = newSize;\n-\n- //notify layers of mapresize\n- for (var i = 0, len = this.layers.length; i < len; i++) {\n- this.layers[i].onMapResize();\n- }\n-\n- var center = this.getCachedCenter();\n-\n- if (this.baseLayer != null && center != null) {\n- var zoom = this.getZoom();\n- this.zoom = null;\n- this.setCenter(center, zoom);\n- }\n-\n- }\n+ move: function(x, y) {\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ this.components[i].move(x, y);\n }\n- this.events.triggerEvent(\"updatesize\");\n },\n \n /**\n- * Method: getCurrentSize\n- * \n- * Returns:\n- * {} A new object with the dimensions \n- * of the map div\n- */\n- getCurrentSize: function() {\n-\n- var size = new OpenLayers.Size(this.div.clientWidth,\n- this.div.clientHeight);\n-\n- if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {\n- size.w = this.div.offsetWidth;\n- size.h = this.div.offsetHeight;\n- }\n- if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {\n- size.w = parseInt(this.div.style.width);\n- size.h = parseInt(this.div.style.height);\n- }\n- return size;\n- },\n-\n- /** \n- * Method: calculateBounds\n- * \n+ * APIMethod: rotate\n+ * Rotate a geometry around some origin\n+ *\n * Parameters:\n- * center - {} Default is this.getCenter()\n- * resolution - {float} Default is this.getResolution() \n- * \n- * Returns:\n- * {} A bounds based on resolution, center, and \n- * current mapsize.\n+ * angle - {Float} Rotation angle in degrees (measured counterclockwise\n+ * from the positive x-axis)\n+ * origin - {} Center point for the rotation\n */\n- calculateBounds: function(center, resolution) {\n-\n- var extent = null;\n-\n- if (center == null) {\n- center = this.getCachedCenter();\n- }\n- if (resolution == null) {\n- resolution = this.getResolution();\n- }\n-\n- if ((center != null) && (resolution != null)) {\n- var halfWDeg = (this.size.w * resolution) / 2;\n- var halfHDeg = (this.size.h * resolution) / 2;\n-\n- extent = new OpenLayers.Bounds(center.lon - halfWDeg,\n- center.lat - halfHDeg,\n- center.lon + halfWDeg,\n- center.lat + halfHDeg);\n+ rotate: function(angle, origin) {\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ this.components[i].rotate(angle, origin);\n }\n-\n- return extent;\n },\n \n-\n- /********************************************************/\n- /* */\n- /* Zoom, Center, Pan Functions */\n- /* */\n- /* The following functions handle the validation, */\n- /* getting and setting of the Zoom Level and Center */\n- /* as well as the panning of the Map */\n- /* */\n- /********************************************************/\n /**\n- * APIMethod: getCenter\n+ * APIMethod: resize\n+ * Resize a geometry relative to some origin. Use this method to apply\n+ * a uniform scaling to a geometry.\n+ *\n+ * Parameters:\n+ * scale - {Float} Factor by which to scale the geometry. A scale of 2\n+ * doubles the size of the geometry in each dimension\n+ * (lines, for example, will be twice as long, and polygons\n+ * will have four times the area).\n+ * origin - {} Point of origin for resizing\n+ * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n * \n * Returns:\n- * {}\n+ * {} - The current geometry. \n */\n- getCenter: function() {\n- var center = null;\n- var cachedCenter = this.getCachedCenter();\n- if (cachedCenter) {\n- center = cachedCenter.clone();\n+ resize: function(scale, origin, ratio) {\n+ for (var i = 0; i < this.components.length; ++i) {\n+ this.components[i].resize(scale, origin, ratio);\n }\n- return center;\n+ return this;\n },\n \n /**\n- * Method: getCachedCenter\n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n *\n- * Returns:\n- * {}\n- */\n- getCachedCenter: function() {\n- if (!this.center && this.size) {\n- this.center = this.getLonLatFromViewPortPx({\n- x: this.size.w / 2,\n- y: this.size.h / 2\n- });\n- }\n- return this.center;\n- },\n-\n- /**\n- * APIMethod: getZoom\n- * \n- * Returns:\n- * {Integer}\n- */\n- getZoom: function() {\n- return this.zoom;\n- },\n-\n- /** \n- * APIMethod: pan\n- * Allows user to pan by a value of screen pixels\n- * \n * Parameters:\n- * dx - {Integer}\n- * dy - {Integer}\n- * options - {Object} Options to configure panning:\n- * - *animate* {Boolean} Use panTo instead of setCenter. Default is true.\n- * - *dragging* {Boolean} Call setCenter with dragging true. Default is\n- * false.\n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n+ *\n+ * Returns:\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and y1 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- pan: function(dx, dy, options) {\n- options = OpenLayers.Util.applyDefaults(options, {\n- animate: true,\n- dragging: false\n- });\n- if (options.dragging) {\n- if (dx != 0 || dy != 0) {\n- this.moveByPx(dx, dy);\n- }\n- } else {\n- // getCenter\n- var centerPx = this.getViewPortPxFromLonLat(this.getCachedCenter());\n-\n- // adjust\n- var newCenterPx = centerPx.add(dx, dy);\n-\n- if (this.dragging || !newCenterPx.equals(centerPx)) {\n- var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx);\n- if (options.animate) {\n- this.panTo(newCenterLonLat);\n- } else {\n- this.moveTo(newCenterLonLat);\n- if (this.dragging) {\n- this.dragging = false;\n- this.events.triggerEvent(\"moveend\");\n- }\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var details = edge && options && options.details;\n+ var result, best, distance;\n+ var min = Number.POSITIVE_INFINITY;\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ result = this.components[i].distanceTo(geometry, options);\n+ distance = details ? result.distance : result;\n+ if (distance < min) {\n+ min = distance;\n+ best = result;\n+ if (min == 0) {\n+ break;\n }\n }\n }\n-\n+ return best;\n },\n \n /** \n- * APIMethod: panTo\n- * Allows user to pan to a new lonlat\n- * If the new lonlat is in the current extent the map will slide smoothly\n+ * APIMethod: equals\n+ * Determine whether another geometry is equivalent to this one. Geometries\n+ * are considered equivalent if all components have the same coordinates.\n * \n * Parameters:\n- * lonlat - {}\n+ * geometry - {} The geometry to test. \n+ *\n+ * Returns:\n+ * {Boolean} The supplied geometry is equivalent to this geometry.\n */\n- panTo: function(lonlat) {\n- if (this.panTween && this.getExtent().scale(this.panRatio).containsLonLat(lonlat)) {\n- var center = this.getCachedCenter();\n-\n- // center will not change, don't do nothing\n- if (lonlat.equals(center)) {\n- return;\n- }\n-\n- var from = this.getPixelFromLonLat(center);\n- var to = this.getPixelFromLonLat(lonlat);\n- var vector = {\n- x: to.x - from.x,\n- y: to.y - from.y\n- };\n- var last = {\n- x: 0,\n- y: 0\n- };\n-\n- this.panTween.start({\n- x: 0,\n- y: 0\n- }, vector, this.panDuration, {\n- callbacks: {\n- eachStep: OpenLayers.Function.bind(function(px) {\n- var x = px.x - last.x,\n- y = px.y - last.y;\n- this.moveByPx(x, y);\n- last.x = Math.round(px.x);\n- last.y = Math.round(px.y);\n- }, this),\n- done: OpenLayers.Function.bind(function(px) {\n- this.moveTo(lonlat);\n- this.dragging = false;\n- this.events.triggerEvent(\"moveend\");\n- }, this)\n- }\n- });\n+ equals: function(geometry) {\n+ var equivalent = true;\n+ if (!geometry || !geometry.CLASS_NAME ||\n+ (this.CLASS_NAME != geometry.CLASS_NAME)) {\n+ equivalent = false;\n+ } else if (!(OpenLayers.Util.isArray(geometry.components)) ||\n+ (geometry.components.length != this.components.length)) {\n+ equivalent = false;\n } else {\n- this.setCenter(lonlat);\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ if (!this.components[i].equals(geometry.components[i])) {\n+ equivalent = false;\n+ break;\n+ }\n+ }\n }\n+ return equivalent;\n },\n \n /**\n- * APIMethod: setCenter\n- * Set the map center (and optionally, the zoom level).\n+ * APIMethod: transform\n+ * Reproject the components geometry from source to dest.\n * \n * Parameters:\n- * lonlat - {|Array} The new center location.\n- * If provided as array, the first value is the x coordinate,\n- * and the 2nd value is the y coordinate.\n- * zoom - {Integer} Optional zoom level.\n- * dragging - {Boolean} Specifies whether or not to trigger \n- * movestart/end events\n- * forceZoomChange - {Boolean} Specifies whether or not to trigger zoom \n- * change events (needed on baseLayer change)\n- *\n- * TBD: reconsider forceZoomChange in 3.0\n- */\n- setCenter: function(lonlat, zoom, dragging, forceZoomChange) {\n- if (this.panTween) {\n- this.panTween.stop();\n- }\n- if (this.zoomTween) {\n- this.zoomTween.stop();\n- }\n- this.moveTo(lonlat, zoom, {\n- 'dragging': dragging,\n- 'forceZoomChange': forceZoomChange\n- });\n- },\n-\n- /** \n- * Method: moveByPx\n- * Drag the map by pixels.\n- *\n- * Parameters:\n- * dx - {Number}\n- * dy - {Number}\n+ * source - {} \n+ * dest - {}\n+ * \n+ * Returns:\n+ * {} \n */\n- moveByPx: function(dx, dy) {\n- var hw = this.size.w / 2;\n- var hh = this.size.h / 2;\n- var x = hw + dx;\n- var y = hh + dy;\n- var wrapDateLine = this.baseLayer.wrapDateLine;\n- var xRestriction = 0;\n- var yRestriction = 0;\n- if (this.restrictedExtent) {\n- xRestriction = hw;\n- yRestriction = hh;\n- // wrapping the date line makes no sense for restricted extents\n- wrapDateLine = false;\n- }\n- dx = wrapDateLine ||\n- x <= this.maxPx.x - xRestriction &&\n- x >= this.minPx.x + xRestriction ? Math.round(dx) : 0;\n- dy = y <= this.maxPx.y - yRestriction &&\n- y >= this.minPx.y + yRestriction ? Math.round(dy) : 0;\n- if (dx || dy) {\n- if (!this.dragging) {\n- this.dragging = true;\n- this.events.triggerEvent(\"movestart\");\n- }\n- this.center = null;\n- if (dx) {\n- this.layerContainerOriginPx.x -= dx;\n- this.minPx.x -= dx;\n- this.maxPx.x -= dx;\n- }\n- if (dy) {\n- this.layerContainerOriginPx.y -= dy;\n- this.minPx.y -= dy;\n- this.maxPx.y -= dy;\n- }\n- this.applyTransform();\n- var layer, i, len;\n- for (i = 0, len = this.layers.length; i < len; ++i) {\n- layer = this.layers[i];\n- if (layer.visibility &&\n- (layer === this.baseLayer || layer.inRange)) {\n- layer.moveByPx(dx, dy);\n- layer.events.triggerEvent(\"move\");\n- }\n+ transform: function(source, dest) {\n+ if (source && dest) {\n+ for (var i = 0, len = this.components.length; i < len; i++) {\n+ var component = this.components[i];\n+ component.transform(source, dest);\n }\n- this.events.triggerEvent(\"move\");\n+ this.bounds = null;\n }\n+ return this;\n },\n \n /**\n- * Method: adjustZoom\n+ * APIMethod: intersects\n+ * Determine if the input geometry intersects this one.\n *\n * Parameters:\n- * zoom - {Number} The zoom level to adjust\n+ * geometry - {} Any type of geometry.\n *\n * Returns:\n- * {Integer} Adjusted zoom level that shows a map not wider than its\n- * 's maxExtent.\n+ * {Boolean} The input geometry intersects this one.\n */\n- adjustZoom: function(zoom) {\n- if (this.baseLayer && this.baseLayer.wrapDateLine) {\n- var resolution, resolutions = this.baseLayer.resolutions,\n- maxResolution = this.getMaxExtent().getWidth() / this.size.w;\n- if (this.getResolutionForZoom(zoom) > maxResolution) {\n- if (this.fractionalZoom) {\n- zoom = this.getZoomForResolution(maxResolution);\n- } else {\n- for (var i = zoom | 0, ii = resolutions.length; i < ii; ++i) {\n- if (resolutions[i] <= maxResolution) {\n- zoom = i;\n- break;\n- }\n- }\n- }\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ intersect = geometry.intersects(this.components[i]);\n+ if (intersect) {\n+ break;\n }\n }\n- return zoom;\n- },\n-\n- /**\n- * APIMethod: getMinZoom\n- * Returns the minimum zoom level for the current map view. If the base\n- * layer is configured with set to true, this will be the\n- * first zoom level that shows no more than one world width in the current\n- * map viewport. Components that rely on this value (e.g. zoom sliders)\n- * should also listen to the map's \"updatesize\" event and call this method\n- * in the \"updatesize\" listener.\n- *\n- * Returns:\n- * {Number} Minimum zoom level that shows a map not wider than its\n- * 's maxExtent. This is an Integer value, unless the map is\n- * configured with set to true.\n- */\n- getMinZoom: function() {\n- return this.adjustZoom(0);\n+ return intersect;\n },\n \n /**\n- * Method: moveTo\n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n *\n * Parameters:\n- * lonlat - {}\n- * zoom - {Integer}\n- * options - {Object}\n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n+ *\n+ * Returns:\n+ * {Array} A list of all vertices in the geometry.\n */\n- moveTo: function(lonlat, zoom, options) {\n- if (lonlat != null && !(lonlat instanceof OpenLayers.LonLat)) {\n- lonlat = new OpenLayers.LonLat(lonlat);\n- }\n- if (!options) {\n- options = {};\n- }\n- if (zoom != null) {\n- zoom = parseFloat(zoom);\n- if (!this.fractionalZoom) {\n- zoom = Math.round(zoom);\n- }\n- }\n- var requestedZoom = zoom;\n- zoom = this.adjustZoom(zoom);\n- if (zoom !== requestedZoom) {\n- // zoom was adjusted, so keep old lonlat to avoid panning\n- lonlat = this.getCenter();\n- }\n- // dragging is false by default\n- var dragging = options.dragging || this.dragging;\n- // forceZoomChange is false by default\n- var forceZoomChange = options.forceZoomChange;\n-\n- if (!this.getCachedCenter() && !this.isValidLonLat(lonlat)) {\n- lonlat = this.maxExtent.getCenterLonLat();\n- this.center = lonlat.clone();\n- }\n-\n- if (this.restrictedExtent != null) {\n- // In 3.0, decide if we want to change interpretation of maxExtent.\n- if (lonlat == null) {\n- lonlat = this.center;\n- }\n- if (zoom == null) {\n- zoom = this.getZoom();\n- }\n- var resolution = this.getResolutionForZoom(zoom);\n- var extent = this.calculateBounds(lonlat, resolution);\n- if (!this.restrictedExtent.containsBounds(extent)) {\n- var maxCenter = this.restrictedExtent.getCenterLonLat();\n- if (extent.getWidth() > this.restrictedExtent.getWidth()) {\n- lonlat = new OpenLayers.LonLat(maxCenter.lon, lonlat.lat);\n- } else if (extent.left < this.restrictedExtent.left) {\n- lonlat = lonlat.add(this.restrictedExtent.left -\n- extent.left, 0);\n- } else if (extent.right > this.restrictedExtent.right) {\n- lonlat = lonlat.add(this.restrictedExtent.right -\n- extent.right, 0);\n- }\n- if (extent.getHeight() > this.restrictedExtent.getHeight()) {\n- lonlat = new OpenLayers.LonLat(lonlat.lon, maxCenter.lat);\n- } else if (extent.bottom < this.restrictedExtent.bottom) {\n- lonlat = lonlat.add(0, this.restrictedExtent.bottom -\n- extent.bottom);\n- } else if (extent.top > this.restrictedExtent.top) {\n- lonlat = lonlat.add(0, this.restrictedExtent.top -\n- extent.top);\n- }\n- }\n+ getVertices: function(nodes) {\n+ var vertices = [];\n+ for (var i = 0, len = this.components.length; i < len; ++i) {\n+ Array.prototype.push.apply(\n+ vertices, this.components[i].getVertices(nodes)\n+ );\n }\n+ return vertices;\n+ },\n \n- var zoomChanged = forceZoomChange || (\n- (this.isValidZoomLevel(zoom)) &&\n- (zoom != this.getZoom()));\n \n- var centerChanged = (this.isValidLonLat(lonlat)) &&\n- (!lonlat.equals(this.center));\n+ CLASS_NAME: \"OpenLayers.Geometry.Collection\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/MultiPoint.js\n+ ====================================================================== */\n \n- // if neither center nor zoom will change, no need to do anything\n- if (zoomChanged || centerChanged || dragging) {\n- dragging || this.events.triggerEvent(\"movestart\", {\n- zoomChanged: zoomChanged\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- if (centerChanged) {\n- if (!zoomChanged && this.center) {\n- // if zoom hasnt changed, just slide layerContainer\n- // (must be done before setting this.center to new value)\n- this.centerLayerContainer(lonlat);\n- }\n- this.center = lonlat.clone();\n- }\n+/**\n+ * @requires OpenLayers/Geometry/Collection.js\n+ * @requires OpenLayers/Geometry/Point.js\n+ */\n \n- var res = zoomChanged ?\n- this.getResolutionForZoom(zoom) : this.getResolution();\n- // (re)set the layerContainerDiv's location\n- if (zoomChanged || this.layerContainerOrigin == null) {\n- this.layerContainerOrigin = this.getCachedCenter();\n- this.layerContainerOriginPx.x = 0;\n- this.layerContainerOriginPx.y = 0;\n- this.applyTransform();\n- var maxExtent = this.getMaxExtent({\n- restricted: true\n- });\n- var maxExtentCenter = maxExtent.getCenterLonLat();\n- var lonDelta = this.center.lon - maxExtentCenter.lon;\n- var latDelta = maxExtentCenter.lat - this.center.lat;\n- var extentWidth = Math.round(maxExtent.getWidth() / res);\n- var extentHeight = Math.round(maxExtent.getHeight() / res);\n- this.minPx = {\n- x: (this.size.w - extentWidth) / 2 - lonDelta / res,\n- y: (this.size.h - extentHeight) / 2 - latDelta / res\n- };\n- this.maxPx = {\n- x: this.minPx.x + Math.round(maxExtent.getWidth() / res),\n- y: this.minPx.y + Math.round(maxExtent.getHeight() / res)\n- };\n- }\n+/**\n+ * Class: OpenLayers.Geometry.MultiPoint\n+ * MultiPoint is a collection of Points. Create a new instance with the\n+ * constructor.\n+ *\n+ * Inherits from:\n+ * - \n+ * - \n+ */\n+OpenLayers.Geometry.MultiPoint = OpenLayers.Class(\n+ OpenLayers.Geometry.Collection, {\n \n- if (zoomChanged) {\n- this.zoom = zoom;\n- this.resolution = res;\n- }\n+ /**\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of\n+ * components that the collection can include. A null value means the\n+ * component types are not restricted.\n+ */\n+ componentTypes: [\"OpenLayers.Geometry.Point\"],\n \n- var bounds = this.getExtent();\n+ /**\n+ * Constructor: OpenLayers.Geometry.MultiPoint\n+ * Create a new MultiPoint Geometry\n+ *\n+ * Parameters:\n+ * components - {Array()} \n+ *\n+ * Returns:\n+ * {}\n+ */\n \n- //send the move call to the baselayer and all the overlays \n+ /**\n+ * APIMethod: addPoint\n+ * Wrapper for \n+ *\n+ * Parameters:\n+ * point - {} Point to be added\n+ * index - {Integer} Optional index\n+ */\n+ addPoint: function(point, index) {\n+ this.addComponent(point, index);\n+ },\n \n- if (this.baseLayer.visibility) {\n- this.baseLayer.moveTo(bounds, zoomChanged, options.dragging);\n- options.dragging || this.baseLayer.events.triggerEvent(\n- \"moveend\", {\n- zoomChanged: zoomChanged\n- }\n- );\n- }\n+ /**\n+ * APIMethod: removePoint\n+ * Wrapper for \n+ *\n+ * Parameters:\n+ * point - {} Point to be removed\n+ */\n+ removePoint: function(point) {\n+ this.removeComponent(point);\n+ },\n \n- bounds = this.baseLayer.getExtent();\n+ CLASS_NAME: \"OpenLayers.Geometry.MultiPoint\"\n+ });\n+/* ======================================================================\n+ OpenLayers/Geometry/Curve.js\n+ ====================================================================== */\n \n- for (var i = this.layers.length - 1; i >= 0; --i) {\n- var layer = this.layers[i];\n- if (layer !== this.baseLayer && !layer.isBaseLayer) {\n- var inRange = layer.calculateInRange();\n- if (layer.inRange != inRange) {\n- // the inRange property has changed. If the layer is\n- // no longer in range, we turn it off right away. If\n- // the layer is no longer out of range, the moveTo\n- // call below will turn on the layer.\n- layer.inRange = inRange;\n- if (!inRange) {\n- layer.display(false);\n- }\n- this.events.triggerEvent(\"changelayer\", {\n- layer: layer,\n- property: \"visibility\"\n- });\n- }\n- if (inRange && layer.visibility) {\n- layer.moveTo(bounds, zoomChanged, options.dragging);\n- options.dragging || layer.events.triggerEvent(\n- \"moveend\", {\n- zoomChanged: zoomChanged\n- }\n- );\n- }\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- this.events.triggerEvent(\"move\");\n- dragging || this.events.triggerEvent(\"moveend\");\n+/**\n+ * @requires OpenLayers/Geometry/MultiPoint.js\n+ */\n \n- if (zoomChanged) {\n- //redraw popups\n- for (var i = 0, len = this.popups.length; i < len; i++) {\n- this.popups[i].updatePosition();\n- }\n- this.events.triggerEvent(\"zoomend\");\n- }\n- }\n- },\n+/**\n+ * Class: OpenLayers.Geometry.Curve\n+ * A Curve is a MultiPoint, whose points are assumed to be connected. To \n+ * this end, we provide a \"getLength()\" function, which iterates through \n+ * the points, summing the distances between them. \n+ * \n+ * Inherits: \n+ * - \n+ */\n+OpenLayers.Geometry.Curve = OpenLayers.Class(OpenLayers.Geometry.MultiPoint, {\n \n- /** \n- * Method: centerLayerContainer\n- * This function takes care to recenter the layerContainerDiv.\n- * \n- * Parameters:\n- * lonlat - {}\n+ /**\n+ * Property: componentTypes\n+ * {Array(String)} An array of class names representing the types of \n+ * components that the collection can include. A null \n+ * value means the component types are not restricted.\n */\n- centerLayerContainer: function(lonlat) {\n- var originPx = this.getViewPortPxFromLonLat(this.layerContainerOrigin);\n- var newPx = this.getViewPortPxFromLonLat(lonlat);\n-\n- if ((originPx != null) && (newPx != null)) {\n- var oldLeft = this.layerContainerOriginPx.x;\n- var oldTop = this.layerContainerOriginPx.y;\n- var newLeft = Math.round(originPx.x - newPx.x);\n- var newTop = Math.round(originPx.y - newPx.y);\n- this.applyTransform(\n- (this.layerContainerOriginPx.x = newLeft),\n- (this.layerContainerOriginPx.y = newTop));\n- var dx = oldLeft - newLeft;\n- var dy = oldTop - newTop;\n- this.minPx.x -= dx;\n- this.maxPx.x -= dx;\n- this.minPx.y -= dy;\n- this.maxPx.y -= dy;\n- }\n- },\n+ componentTypes: [\"OpenLayers.Geometry.Point\"],\n \n /**\n- * Method: isValidZoomLevel\n+ * Constructor: OpenLayers.Geometry.Curve\n * \n * Parameters:\n- * zoomLevel - {Integer}\n- * \n- * Returns:\n- * {Boolean} Whether or not the zoom level passed in is non-null and \n- * within the min/max range of zoom levels.\n+ * point - {Array()}\n */\n- isValidZoomLevel: function(zoomLevel) {\n- return ((zoomLevel != null) &&\n- (zoomLevel >= 0) &&\n- (zoomLevel < this.getNumZoomLevels()));\n- },\n \n /**\n- * Method: isValidLonLat\n- * \n- * Parameters:\n- * lonlat - {}\n+ * APIMethod: getLength\n * \n * Returns:\n- * {Boolean} Whether or not the lonlat passed in is non-null and within\n- * the maxExtent bounds\n+ * {Float} The length of the curve\n */\n- isValidLonLat: function(lonlat) {\n- var valid = false;\n- if (lonlat != null) {\n- var maxExtent = this.getMaxExtent();\n- var worldBounds = this.baseLayer.wrapDateLine && maxExtent;\n- valid = maxExtent.containsLonLat(lonlat, {\n- worldBounds: worldBounds\n- });\n+ getLength: function() {\n+ var length = 0.0;\n+ if (this.components && (this.components.length > 1)) {\n+ for (var i = 1, len = this.components.length; i < len; i++) {\n+ length += this.components[i - 1].distanceTo(this.components[i]);\n+ }\n }\n- return valid;\n+ return length;\n },\n \n- /********************************************************/\n- /* */\n- /* Layer Options */\n- /* */\n- /* Accessor functions to Layer Options parameters */\n- /* */\n- /********************************************************/\n-\n /**\n- * APIMethod: getProjection\n- * This method returns a string representing the projection. In \n- * the case of projection support, this will be the srsCode which\n- * is loaded -- otherwise it will simply be the string value that\n- * was passed to the projection at startup.\n+ * APIMethod: getGeodesicLength\n+ * Calculate the approximate length of the geometry were it projected onto\n+ * the earth.\n *\n- * FIXME: In 3.0, we will remove getProjectionObject, and instead\n- * return a Projection object from this function. \n+ * projection - {} The spatial reference system\n+ * for the geometry coordinates. If not provided, Geographic/WGS84 is\n+ * assumed.\n * \n * Returns:\n- * {String} The Projection string from the base layer or null. \n- */\n- getProjection: function() {\n- var projection = this.getProjectionObject();\n- return projection ? projection.getCode() : null;\n- },\n-\n- /**\n- * APIMethod: getProjectionObject\n- * Returns the projection obect from the baselayer.\n- *\n- * Returns:\n- * {} The Projection of the base layer.\n+ * {Float} The appoximate geodesic length of the geometry in meters.\n */\n- getProjectionObject: function() {\n- var projection = null;\n- if (this.baseLayer != null) {\n- projection = this.baseLayer.projection;\n+ getGeodesicLength: function(projection) {\n+ var geom = this; // so we can work with a clone if needed\n+ if (projection) {\n+ var gg = new OpenLayers.Projection(\"EPSG:4326\");\n+ if (!gg.equals(projection)) {\n+ geom = this.clone().transform(projection, gg);\n+ }\n }\n- return projection;\n- },\n-\n- /**\n- * APIMethod: getMaxResolution\n- * \n- * Returns:\n- * {String} The Map's Maximum Resolution\n- */\n- getMaxResolution: function() {\n- var maxResolution = null;\n- if (this.baseLayer != null) {\n- maxResolution = this.baseLayer.maxResolution;\n+ var length = 0.0;\n+ if (geom.components && (geom.components.length > 1)) {\n+ var p1, p2;\n+ for (var i = 1, len = geom.components.length; i < len; i++) {\n+ p1 = geom.components[i - 1];\n+ p2 = geom.components[i];\n+ // this returns km and requires lon/lat properties\n+ length += OpenLayers.Util.distVincenty({\n+ lon: p1.x,\n+ lat: p1.y\n+ }, {\n+ lon: p2.x,\n+ lat: p2.y\n+ });\n+ }\n }\n- return maxResolution;\n+ // convert to m\n+ return length * 1000;\n },\n \n+ CLASS_NAME: \"OpenLayers.Geometry.Curve\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/LineString.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/Geometry/Curve.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Geometry.LineString\n+ * A LineString is a Curve which, once two points have been added to it, can \n+ * never be less than two points long.\n+ * \n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {\n+\n /**\n- * APIMethod: getMaxExtent\n+ * Constructor: OpenLayers.Geometry.LineString\n+ * Create a new LineString geometry\n *\n * Parameters:\n- * options - {Object} \n- * \n- * Allowed Options:\n- * restricted - {Boolean} If true, returns restricted extent (if it is \n- * available.)\n+ * points - {Array()} An array of points used to\n+ * generate the linestring\n *\n- * Returns:\n- * {} The maxExtent property as set on the current \n- * baselayer, unless the 'restricted' option is set, in which case\n- * the 'restrictedExtent' option from the map is returned (if it\n- * is set).\n */\n- getMaxExtent: function(options) {\n- var maxExtent = null;\n- if (options && options.restricted && this.restrictedExtent) {\n- maxExtent = this.restrictedExtent;\n- } else if (this.baseLayer != null) {\n- maxExtent = this.baseLayer.maxExtent;\n- }\n- return maxExtent;\n- },\n \n /**\n- * APIMethod: getNumZoomLevels\n- * \n- * Returns:\n- * {Integer} The total number of zoom levels that can be displayed by the \n- * current baseLayer.\n+ * APIMethod: removeComponent\n+ * Only allows removal of a point if there are three or more points in \n+ * the linestring. (otherwise the result would be just a single point)\n+ *\n+ * Parameters: \n+ * point - {} The point to be removed\n+ *\n+ * Returns: \n+ * {Boolean} The component was removed.\n */\n- getNumZoomLevels: function() {\n- var numZoomLevels = null;\n- if (this.baseLayer != null) {\n- numZoomLevels = this.baseLayer.numZoomLevels;\n+ removeComponent: function(point) {\n+ var removed = this.components && (this.components.length > 2);\n+ if (removed) {\n+ OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,\n+ arguments);\n }\n- return numZoomLevels;\n+ return removed;\n },\n \n- /********************************************************/\n- /* */\n- /* Baselayer Functions */\n- /* */\n- /* The following functions, all publicly exposed */\n- /* in the API?, are all merely wrappers to the */\n- /* the same calls on whatever layer is set as */\n- /* the current base layer */\n- /* */\n- /********************************************************/\n-\n /**\n- * APIMethod: getExtent\n- * \n+ * APIMethod: intersects\n+ * Test for instersection between two geometries. This is a cheapo\n+ * implementation of the Bently-Ottmann algorigithm. It doesn't\n+ * really keep track of a sweep line data structure. It is closer\n+ * to the brute force method, except that segments are sorted and\n+ * potential intersections are only calculated when bounding boxes\n+ * intersect.\n+ *\n+ * Parameters:\n+ * geometry - {}\n+ *\n * Returns:\n- * {} A Bounds object which represents the lon/lat \n- * bounds of the current viewPort. \n- * If no baselayer is set, returns null.\n+ * {Boolean} The input geometry intersects this geometry.\n */\n- getExtent: function() {\n- var extent = null;\n- if (this.baseLayer != null) {\n- extent = this.baseLayer.getExtent();\n+ intersects: function(geometry) {\n+ var intersect = false;\n+ var type = geometry.CLASS_NAME;\n+ if (type == \"OpenLayers.Geometry.LineString\" ||\n+ type == \"OpenLayers.Geometry.LinearRing\" ||\n+ type == \"OpenLayers.Geometry.Point\") {\n+ var segs1 = this.getSortedSegments();\n+ var segs2;\n+ if (type == \"OpenLayers.Geometry.Point\") {\n+ segs2 = [{\n+ x1: geometry.x,\n+ y1: geometry.y,\n+ x2: geometry.x,\n+ y2: geometry.y\n+ }];\n+ } else {\n+ segs2 = geometry.getSortedSegments();\n+ }\n+ var seg1, seg1x1, seg1x2, seg1y1, seg1y2,\n+ seg2, seg2y1, seg2y2;\n+ // sweep right\n+ outer: for (var i = 0, len = segs1.length; i < len; ++i) {\n+ seg1 = segs1[i];\n+ seg1x1 = seg1.x1;\n+ seg1x2 = seg1.x2;\n+ seg1y1 = seg1.y1;\n+ seg1y2 = seg1.y2;\n+ inner: for (var j = 0, jlen = segs2.length; j < jlen; ++j) {\n+ seg2 = segs2[j];\n+ if (seg2.x1 > seg1x2) {\n+ // seg1 still left of seg2\n+ break;\n+ }\n+ if (seg2.x2 < seg1x1) {\n+ // seg2 still left of seg1\n+ continue;\n+ }\n+ seg2y1 = seg2.y1;\n+ seg2y2 = seg2.y2;\n+ if (Math.min(seg2y1, seg2y2) > Math.max(seg1y1, seg1y2)) {\n+ // seg2 above seg1\n+ continue;\n+ }\n+ if (Math.max(seg2y1, seg2y2) < Math.min(seg1y1, seg1y2)) {\n+ // seg2 below seg1\n+ continue;\n+ }\n+ if (OpenLayers.Geometry.segmentsIntersect(seg1, seg2)) {\n+ intersect = true;\n+ break outer;\n+ }\n+ }\n+ }\n+ } else {\n+ intersect = geometry.intersects(this);\n }\n- return extent;\n+ return intersect;\n },\n \n /**\n- * APIMethod: getResolution\n- * \n+ * Method: getSortedSegments\n+ *\n * Returns:\n- * {Float} The current resolution of the map. \n- * If no baselayer is set, returns null.\n+ * {Array} An array of segment objects. Segment objects have properties\n+ * x1, y1, x2, and y2. The start point is represented by x1 and y1.\n+ * The end point is represented by x2 and y2. Start and end are\n+ * ordered so that x1 < x2.\n */\n- getResolution: function() {\n- var resolution = null;\n- if (this.baseLayer != null) {\n- resolution = this.baseLayer.getResolution();\n- } else if (this.allOverlays === true && this.layers.length > 0) {\n- // while adding the 1st layer to the map in allOverlays mode,\n- // this.baseLayer is not set yet when we need the resolution\n- // for calculateInRange.\n- resolution = this.layers[0].getResolution();\n+ getSortedSegments: function() {\n+ var numSeg = this.components.length - 1;\n+ var segments = new Array(numSeg),\n+ point1, point2;\n+ for (var i = 0; i < numSeg; ++i) {\n+ point1 = this.components[i];\n+ point2 = this.components[i + 1];\n+ if (point1.x < point2.x) {\n+ segments[i] = {\n+ x1: point1.x,\n+ y1: point1.y,\n+ x2: point2.x,\n+ y2: point2.y\n+ };\n+ } else {\n+ segments[i] = {\n+ x1: point2.x,\n+ y1: point2.y,\n+ x2: point1.x,\n+ y2: point1.y\n+ };\n+ }\n }\n- return resolution;\n- },\n-\n- /**\n- * APIMethod: getUnits\n- * \n- * Returns:\n- * {Float} The current units of the map. \n- * If no baselayer is set, returns null.\n- */\n- getUnits: function() {\n- var units = null;\n- if (this.baseLayer != null) {\n- units = this.baseLayer.units;\n+ // more efficient to define this somewhere static\n+ function byX1(seg1, seg2) {\n+ return seg1.x1 - seg2.x1;\n }\n- return units;\n+ return segments.sort(byX1);\n },\n \n /**\n- * APIMethod: getScale\n- * \n+ * Method: splitWithSegment\n+ * Split this geometry with the given segment.\n+ *\n+ * Parameters:\n+ * seg - {Object} An object with x1, y1, x2, and y2 properties referencing\n+ * segment endpoint coordinates.\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n+ *\n+ * Valid options:\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source segment must be within the\n+ * tolerance distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of one of the source segment's\n+ * endpoints will be assumed to occur at the endpoint.\n+ *\n * Returns:\n- * {Float} The current scale denominator of the map. \n- * If no baselayer is set, returns null.\n+ * {Object} An object with *lines* and *points* properties. If the given\n+ * segment intersects this linestring, the lines array will reference\n+ * geometries that result from the split. The points array will contain\n+ * all intersection points. Intersection points are sorted along the\n+ * segment (in order from x1,y1 to x2,y2).\n */\n- getScale: function() {\n- var scale = null;\n- if (this.baseLayer != null) {\n- var res = this.getResolution();\n- var units = this.baseLayer.units;\n- scale = OpenLayers.Util.getScaleFromResolution(res, units);\n+ splitWithSegment: function(seg, options) {\n+ var edge = !(options && options.edge === false);\n+ var tolerance = options && options.tolerance;\n+ var lines = [];\n+ var verts = this.getVertices();\n+ var points = [];\n+ var intersections = [];\n+ var split = false;\n+ var vert1, vert2, point;\n+ var node, vertex, target;\n+ var interOptions = {\n+ point: true,\n+ tolerance: tolerance\n+ };\n+ var result = null;\n+ for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n+ vert1 = verts[i];\n+ points.push(vert1.clone());\n+ vert2 = verts[i + 1];\n+ target = {\n+ x1: vert1.x,\n+ y1: vert1.y,\n+ x2: vert2.x,\n+ y2: vert2.y\n+ };\n+ point = OpenLayers.Geometry.segmentsIntersect(\n+ seg, target, interOptions\n+ );\n+ if (point instanceof OpenLayers.Geometry.Point) {\n+ if ((point.x === seg.x1 && point.y === seg.y1) ||\n+ (point.x === seg.x2 && point.y === seg.y2) ||\n+ point.equals(vert1) || point.equals(vert2)) {\n+ vertex = true;\n+ } else {\n+ vertex = false;\n+ }\n+ if (vertex || edge) {\n+ // push intersections different than the previous\n+ if (!point.equals(intersections[intersections.length - 1])) {\n+ intersections.push(point.clone());\n+ }\n+ if (i === 0) {\n+ if (point.equals(vert1)) {\n+ continue;\n+ }\n+ }\n+ if (point.equals(vert2)) {\n+ continue;\n+ }\n+ split = true;\n+ if (!point.equals(vert1)) {\n+ points.push(point);\n+ }\n+ lines.push(new OpenLayers.Geometry.LineString(points));\n+ points = [point.clone()];\n+ }\n+ }\n }\n- return scale;\n- },\n-\n-\n- /**\n- * APIMethod: getZoomForExtent\n- * \n- * Parameters: \n- * bounds - {}\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} A suitable zoom level for the specified bounds.\n- * If no baselayer is set, returns null.\n- */\n- getZoomForExtent: function(bounds, closest) {\n- var zoom = null;\n- if (this.baseLayer != null) {\n- zoom = this.baseLayer.getZoomForExtent(bounds, closest);\n+ if (split) {\n+ points.push(vert2.clone());\n+ lines.push(new OpenLayers.Geometry.LineString(points));\n }\n- return zoom;\n- },\n-\n- /**\n- * APIMethod: getResolutionForZoom\n- * \n- * Parameters:\n- * zoom - {Float}\n- * \n- * Returns:\n- * {Float} A suitable resolution for the specified zoom. If no baselayer\n- * is set, returns null.\n- */\n- getResolutionForZoom: function(zoom) {\n- var resolution = null;\n- if (this.baseLayer) {\n- resolution = this.baseLayer.getResolutionForZoom(zoom);\n+ if (intersections.length > 0) {\n+ // sort intersections along segment\n+ var xDir = seg.x1 < seg.x2 ? 1 : -1;\n+ var yDir = seg.y1 < seg.y2 ? 1 : -1;\n+ result = {\n+ lines: lines,\n+ points: intersections.sort(function(p1, p2) {\n+ return (xDir * p1.x - xDir * p2.x) || (yDir * p1.y - yDir * p2.y);\n+ })\n+ };\n }\n- return resolution;\n+ return result;\n },\n \n /**\n- * APIMethod: getZoomForResolution\n+ * Method: split\n+ * Use this geometry (the source) to attempt to split a target geometry.\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+ * target - {} The target geometry.\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n+ *\n+ * Valid options:\n+ * mutual - {Boolean} Split the source geometry in addition to the target\n+ * geometry. Default is false.\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source must be within the tolerance\n+ * distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of an existing vertex on the source\n+ * will be assumed to occur at the vertex.\n * \n * Returns:\n- * {Integer} A suitable zoom level for the specified resolution.\n- * If no baselayer is set, returns null.\n- */\n- getZoomForResolution: function(resolution, closest) {\n- var zoom = null;\n- if (this.baseLayer != null) {\n- zoom = this.baseLayer.getZoomForResolution(resolution, closest);\n- }\n- return zoom;\n- },\n-\n- /********************************************************/\n- /* */\n- /* Zooming Functions */\n- /* */\n- /* The following functions, all publicly exposed */\n- /* in the API, are all merely wrappers to the */\n- /* the setCenter() function */\n- /* */\n- /********************************************************/\n-\n- /** \n- * APIMethod: zoomTo\n- * Zoom to a specific zoom level. Zooming will be animated unless the map\n- * is configured with {zoomMethod: null}. To zoom without animation, use\n- * without a lonlat argument.\n- * \n- * Parameters:\n- * zoom - {Integer}\n+ * {Array} A list of geometries (of this same type as the target) that\n+ * result from splitting the target with the source geometry. The\n+ * source and target geometry will remain unmodified. If no split\n+ * results, null will be returned. If mutual is true and a split\n+ * results, return will be an array of two arrays - the first will be\n+ * all geometries that result from splitting the source geometry and\n+ * the second will be all geometries that result from splitting the\n+ * target geometry.\n */\n- zoomTo: function(zoom, xy) {\n- // non-API arguments:\n- // xy - {} optional zoom origin\n-\n- var map = this;\n- if (map.isValidZoomLevel(zoom)) {\n- if (map.baseLayer.wrapDateLine) {\n- zoom = map.adjustZoom(zoom);\n- }\n- if (map.zoomTween) {\n- var currentRes = map.getResolution(),\n- targetRes = map.getResolutionForZoom(zoom),\n- start = {\n- scale: 1\n- },\n- end = {\n- scale: currentRes / targetRes\n- };\n- if (map.zoomTween.playing && map.zoomTween.duration < 3 * map.zoomDuration) {\n- // update the end scale, and reuse the running zoomTween\n- map.zoomTween.finish = {\n- scale: map.zoomTween.finish.scale * end.scale\n- };\n- } else {\n- if (!xy) {\n- var size = map.getSize();\n- xy = {\n- x: size.w / 2,\n- y: size.h / 2\n- };\n- }\n- map.zoomTween.start(start, end, map.zoomDuration, {\n- minFrameRate: 50, // don't spend much time zooming\n- callbacks: {\n- eachStep: function(data) {\n- var containerOrigin = map.layerContainerOriginPx,\n- scale = data.scale,\n- dx = ((scale - 1) * (containerOrigin.x - xy.x)) | 0,\n- dy = ((scale - 1) * (containerOrigin.y - xy.y)) | 0;\n- map.applyTransform(containerOrigin.x + dx, containerOrigin.y + dy, scale);\n- },\n- done: function(data) {\n- map.applyTransform();\n- var resolution = map.getResolution() / data.scale,\n- zoom = map.getZoomForResolution(resolution, true)\n- map.moveTo(map.getZoomTargetCenter(xy, resolution), zoom, true);\n+ split: function(target, options) {\n+ var results = null;\n+ var mutual = options && options.mutual;\n+ var sourceSplit, targetSplit, sourceParts, targetParts;\n+ if (target instanceof OpenLayers.Geometry.LineString) {\n+ var verts = this.getVertices();\n+ var vert1, vert2, seg, splits, lines, point;\n+ var points = [];\n+ sourceParts = [];\n+ for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n+ vert1 = verts[i];\n+ vert2 = verts[i + 1];\n+ seg = {\n+ x1: vert1.x,\n+ y1: vert1.y,\n+ x2: vert2.x,\n+ y2: vert2.y\n+ };\n+ targetParts = targetParts || [target];\n+ if (mutual) {\n+ points.push(vert1.clone());\n+ }\n+ for (var j = 0; j < targetParts.length; ++j) {\n+ splits = targetParts[j].splitWithSegment(seg, options);\n+ if (splits) {\n+ // splice in new features\n+ lines = splits.lines;\n+ if (lines.length > 0) {\n+ lines.unshift(j, 1);\n+ Array.prototype.splice.apply(targetParts, lines);\n+ j += lines.length - 2;\n+ }\n+ if (mutual) {\n+ for (var k = 0, len = splits.points.length; k < len; ++k) {\n+ point = splits.points[k];\n+ if (!point.equals(vert1)) {\n+ points.push(point);\n+ sourceParts.push(new OpenLayers.Geometry.LineString(points));\n+ if (point.equals(vert2)) {\n+ points = [];\n+ } else {\n+ points = [point.clone()];\n+ }\n+ }\n }\n }\n- });\n+ }\n }\n- } else {\n- var center = xy ?\n- map.getZoomTargetCenter(xy, map.getResolutionForZoom(zoom)) :\n- null;\n- map.setCenter(center, zoom);\n }\n+ if (mutual && sourceParts.length > 0 && points.length > 0) {\n+ points.push(vert2.clone());\n+ sourceParts.push(new OpenLayers.Geometry.LineString(points));\n+ }\n+ } else {\n+ results = target.splitWith(this, options);\n }\n- },\n-\n- /**\n- * APIMethod: zoomIn\n- * \n- */\n- zoomIn: function() {\n- this.zoomTo(this.getZoom() + 1);\n- },\n-\n- /**\n- * APIMethod: zoomOut\n- * \n- */\n- zoomOut: function() {\n- this.zoomTo(this.getZoom() - 1);\n- },\n-\n- /**\n- * APIMethod: zoomToExtent\n- * Zoom to the passed in bounds, recenter\n- * \n- * Parameters:\n- * bounds - {|Array} If provided as an array, the array\n- * should consist of four values (left, bottom, right, top).\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- */\n- zoomToExtent: function(bounds, closest) {\n- if (!(bounds instanceof OpenLayers.Bounds)) {\n- bounds = new OpenLayers.Bounds(bounds);\n+ if (targetParts && targetParts.length > 1) {\n+ targetSplit = true;\n+ } else {\n+ targetParts = [];\n }\n- var center = bounds.getCenterLonLat();\n- if (this.baseLayer.wrapDateLine) {\n- var maxExtent = this.getMaxExtent();\n-\n- //fix straddling bounds (in the case of a bbox that straddles the \n- // dateline, it's left and right boundaries will appear backwards. \n- // we fix this by allowing a right value that is greater than the\n- // max value at the dateline -- this allows us to pass a valid \n- // bounds to calculate zoom)\n- //\n- bounds = bounds.clone();\n- while (bounds.right < bounds.left) {\n- bounds.right += maxExtent.getWidth();\n+ if (sourceParts && sourceParts.length > 1) {\n+ sourceSplit = true;\n+ } else {\n+ sourceParts = [];\n+ }\n+ if (targetSplit || sourceSplit) {\n+ if (mutual) {\n+ results = [sourceParts, targetParts];\n+ } else {\n+ results = targetParts;\n }\n- //if the bounds was straddling (see above), then the center point \n- // we got from it was wrong. So we take our new bounds and ask it\n- // for the center.\n- //\n- center = bounds.getCenterLonLat().wrapDateLine(maxExtent);\n }\n- this.setCenter(center, this.getZoomForExtent(bounds, closest));\n+ return results;\n },\n \n- /** \n- * APIMethod: zoomToMaxExtent\n- * Zoom to the full extent and recenter.\n+ /**\n+ * Method: splitWith\n+ * Split this geometry (the target) with the given geometry (the source).\n *\n * Parameters:\n- * options - {Object}\n- * \n- * Allowed Options:\n- * restricted - {Boolean} True to zoom to restricted extent if it is \n- * set. Defaults to true.\n- */\n- zoomToMaxExtent: function(options) {\n- //restricted is true by default\n- var restricted = (options) ? options.restricted : true;\n-\n- var maxExtent = this.getMaxExtent({\n- 'restricted': restricted\n- });\n- this.zoomToExtent(maxExtent);\n- },\n-\n- /** \n- * APIMethod: zoomToScale\n- * Zoom to a specified scale \n- * \n- * Parameters:\n- * scale - {float}\n- * closest - {Boolean} Find the zoom level that most closely fits the \n- * specified scale. Note that this may result in a zoom that does \n- * not exactly contain the entire extent.\n- * Default is false.\n+ * geometry - {} A geometry used to split this\n+ * geometry (the source).\n+ * options - {Object} Properties of this object will be used to determine\n+ * how the split is conducted.\n+ *\n+ * Valid options:\n+ * mutual - {Boolean} Split the source geometry in addition to the target\n+ * geometry. Default is false.\n+ * edge - {Boolean} Allow splitting when only edges intersect. Default is\n+ * true. If false, a vertex on the source must be within the tolerance\n+ * distance of the intersection to be considered a split.\n+ * tolerance - {Number} If a non-null value is provided, intersections\n+ * within the tolerance distance of an existing vertex on the source\n+ * will be assumed to occur at the vertex.\n * \n+ * Returns:\n+ * {Array} A list of geometries (of this same type as the target) that\n+ * result from splitting the target with the source geometry. The\n+ * source and target geometry will remain unmodified. If no split\n+ * results, null will be returned. If mutual is true and a split\n+ * results, return will be an array of two arrays - the first will be\n+ * all geometries that result from splitting the source geometry and\n+ * the second will be all geometries that result from splitting the\n+ * target geometry.\n */\n- zoomToScale: function(scale, closest) {\n- var res = OpenLayers.Util.getResolutionFromScale(scale,\n- this.baseLayer.units);\n-\n- var halfWDeg = (this.size.w * res) / 2;\n- var halfHDeg = (this.size.h * res) / 2;\n- var center = this.getCachedCenter();\n+ splitWith: function(geometry, options) {\n+ return geometry.split(this, options);\n \n- var extent = new OpenLayers.Bounds(center.lon - halfWDeg,\n- center.lat - halfHDeg,\n- center.lon + halfWDeg,\n- center.lat + halfHDeg);\n- this.zoomToExtent(extent, closest);\n },\n \n- /********************************************************/\n- /* */\n- /* Translation Functions */\n- /* */\n- /* The following functions translate between */\n- /* LonLat, LayerPx, and ViewPortPx */\n- /* */\n- /********************************************************/\n-\n- //\n- // TRANSLATION: LonLat <-> ViewPortPx\n- //\n-\n /**\n- * Method: getLonLatFromViewPortPx\n- * \n+ * APIMethod: getVertices\n+ * Return a list of all points in this geometry.\n+ *\n * Parameters:\n- * viewPortPx - {|Object} An OpenLayers.Pixel or\n- * an object with a 'x'\n- * and 'y' properties.\n- * \n+ * nodes - {Boolean} For lines, only return vertices that are\n+ * endpoints. If false, for lines, only vertices that are not\n+ * endpoints will be returned. If not provided, all vertices will\n+ * be returned.\n+ *\n * Returns:\n- * {} An OpenLayers.LonLat which is the passed-in view \n- * port , translated into lon/lat\n- * by the current base layer.\n+ * {Array} A list of all vertices in the geometry.\n */\n- getLonLatFromViewPortPx: function(viewPortPx) {\n- var lonlat = null;\n- if (this.baseLayer != null) {\n- lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);\n+ getVertices: function(nodes) {\n+ var vertices;\n+ if (nodes === true) {\n+ vertices = [\n+ this.components[0],\n+ this.components[this.components.length - 1]\n+ ];\n+ } else if (nodes === false) {\n+ vertices = this.components.slice(1, this.components.length - 1);\n+ } else {\n+ vertices = this.components.slice();\n }\n- return lonlat;\n+ return vertices;\n },\n \n /**\n- * APIMethod: getViewPortPxFromLonLat\n- * \n+ * APIMethod: distanceTo\n+ * Calculate the closest distance between two geometries (on the x-y plane).\n+ *\n * Parameters:\n- * lonlat - {}\n- * \n+ * geometry - {} The target geometry.\n+ * options - {Object} Optional properties for configuring the distance\n+ * calculation.\n+ *\n+ * Valid options:\n+ * details - {Boolean} Return details from the distance calculation.\n+ * Default is false.\n+ * edge - {Boolean} Calculate the distance from this geometry to the\n+ * nearest edge of the target geometry. Default is true. If true,\n+ * calling distanceTo from a geometry that is wholly contained within\n+ * the target will result in a non-zero distance. If false, whenever\n+ * geometries intersect, calling distanceTo will return 0. If false,\n+ * details cannot be returned.\n+ *\n * Returns:\n- * {} An OpenLayers.Pixel which is the passed-in \n- * , translated into view port \n- * pixels by the current base layer.\n+ * {Number | Object} The distance between this geometry and the target.\n+ * If details is true, the return will be an object with distance,\n+ * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n+ * the coordinates of the closest point on this geometry. The x1 and y1\n+ * properties represent the coordinates of the closest point on the\n+ * target geometry.\n */\n- getViewPortPxFromLonLat: function(lonlat) {\n- var px = null;\n- if (this.baseLayer != null) {\n- px = this.baseLayer.getViewPortPxFromLonLat(lonlat);\n+ distanceTo: function(geometry, options) {\n+ var edge = !(options && options.edge === false);\n+ var details = edge && options && options.details;\n+ var result, best = {};\n+ var min = Number.POSITIVE_INFINITY;\n+ if (geometry instanceof OpenLayers.Geometry.Point) {\n+ var segs = this.getSortedSegments();\n+ var x = geometry.x;\n+ var y = geometry.y;\n+ var seg;\n+ for (var i = 0, len = segs.length; i < len; ++i) {\n+ seg = segs[i];\n+ result = OpenLayers.Geometry.distanceToSegment(geometry, seg);\n+ if (result.distance < min) {\n+ min = result.distance;\n+ best = result;\n+ if (min === 0) {\n+ break;\n+ }\n+ } else {\n+ // if distance increases and we cross y0 to the right of x0, no need to keep looking.\n+ if (seg.x2 > x && ((y > seg.y1 && y < seg.y2) || (y < seg.y1 && y > seg.y2))) {\n+ break;\n+ }\n+ }\n+ }\n+ if (details) {\n+ best = {\n+ distance: best.distance,\n+ x0: best.x,\n+ y0: best.y,\n+ x1: x,\n+ y1: y\n+ };\n+ } else {\n+ best = best.distance;\n+ }\n+ } else if (geometry instanceof OpenLayers.Geometry.LineString) {\n+ var segs0 = this.getSortedSegments();\n+ var segs1 = geometry.getSortedSegments();\n+ var seg0, seg1, intersection, x0, y0;\n+ var len1 = segs1.length;\n+ var interOptions = {\n+ point: true\n+ };\n+ outer: for (var i = 0, len = segs0.length; i < len; ++i) {\n+ seg0 = segs0[i];\n+ x0 = seg0.x1;\n+ y0 = seg0.y1;\n+ for (var j = 0; j < len1; ++j) {\n+ seg1 = segs1[j];\n+ intersection = OpenLayers.Geometry.segmentsIntersect(seg0, seg1, interOptions);\n+ if (intersection) {\n+ min = 0;\n+ best = {\n+ distance: 0,\n+ x0: intersection.x,\n+ y0: intersection.y,\n+ x1: intersection.x,\n+ y1: intersection.y\n+ };\n+ break outer;\n+ } else {\n+ result = OpenLayers.Geometry.distanceToSegment({\n+ x: x0,\n+ y: y0\n+ }, seg1);\n+ if (result.distance < min) {\n+ min = result.distance;\n+ best = {\n+ distance: min,\n+ x0: x0,\n+ y0: y0,\n+ x1: result.x,\n+ y1: result.y\n+ };\n+ }\n+ }\n+ }\n+ }\n+ if (!details) {\n+ best = best.distance;\n+ }\n+ if (min !== 0) {\n+ // check the final vertex in this line's sorted segments\n+ if (seg0) {\n+ result = geometry.distanceTo(\n+ new OpenLayers.Geometry.Point(seg0.x2, seg0.y2),\n+ options\n+ );\n+ var dist = details ? result.distance : result;\n+ if (dist < min) {\n+ if (details) {\n+ best = {\n+ distance: min,\n+ x0: result.x1,\n+ y0: result.y1,\n+ x1: result.x0,\n+ y1: result.y0\n+ };\n+ } else {\n+ best = dist;\n+ }\n+ }\n+ }\n+ }\n+ } else {\n+ best = geometry.distanceTo(this, options);\n+ // swap since target comes from this line\n+ if (details) {\n+ best = {\n+ distance: best.distance,\n+ x0: best.x1,\n+ y0: best.y1,\n+ x1: best.x0,\n+ y1: best.y0\n+ };\n+ }\n }\n- return px;\n+ return best;\n },\n \n /**\n- * Method: getZoomTargetCenter\n+ * APIMethod: simplify\n+ * This function will return a simplified LineString.\n+ * Simplification is based on the Douglas-Peucker algorithm.\n+ *\n *\n * Parameters:\n- * xy - {} The zoom origin pixel location on the screen\n- * resolution - {Float} The resolution we want to get the center for\n+ * tolerance - {number} threshhold for simplification in map units\n *\n * Returns:\n- * {} The location of the map center after the\n- * transformation described by the origin xy and the target resolution.\n+ * {OpenLayers.Geometry.LineString} the simplified LineString\n */\n- getZoomTargetCenter: function(xy, resolution) {\n- var lonlat = null,\n- size = this.getSize(),\n- deltaX = size.w / 2 - xy.x,\n- deltaY = xy.y - size.h / 2,\n- zoomPoint = this.getLonLatFromPixel(xy);\n- if (zoomPoint) {\n- lonlat = new OpenLayers.LonLat(\n- zoomPoint.lon + deltaX * resolution,\n- zoomPoint.lat + deltaY * resolution\n- );\n- }\n- return lonlat;\n- },\n+ simplify: function(tolerance) {\n+ if (this && this !== null) {\n+ var points = this.getVertices();\n+ if (points.length < 3) {\n+ return this;\n+ }\n \n- //\n- // CONVENIENCE TRANSLATION FUNCTIONS FOR API\n- //\n+ var compareNumbers = function(a, b) {\n+ return (a - b);\n+ };\n \n- /**\n- * APIMethod: getLonLatFromPixel\n- * \n- * Parameters:\n- * px - {|Object} An OpenLayers.Pixel or an object with\n- * a 'x' and 'y' properties.\n- *\n- * Returns:\n- * {} An OpenLayers.LonLat corresponding to the given\n- * OpenLayers.Pixel, translated into lon/lat by the \n- * current base layer\n- */\n- getLonLatFromPixel: function(px) {\n- return this.getLonLatFromViewPortPx(px);\n- },\n+ /**\n+ * Private function doing the Douglas-Peucker reduction\n+ */\n+ var douglasPeuckerReduction = function(points, firstPoint, lastPoint, tolerance) {\n+ var maxDistance = 0;\n+ var indexFarthest = 0;\n \n- /**\n- * APIMethod: getPixelFromLonLat\n- * Returns a pixel location given a map location. The map location is\n- * translated to an integer pixel location (in viewport pixel\n- * coordinates) by the current base layer.\n- * \n- * Parameters:\n- * lonlat - {} A map location.\n- * \n- * Returns: \n- * {} An OpenLayers.Pixel corresponding to the \n- * translated into view port pixels by the current\n- * base layer.\n- */\n- getPixelFromLonLat: function(lonlat) {\n- var px = this.getViewPortPxFromLonLat(lonlat);\n- px.x = Math.round(px.x);\n- px.y = Math.round(px.y);\n- return px;\n- },\n+ for (var index = firstPoint, distance; index < lastPoint; index++) {\n+ distance = perpendicularDistance(points[firstPoint], points[lastPoint], points[index]);\n+ if (distance > maxDistance) {\n+ maxDistance = distance;\n+ indexFarthest = index;\n+ }\n+ }\n \n- /**\n- * Method: getGeodesicPixelSize\n- * \n- * Parameters:\n- * px - {} The pixel to get the geodesic length for. If\n- * not provided, the center pixel of the map viewport will be used.\n- * \n- * Returns:\n- * {} The geodesic size of the pixel in kilometers.\n- */\n- getGeodesicPixelSize: function(px) {\n- var lonlat = px ? this.getLonLatFromPixel(px) : (\n- this.getCachedCenter() || new OpenLayers.LonLat(0, 0));\n- var res = this.getResolution();\n- var left = lonlat.add(-res / 2, 0);\n- var right = lonlat.add(res / 2, 0);\n- var bottom = lonlat.add(0, -res / 2);\n- var top = lonlat.add(0, res / 2);\n- var dest = new OpenLayers.Projection(\"EPSG:4326\");\n- var source = this.getProjectionObject() || dest;\n- if (!source.equals(dest)) {\n- left.transform(source, dest);\n- right.transform(source, dest);\n- bottom.transform(source, dest);\n- top.transform(source, dest);\n- }\n+ if (maxDistance > tolerance && indexFarthest != firstPoint) {\n+ //Add the largest point that exceeds the tolerance\n+ pointIndexsToKeep.push(indexFarthest);\n+ douglasPeuckerReduction(points, firstPoint, indexFarthest, tolerance);\n+ douglasPeuckerReduction(points, indexFarthest, lastPoint, tolerance);\n+ }\n+ };\n \n- return new OpenLayers.Size(\n- OpenLayers.Util.distVincenty(left, right),\n- OpenLayers.Util.distVincenty(bottom, top)\n- );\n- },\n+ /**\n+ * Private function calculating the perpendicular distance\n+ * TODO: check whether OpenLayers.Geometry.LineString::distanceTo() is faster or slower\n+ */\n+ var perpendicularDistance = function(point1, point2, point) {\n+ //Area = |(1/2)(x1y2 + x2y3 + x3y1 - x2y1 - x3y2 - x1y3)| *Area of triangle\n+ //Base = v((x1-x2)\u00b2+(x1-x2)\u00b2) *Base of Triangle*\n+ //Area = .5*Base*H *Solve for height\n+ //Height = Area/.5/Base\n \n+ var area = Math.abs(0.5 * (point1.x * point2.y + point2.x * point.y + point.x * point1.y - point2.x * point1.y - point.x * point2.y - point1.x * point.y));\n+ var bottom = Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));\n+ var height = area / bottom * 2;\n \n+ return height;\n+ };\n \n- //\n- // TRANSLATION: ViewPortPx <-> LayerPx\n- //\n+ var firstPoint = 0;\n+ var lastPoint = points.length - 1;\n+ var pointIndexsToKeep = [];\n \n- /**\n- * APIMethod: getViewPortPxFromLayerPx\n- * \n- * Parameters:\n- * layerPx - {}\n- * \n- * Returns:\n- * {} Layer Pixel translated into ViewPort Pixel \n- * coordinates\n- */\n- getViewPortPxFromLayerPx: function(layerPx) {\n- var viewPortPx = null;\n- if (layerPx != null) {\n- var dX = this.layerContainerOriginPx.x;\n- var dY = this.layerContainerOriginPx.y;\n- viewPortPx = layerPx.add(dX, dY);\n- }\n- return viewPortPx;\n- },\n+ //Add the first and last index to the keepers\n+ pointIndexsToKeep.push(firstPoint);\n+ pointIndexsToKeep.push(lastPoint);\n \n- /**\n- * APIMethod: getLayerPxFromViewPortPx\n- * \n- * Parameters:\n- * viewPortPx - {}\n- * \n- * Returns:\n- * {} ViewPort Pixel translated into Layer Pixel \n- * coordinates\n- */\n- getLayerPxFromViewPortPx: function(viewPortPx) {\n- var layerPx = null;\n- if (viewPortPx != null) {\n- var dX = -this.layerContainerOriginPx.x;\n- var dY = -this.layerContainerOriginPx.y;\n- layerPx = viewPortPx.add(dX, dY);\n- if (isNaN(layerPx.x) || isNaN(layerPx.y)) {\n- layerPx = null;\n+ //The first and the last point cannot be the same\n+ while (points[firstPoint].equals(points[lastPoint])) {\n+ lastPoint--;\n+ //Addition: the first point not equal to first point in the LineString is kept as well\n+ pointIndexsToKeep.push(lastPoint);\n }\n- }\n- return layerPx;\n- },\n \n- //\n- // TRANSLATION: LonLat <-> LayerPx\n- //\n+ douglasPeuckerReduction(points, firstPoint, lastPoint, tolerance);\n+ var returnPoints = [];\n+ pointIndexsToKeep.sort(compareNumbers);\n+ for (var index = 0; index < pointIndexsToKeep.length; index++) {\n+ returnPoints.push(points[pointIndexsToKeep[index]]);\n+ }\n+ return new OpenLayers.Geometry.LineString(returnPoints);\n \n- /**\n- * Method: getLonLatFromLayerPx\n- * \n- * Parameters:\n- * px - {}\n- *\n- * Returns:\n- * {}\n- */\n- getLonLatFromLayerPx: function(px) {\n- //adjust for displacement of layerContainerDiv\n- px = this.getViewPortPxFromLayerPx(px);\n- return this.getLonLatFromViewPortPx(px);\n+ } else {\n+ return this;\n+ }\n },\n \n- /**\n- * APIMethod: getLayerPxFromLonLat\n- * \n- * Parameters:\n- * lonlat - {} lonlat\n- *\n- * Returns:\n- * {} An OpenLayers.Pixel which is the passed-in \n- * , translated into layer pixels \n- * by the current base layer\n- */\n- getLayerPxFromLonLat: function(lonlat) {\n- //adjust for displacement of layerContainerDiv\n- var px = this.getPixelFromLonLat(lonlat);\n- return this.getLayerPxFromViewPortPx(px);\n- },\n-\n- /**\n- * Method: applyTransform\n- * Applies the given transform to the . This method has\n- * a 2-stage fallback from translate3d/scale3d via translate/scale to plain\n- * style.left/style.top, in which case no scaling is supported.\n- *\n- * Parameters:\n- * x - {Number} x parameter for the translation. Defaults to the x value of\n- * the map's \n- * y - {Number} y parameter for the translation. Defaults to the y value of\n- * the map's \n- * scale - {Number} scale. Defaults to 1 if not provided.\n- */\n- applyTransform: function(x, y, scale) {\n- scale = scale || 1;\n- var origin = this.layerContainerOriginPx,\n- needTransform = scale !== 1;\n- x = x || origin.x;\n- y = y || origin.y;\n-\n- var style = this.layerContainerDiv.style,\n- transform = this.applyTransform.transform,\n- template = this.applyTransform.template;\n-\n- if (transform === undefined) {\n- transform = OpenLayers.Util.vendorPrefix.style('transform');\n- this.applyTransform.transform = transform;\n- if (transform) {\n- // Try translate3d, but only if the viewPortDiv has a transform\n- // defined in a stylesheet\n- var computedStyle = OpenLayers.Element.getStyle(this.viewPortDiv,\n- OpenLayers.Util.vendorPrefix.css('transform'));\n- if (!computedStyle || computedStyle !== 'none') {\n- template = ['translate3d(', ',0) ', 'scale3d(', ',1)'];\n- style[transform] = [template[0], '0,0', template[1]].join('');\n- }\n- // If no transform is defined in the stylesheet or translate3d\n- // does not stick, use translate and scale\n- if (!template || !~style[transform].indexOf(template[0])) {\n- template = ['translate(', ') ', 'scale(', ')'];\n- }\n- this.applyTransform.template = template;\n- }\n- }\n-\n- // If we do 3d transforms, we always want to use them. If we do 2d\n- // transforms, we only use them when we need to.\n- if (transform !== null && (template[0] === 'translate3d(' || needTransform === true)) {\n- // Our 2d transforms are combined with style.left and style.top, so\n- // adjust x and y values and set the origin as left and top\n- if (needTransform === true && template[0] === 'translate(') {\n- x -= origin.x;\n- y -= origin.y;\n- style.left = origin.x + 'px';\n- style.top = origin.y + 'px';\n- }\n- style[transform] = [\n- template[0], x, 'px,', y, 'px', template[1],\n- template[2], scale, ',', scale, template[3]\n- ].join('');\n- } else {\n- style.left = x + 'px';\n- style.top = y + 'px';\n- // We previously might have had needTransform, so remove transform\n- if (transform !== null) {\n- style[transform] = '';\n- }\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Map\"\n-});\n-\n-/**\n- * Constant: TILE_WIDTH\n- * {Integer} 256 Default tile width (unless otherwise specified)\n- */\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/Layer.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- */\n-OpenLayers.Layer = OpenLayers.Class({\n-\n- /**\n- * APIProperty: id\n- * {String}\n- */\n- id: null,\n-\n- /** \n- * APIProperty: name\n- * {String}\n- */\n- name: null,\n-\n- /** \n- * APIProperty: div\n- * {DOMElement}\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- isBaseLayer: false,\n-\n- /**\n- * Property: alpha\n- * {Boolean} The layer's images have an alpha channel. Default is false.\n- */\n- alpha: false,\n-\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- /**\n- * APIProperty: visibility\n- * {Boolean} The layer should be displayed in the map. Default is true.\n- */\n- visibility: true,\n-\n- /**\n- * APIProperty: attribution\n- * {String} Attribution string, displayed when an \n- * has been added to the map.\n- */\n- attribution: null,\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- */\n- inRange: false,\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- // OPTIONS\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- */\n- options: 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- resolutions: 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- * \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- *\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- this.metadata = {};\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- }\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- */\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- if (this.events) {\n- if (this.eventListeners) {\n- this.events.un(this.eventListeners);\n- }\n- this.events.destroy();\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- }\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- }\n- }\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- }\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- *\n- * Parameters:\n- * scales - {Array(Number)} Scales\n- *\n- * Returns\n- * {Array(Number)} Resolutions\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- }\n- return resolutions;\n- },\n-\n- /**\n- * Method: calculateResolutions\n- * Calculate resolutions based on the provided properties.\n- *\n- * Parameters:\n- * props - {Object} Properties\n- *\n- * Returns:\n- * {Array({Number})} Array of resolutions.\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- }\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- * 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- * zoom - {Float}\n- * \n- * Returns:\n- * {Float} A suitable resolution for the specified zoom.\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- }\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- * \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- */\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- }\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- }\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- );\n- }\n- return px;\n- },\n-\n- /**\n- * APIMethod: setOpacity\n- * Sets the opacity for the entire layer (all images)\n- * \n- * Parameters:\n- * opacity - {Float}\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- }\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"opacity\"\n- });\n- }\n- }\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-\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/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-\n- /** \n- * Property: id \n- * {String} \n- */\n- id: null,\n-\n- /** \n- * Property: map \n- * {} this gets set in the addControl() function in\n- * OpenLayers.Map \n- */\n- map: null,\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- div: null,\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-\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- allowSelection: false,\n-\n- /** \n- * Property: displayClass \n- * {string} This property is used for CSS related to the drawing of the\n- * Control. \n- */\n- displayClass: \"\",\n-\n- /**\n- * APIProperty: title \n- * {string} This property is used for showing a tooltip over the \n- * Control. \n- */\n- title: \"\",\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-\n- /** \n- * APIProperty: active \n- * {Boolean} The control is active (read-only). Use and \n- * to change control state.\n- */\n- active: null,\n-\n- /**\n- * Property: handlerOptions\n- * {Object} Used to set non-default properties on the control's handler\n- */\n- handlerOptions: null,\n-\n- /** \n- * Property: handler \n- * {} null\n- */\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: 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- events: null,\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- *\n- * Overrides the default div attribute value of null.\n- * \n- * Parameters:\n- * options - {Object} \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-\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- if (this.id == null) {\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\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- }\n- this.eventListeners = null;\n-\n- // eliminate circular references\n- if (this.handler) {\n- this.handler.destroy();\n- this.handler = null;\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- if (this.map) {\n- this.map.removeControl(this);\n- this.map = null;\n- }\n- this.div = null;\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- *\n- * Parameters:\n- * map - {} \n- */\n- setMap: function(map) {\n- this.map = map;\n- if (this.handler) {\n- this.handler.setMap(map);\n- }\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- * Parameters:\n- * px - {} The top-left pixel position of the control\n- * or null.\n- *\n- * Returns:\n- * {DOMElement} A reference to the DIV DOMElement containing the control\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- }\n- if (this.title != \"\") {\n- this.div.title = this.title;\n- }\n- }\n- if (px != null) {\n- this.position = px.clone();\n- }\n- this.moveTo(this.position);\n- return this.div;\n- },\n-\n- /**\n- * Method: moveTo\n- * Sets the left and top style attributes to the passed in pixel \n- * coordinates.\n- *\n- * Parameters:\n- * px - {}\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- * 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- * {Boolean} True if the control was successfully activated or\n- * false if the control was already active.\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- );\n- }\n- this.events.triggerEvent(\"activate\");\n- return true;\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- * \n- * Returns:\n- * {Boolean} True if the control was effectively deactivated or false\n- * if the control was already inactive.\n- */\n- deactivate: function() {\n- if (this.active) {\n- if (this.handler) {\n- this.handler.deactivate();\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- CLASS_NAME: \"OpenLayers.Control\"\n-});\n-\n-/**\n- * Constant: OpenLayers.Control.TYPE_BUTTON\n- */\n-OpenLayers.Control.TYPE_BUTTON = 1;\n-\n-/**\n- * Constant: OpenLayers.Control.TYPE_TOGGLE\n- */\n-OpenLayers.Control.TYPE_TOGGLE = 2;\n-\n-/**\n- * Constant: OpenLayers.Control.TYPE_TOOL\n- */\n-OpenLayers.Control.TYPE_TOOL = 3;\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- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry\n- * A Geometry is a description of a geographic object. Create an instance of\n- * this class with the constructor. This is a base class,\n- * typical geometry types are described by subclasses of this class.\n- *\n- * Note that if you use the method, you must\n- * explicitly include the OpenLayers.Format.WKT in your build.\n- */\n-OpenLayers.Geometry = OpenLayers.Class({\n-\n- /**\n- * Property: id\n- * {String} A unique identifier for this geometry.\n- */\n- id: null,\n-\n- /**\n- * Property: parent\n- * {}This is set when a Geometry is added as component\n- * of another geometry\n- */\n- parent: null,\n-\n- /**\n- * Property: bounds \n- * {} The bounds of this geometry\n- */\n- bounds: null,\n-\n- /**\n- * Constructor: OpenLayers.Geometry\n- * Creates a geometry object. \n- */\n- initialize: function() {\n- this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n- },\n-\n- /**\n- * Method: destroy\n- * Destroy this geometry.\n- */\n- destroy: function() {\n- this.id = null;\n- this.bounds = null;\n- },\n-\n- /**\n- * APIMethod: clone\n- * Create a clone of this geometry. Does not set any non-standard\n- * properties of the cloned geometry.\n- * \n- * Returns:\n- * {} An exact clone of this geometry.\n- */\n- clone: function() {\n- return new OpenLayers.Geometry();\n- },\n-\n- /**\n- * Method: setBounds\n- * Set the bounds for this Geometry.\n- * \n- * Parameters:\n- * bounds - {} \n- */\n- setBounds: function(bounds) {\n- if (bounds) {\n- this.bounds = bounds.clone();\n- }\n- },\n-\n- /**\n- * Method: clearBounds\n- * Nullify this components bounds and that of its parent as well.\n- */\n- clearBounds: function() {\n- this.bounds = null;\n- if (this.parent) {\n- this.parent.clearBounds();\n- }\n- },\n-\n- /**\n- * Method: extendBounds\n- * Extend the existing bounds to include the new bounds. \n- * If geometry's bounds is not yet set, then set a new Bounds.\n- * \n- * Parameters:\n- * newBounds - {} \n- */\n- extendBounds: function(newBounds) {\n- var bounds = this.getBounds();\n- if (!bounds) {\n- this.setBounds(newBounds);\n- } else {\n- this.bounds.extend(newBounds);\n- }\n- },\n-\n- /**\n- * APIMethod: getBounds\n- * Get the bounds for this Geometry. If bounds is not set, it \n- * is calculated again, this makes queries faster.\n- * \n- * Returns:\n- * {}\n- */\n- getBounds: function() {\n- if (this.bounds == null) {\n- this.calculateBounds();\n- }\n- return this.bounds;\n- },\n-\n- /** \n- * APIMethod: calculateBounds\n- * Recalculate the bounds for the geometry. \n- */\n- calculateBounds: function() {\n- //\n- // This should be overridden by subclasses.\n- //\n- },\n-\n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options depend on the specific geometry type.\n- * \n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n- */\n- distanceTo: function(geometry, options) {},\n-\n- /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n- */\n- getVertices: function(nodes) {},\n-\n- /**\n- * Method: atPoint\n- * Note - This is only an approximation based on the bounds of the \n- * geometry.\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 geometry is at the specified location\n- */\n- atPoint: function(lonlat, toleranceLon, toleranceLat) {\n- var atPoint = false;\n- var bounds = this.getBounds();\n- if ((bounds != null) && (lonlat != null)) {\n-\n- var dX = (toleranceLon != null) ? toleranceLon : 0;\n- var dY = (toleranceLat != null) ? toleranceLat : 0;\n-\n- var toleranceBounds =\n- new OpenLayers.Bounds(this.bounds.left - dX,\n- this.bounds.bottom - dY,\n- this.bounds.right + dX,\n- this.bounds.top + dY);\n-\n- atPoint = toleranceBounds.containsLonLat(lonlat);\n- }\n- return atPoint;\n- },\n-\n- /**\n- * Method: getLength\n- * Calculate the length of this geometry. This method is defined in\n- * subclasses.\n- * \n- * Returns:\n- * {Float} The length of the collection by summing its parts\n- */\n- getLength: function() {\n- //to be overridden by geometries that actually have a length\n- //\n- return 0.0;\n- },\n-\n- /**\n- * Method: getArea\n- * Calculate the area of this geometry. This method is defined in subclasses.\n- * \n- * Returns:\n- * {Float} The area of the collection by summing its parts\n- */\n- getArea: function() {\n- //to be overridden by geometries that actually have an area\n- //\n- return 0.0;\n- },\n-\n- /**\n- * APIMethod: getCentroid\n- * Calculate the centroid of this geometry. This method is defined in subclasses.\n- *\n- * Returns:\n- * {} The centroid of the collection\n- */\n- getCentroid: function() {\n- return null;\n- },\n-\n- /**\n- * Method: toString\n- * Returns a text representation of the geometry. If the WKT format is\n- * included in a build, this will be the Well-Known Text \n- * representation.\n- *\n- * Returns:\n- * {String} String representation of this geometry.\n- */\n- toString: function() {\n- var string;\n- if (OpenLayers.Format && OpenLayers.Format.WKT) {\n- string = OpenLayers.Format.WKT.prototype.write(\n- new OpenLayers.Feature.Vector(this)\n- );\n- } else {\n- string = Object.prototype.toString.call(this);\n- }\n- return string;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Geometry\"\n-});\n-\n-/**\n- * Function: OpenLayers.Geometry.fromWKT\n- * Generate a geometry given a Well-Known Text string. For this method to\n- * work, you must include the OpenLayers.Format.WKT in your build \n- * explicitly.\n- *\n- * Parameters:\n- * wkt - {String} A string representing the geometry in Well-Known Text.\n- *\n- * Returns:\n- * {} A geometry of the appropriate class.\n- */\n-OpenLayers.Geometry.fromWKT = function(wkt) {\n- var geom;\n- if (OpenLayers.Format && OpenLayers.Format.WKT) {\n- var format = OpenLayers.Geometry.fromWKT.format;\n- if (!format) {\n- format = new OpenLayers.Format.WKT();\n- OpenLayers.Geometry.fromWKT.format = format;\n- }\n- var result = format.read(wkt);\n- if (result instanceof OpenLayers.Feature.Vector) {\n- geom = result.geometry;\n- } else if (OpenLayers.Util.isArray(result)) {\n- var len = result.length;\n- var components = new Array(len);\n- for (var i = 0; i < len; ++i) {\n- components[i] = result[i].geometry;\n- }\n- geom = new OpenLayers.Geometry.Collection(components);\n- }\n- }\n- return geom;\n-};\n-\n-/**\n- * Method: OpenLayers.Geometry.segmentsIntersect\n- * Determine whether two line segments intersect. Optionally calculates\n- * and returns the intersection point. This function is optimized for\n- * cases where seg1.x2 >= seg2.x1 || seg2.x2 >= seg1.x1. In those\n- * obvious cases where there is no intersection, the function should\n- * not be called.\n- *\n- * Parameters:\n- * seg1 - {Object} Object representing a segment with properties x1, y1, x2,\n- * and y2. The start point is represented by x1 and y1. The end point\n- * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n- * seg2 - {Object} Object representing a segment with properties x1, y1, x2,\n- * and y2. The start point is represented by x1 and y1. The end point\n- * is represented by x2 and y2. Start and end are ordered so that x1 < x2.\n- * options - {Object} Optional properties for calculating the intersection.\n- *\n- * Valid options:\n- * point - {Boolean} Return the intersection point. If false, the actual\n- * intersection point will not be calculated. If true and the segments\n- * intersect, the intersection point will be returned. If true and\n- * the segments do not intersect, false will be returned. If true and\n- * the segments are coincident, true will be returned.\n- * tolerance - {Number} If a non-null value is provided, if the segments are\n- * within the tolerance distance, this will be considered an intersection.\n- * In addition, if the point option is true and the calculated intersection\n- * is within the tolerance distance of an end point, the endpoint will be\n- * returned instead of the calculated intersection. Further, if the\n- * intersection is within the tolerance of endpoints on both segments, or\n- * if two segment endpoints are within the tolerance distance of eachother\n- * (but no intersection is otherwise calculated), an endpoint on the\n- * first segment provided will be returned.\n- *\n- * Returns:\n- * {Boolean | } The two segments intersect.\n- * If the point argument is true, the return will be the intersection\n- * point or false if none exists. If point is true and the segments\n- * are coincident, return will be true (and the instersection is equal\n- * to the shorter segment).\n- */\n-OpenLayers.Geometry.segmentsIntersect = function(seg1, seg2, options) {\n- var point = options && options.point;\n- var tolerance = options && options.tolerance;\n- var intersection = false;\n- var x11_21 = seg1.x1 - seg2.x1;\n- var y11_21 = seg1.y1 - seg2.y1;\n- var x12_11 = seg1.x2 - seg1.x1;\n- var y12_11 = seg1.y2 - seg1.y1;\n- var y22_21 = seg2.y2 - seg2.y1;\n- var x22_21 = seg2.x2 - seg2.x1;\n- var d = (y22_21 * x12_11) - (x22_21 * y12_11);\n- var n1 = (x22_21 * y11_21) - (y22_21 * x11_21);\n- var n2 = (x12_11 * y11_21) - (y12_11 * x11_21);\n- if (d == 0) {\n- // parallel\n- if (n1 == 0 && n2 == 0) {\n- // coincident\n- intersection = true;\n- }\n- } else {\n- var along1 = n1 / d;\n- var along2 = n2 / d;\n- if (along1 >= 0 && along1 <= 1 && along2 >= 0 && along2 <= 1) {\n- // intersect\n- if (!point) {\n- intersection = true;\n- } else {\n- // calculate the intersection point\n- var x = seg1.x1 + (along1 * x12_11);\n- var y = seg1.y1 + (along1 * y12_11);\n- intersection = new OpenLayers.Geometry.Point(x, y);\n- }\n- }\n- }\n- if (tolerance) {\n- var dist;\n- if (intersection) {\n- if (point) {\n- var segs = [seg1, seg2];\n- var seg, x, y;\n- // check segment endpoints for proximity to intersection\n- // set intersection to first endpoint within the tolerance\n- outer: for (var i = 0; i < 2; ++i) {\n- seg = segs[i];\n- for (var j = 1; j < 3; ++j) {\n- x = seg[\"x\" + j];\n- y = seg[\"y\" + j];\n- dist = Math.sqrt(\n- Math.pow(x - intersection.x, 2) +\n- Math.pow(y - intersection.y, 2)\n- );\n- if (dist < tolerance) {\n- intersection.x = x;\n- intersection.y = y;\n- break outer;\n- }\n- }\n- }\n-\n- }\n- } else {\n- // no calculated intersection, but segments could be within\n- // the tolerance of one another\n- var segs = [seg1, seg2];\n- var source, target, x, y, p, result;\n- // check segment endpoints for proximity to intersection\n- // set intersection to first endpoint within the tolerance\n- outer: for (var i = 0; i < 2; ++i) {\n- source = segs[i];\n- target = segs[(i + 1) % 2];\n- for (var j = 1; j < 3; ++j) {\n- p = {\n- x: source[\"x\" + j],\n- y: source[\"y\" + j]\n- };\n- result = OpenLayers.Geometry.distanceToSegment(p, target);\n- if (result.distance < tolerance) {\n- if (point) {\n- intersection = new OpenLayers.Geometry.Point(p.x, p.y);\n- } else {\n- intersection = true;\n- }\n- break outer;\n- }\n- }\n- }\n- }\n- }\n- return intersection;\n-};\n-\n-/**\n- * Function: OpenLayers.Geometry.distanceToSegment\n- *\n- * Parameters:\n- * point - {Object} An object with x and y properties representing the\n- * point coordinates.\n- * segment - {Object} An object with x1, y1, x2, and y2 properties\n- * representing endpoint coordinates.\n- *\n- * Returns:\n- * {Object} An object with distance, along, x, and y properties. The distance\n- * will be the shortest distance between the input point and segment.\n- * The x and y properties represent the coordinates along the segment\n- * where the shortest distance meets the segment. The along attribute\n- * describes how far between the two segment points the given point is.\n- */\n-OpenLayers.Geometry.distanceToSegment = function(point, segment) {\n- var result = OpenLayers.Geometry.distanceSquaredToSegment(point, segment);\n- result.distance = Math.sqrt(result.distance);\n- return result;\n-};\n-\n-/**\n- * Function: OpenLayers.Geometry.distanceSquaredToSegment\n- *\n- * Usually the distanceToSegment function should be used. This variant however\n- * can be used for comparisons where the exact distance is not important.\n- *\n- * Parameters:\n- * point - {Object} An object with x and y properties representing the\n- * point coordinates.\n- * segment - {Object} An object with x1, y1, x2, and y2 properties\n- * representing endpoint coordinates.\n- *\n- * Returns:\n- * {Object} An object with squared distance, along, x, and y properties.\n- * The distance will be the shortest distance between the input point and\n- * segment. The x and y properties represent the coordinates along the\n- * segment where the shortest distance meets the segment. The along\n- * attribute describes how far between the two segment points the given\n- * point is.\n- */\n-OpenLayers.Geometry.distanceSquaredToSegment = function(point, segment) {\n- var x0 = point.x;\n- var y0 = point.y;\n- var x1 = segment.x1;\n- var y1 = segment.y1;\n- var x2 = segment.x2;\n- var y2 = segment.y2;\n- var dx = x2 - x1;\n- var dy = y2 - y1;\n- var along = ((dx * (x0 - x1)) + (dy * (y0 - y1))) /\n- (Math.pow(dx, 2) + Math.pow(dy, 2));\n- var x, y;\n- if (along <= 0.0) {\n- x = x1;\n- y = y1;\n- } else if (along >= 1.0) {\n- x = x2;\n- y = y2;\n- } else {\n- x = x1 + along * dx;\n- y = y1 + along * dy;\n- }\n- return {\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/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- * Property: defaultFilter\n- * {} Optional default filter to read requests\n- */\n- defaultFilter: null,\n-\n- /**\n- * Constructor: OpenLayers.Protocol\n- * Abstract class for vector protocols. 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- options = options || {};\n- OpenLayers.Util.extend(this, options);\n- this.options = options;\n- },\n-\n- /**\n- * Method: mergeWithDefaultFilter\n- * Merge filter passed to the read method with the default one\n- *\n- * Parameters:\n- * filter - {}\n- */\n- mergeWithDefaultFilter: function(filter) {\n- var merged;\n- if (filter && this.defaultFilter) {\n- merged = new OpenLayers.Filter.Logical({\n- type: OpenLayers.Filter.Logical.AND,\n- filters: [this.defaultFilter, filter]\n- });\n- } else {\n- merged = filter || this.defaultFilter || undefined;\n- }\n- return merged;\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Clean up the protocol.\n- */\n- destroy: function() {\n- this.options = null;\n- this.format = null;\n- },\n-\n- /**\n- * APIMethod: read\n- * Construct a request for reading new features.\n- *\n- * Parameters:\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- read: function(options) {\n- options = options || {};\n- options.filter = this.mergeWithDefaultFilter(options.filter);\n- },\n-\n-\n- /**\n- * APIMethod: create\n- * Construct a request for writing newly created features.\n- *\n- * Parameters:\n- * features - {Array({})} or\n- * {}\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- create: function() {},\n-\n- /**\n- * APIMethod: update\n- * Construct a request updating modified features.\n- *\n- * Parameters:\n- * features - {Array({})} or\n- * {}\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- update: function() {},\n-\n- /**\n- * APIMethod: delete\n- * Construct a request deleting a removed feature.\n- *\n- * Parameters:\n- * feature - {}\n- * options - {Object} Optional object for configuring the request.\n- *\n- * Returns:\n- * {} An \n- * object, the same object will be passed to the callback function passed\n- * if one exists in the options object.\n- */\n- \"delete\": function() {},\n-\n- /**\n- * APIMethod: commit\n- * Go over the features and for each take action\n- * based on the feature state. Possible actions are create,\n- * update and delete.\n- *\n- * Parameters:\n- * features - {Array({})}\n- * options - {Object} Object whose possible keys are \"create\", \"update\",\n- * \"delete\", \"callback\" and \"scope\", the values referenced by the\n- * first three are objects as passed to the \"create\", \"update\", and\n- * \"delete\" methods, the value referenced by the \"callback\" key is\n- * a function which is called when the commit operation is complete\n- * using the scope referenced by the \"scope\" key.\n- *\n- * Returns:\n- * {Array({})} An array of\n- * objects.\n- */\n- commit: function() {},\n-\n- /**\n- * Method: abort\n- * Abort an ongoing request.\n- *\n- * Parameters:\n- * response - {}\n- */\n- abort: function(response) {},\n-\n- /**\n- * Method: createCallback\n- * Returns a function that applies the given public method with resp and\n- * options arguments.\n- *\n- * Parameters:\n- * method - {Function} The method to be applied by the callback.\n- * response - {} The protocol response object.\n- * options - {Object} Options sent to the protocol method\n- */\n- createCallback: function(method, response, options) {\n- return OpenLayers.Function.bind(function() {\n- method.apply(this, [response, options]);\n- }, this);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Protocol\"\n-});\n-\n-/**\n- * Class: OpenLayers.Protocol.Response\n- * Protocols return Response objects to their users.\n- */\n-OpenLayers.Protocol.Response = OpenLayers.Class({\n- /**\n- * Property: code\n- * {Number} - OpenLayers.Protocol.Response.SUCCESS or\n- * OpenLayers.Protocol.Response.FAILURE\n- */\n- code: null,\n-\n- /**\n- * Property: requestType\n- * {String} The type of request this response corresponds to. Either\n- * \"create\", \"read\", \"update\" or \"delete\".\n- */\n- requestType: null,\n-\n- /**\n- * Property: last\n- * {Boolean} - true if this is the last response expected in a commit,\n- * false otherwise, defaults to true.\n- */\n- last: true,\n-\n- /**\n- * Property: features\n- * {Array({})} or {}\n- * The features returned in the response by the server. Depending on the \n- * protocol's read payload, either features or data will be populated.\n- */\n- features: null,\n-\n- /**\n- * Property: data\n- * {Object}\n- * The data returned in the response by the server. Depending on the \n- * protocol's read payload, either features or data will be populated.\n- */\n- data: null,\n-\n- /**\n- * Property: reqFeatures\n- * {Array({})} or {}\n- * The features provided by the user and placed in the request by the\n- * protocol.\n- */\n- reqFeatures: null,\n-\n- /**\n- * Property: priv\n- */\n- priv: null,\n-\n- /**\n- * Property: error\n- * {Object} The error object in case a service exception was encountered.\n- */\n- error: null,\n-\n- /**\n- * Constructor: OpenLayers.Protocol.Response\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- },\n-\n- /**\n- * Method: success\n- *\n- * Returns:\n- * {Boolean} - true on success, false otherwise\n- */\n- success: function() {\n- return this.code > 0;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Protocol.Response\"\n-});\n-\n-OpenLayers.Protocol.Response.SUCCESS = 1;\n-OpenLayers.Protocol.Response.FAILURE = 0;\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- * full text of the license. */\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- */\n-\n-/**\n- * Class: OpenLayers.Icon\n- * \n- * The icon represents a graphical icon on the screen. Typically used in\n- * conjunction with a to represent markers on a screen.\n- *\n- * An icon has a url, size and position. It also contains an offset which \n- * allows the center point to be represented correctly. This can be\n- * provided either as a fixed offset or a function provided to calculate\n- * the desired offset. \n- * \n- */\n-OpenLayers.Icon = OpenLayers.Class({\n-\n- /** \n- * Property: url \n- * {String} image url\n- */\n- url: null,\n-\n- /** \n- * Property: size \n- * {|Object} An OpenLayers.Size or\n- * an object with a 'w' and 'h' properties.\n- */\n- size: null,\n-\n- /** \n- * Property: offset \n- * {|Object} distance in pixels to offset the\n- * image when being rendered. An OpenLayers.Pixel or an object\n- * with a 'x' and 'y' properties.\n- */\n- offset: null,\n-\n- /** \n- * Property: calculateOffset \n- * {Function} Function to calculate the offset (based on the size)\n- */\n- calculateOffset: null,\n-\n- /** \n- * Property: imageDiv \n- * {DOMElement} \n- */\n- imageDiv: null,\n-\n- /** \n- * Property: px \n- * {|Object} An OpenLayers.Pixel or an object\n- * with a 'x' and 'y' properties.\n- */\n- px: null,\n-\n- /** \n- * Constructor: OpenLayers.Icon\n- * Creates an icon, which is an image tag in a div. \n- *\n- * url - {String} \n- * size - {|Object} An OpenLayers.Size or an\n- * object with a 'w' and 'h'\n- * properties.\n- * offset - {|Object} An OpenLayers.Pixel or an\n- * object with a 'x' and 'y'\n- * properties.\n- * calculateOffset - {Function} \n- */\n- initialize: function(url, size, offset, calculateOffset) {\n- this.url = url;\n- this.size = size || {\n- w: 20,\n- h: 20\n- };\n- this.offset = offset || {\n- x: -(this.size.w / 2),\n- y: -(this.size.h / 2)\n- };\n- this.calculateOffset = calculateOffset;\n-\n- var id = OpenLayers.Util.createUniqueID(\"OL_Icon_\");\n- this.imageDiv = OpenLayers.Util.createAlphaImageDiv(id);\n- },\n-\n- /** \n- * Method: destroy\n- * Nullify references and remove event listeners to prevent circular \n- * references and memory leaks\n- */\n- destroy: function() {\n- // erase any drawn elements\n- this.erase();\n-\n- OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);\n- this.imageDiv.innerHTML = \"\";\n- this.imageDiv = null;\n- },\n-\n- /** \n- * Method: clone\n- * \n- * Returns:\n- * {} A fresh copy of the icon.\n- */\n- clone: function() {\n- return new OpenLayers.Icon(this.url,\n- this.size,\n- this.offset,\n- this.calculateOffset);\n- },\n-\n- /**\n- * Method: setSize\n- * \n- * Parameters:\n- * size - {|Object} An OpenLayers.Size or\n- * an object with a 'w' and 'h' properties.\n- */\n- setSize: function(size) {\n- if (size != null) {\n- this.size = size;\n- }\n- this.draw();\n- },\n-\n- /**\n- * Method: setUrl\n- * \n- * Parameters:\n- * url - {String} \n- */\n- setUrl: function(url) {\n- if (url != null) {\n- this.url = url;\n- }\n- this.draw();\n- },\n-\n- /** \n- * Method: draw\n- * Move the div to the given pixel.\n- * \n- * Parameters:\n- * px - {|Object} An OpenLayers.Pixel or an\n- * object with a 'x' and 'y' properties.\n- * \n- * Returns:\n- * {DOMElement} A new DOM Image of this icon set at the location passed-in\n- */\n- draw: function(px) {\n- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,\n- null,\n- null,\n- this.size,\n- this.url,\n- \"absolute\");\n- this.moveTo(px);\n- return this.imageDiv;\n- },\n-\n- /** \n- * Method: erase\n- * Erase the underlying image element.\n- */\n- erase: function() {\n- if (this.imageDiv != null && this.imageDiv.parentNode != null) {\n- OpenLayers.Element.remove(this.imageDiv);\n- }\n- },\n-\n- /** \n- * Method: setOpacity\n- * Change the icon's opacity\n- *\n- * Parameters:\n- * opacity - {float} \n- */\n- setOpacity: function(opacity) {\n- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, null, null,\n- null, null, null, null, opacity);\n-\n- },\n-\n- /**\n- * Method: moveTo\n- * move icon to passed in px.\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 no px passed in, use stored location\n- if (px != null) {\n- this.px = px;\n- }\n-\n- if (this.imageDiv != null) {\n- if (this.px == null) {\n- this.display(false);\n- } else {\n- if (this.calculateOffset) {\n- this.offset = this.calculateOffset(this.size);\n- }\n- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, {\n- x: this.px.x + this.offset.x,\n- y: this.px.y + this.offset.y\n- });\n- }\n- }\n- },\n-\n- /** \n- * Method: display\n- * Hide or show the icon\n- *\n- * Parameters:\n- * display - {Boolean} \n- */\n- display: function(display) {\n- this.imageDiv.style.display = (display) ? \"\" : \"none\";\n- },\n-\n-\n- /**\n- * APIMethod: isDrawn\n- * \n- * Returns:\n- * {Boolean} Whether or not the icon is drawn.\n- */\n- isDrawn: function() {\n- // nodeType 11 for ie, whose nodes *always* have a parentNode\n- // (of type document fragment)\n- var isDrawn = (this.imageDiv && this.imageDiv.parentNode &&\n- (this.imageDiv.parentNode.nodeType != 11));\n-\n- return isDrawn;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Icon\"\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/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/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- * full text of the license. */\n-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Style.js\n- */\n-\n-/**\n- * Class: OpenLayers.Rule\n- * This class represents an SLD Rule, as being used for rule-based SLD styling.\n- */\n-OpenLayers.Rule = 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} name of this rule\n- */\n- name: null,\n-\n- /**\n- * Property: title\n- * {String} Title of this rule (set if included in SLD)\n- */\n- title: null,\n-\n- /**\n- * Property: description\n- * {String} Description of this rule (set if abstract is included in SLD)\n- */\n- description: null,\n-\n- /**\n- * Property: context\n- * {Object} An optional object with properties that the rule should be\n- * evaluated against. If no context is specified, feature.attributes will\n- * be used.\n- */\n- context: null,\n-\n- /**\n- * Property: filter\n- * {} Optional filter for the rule.\n- */\n- filter: null,\n-\n- /**\n- * Property: elseFilter\n- * {Boolean} Determines whether this rule is only to be applied only if\n- * no other rules match (ElseFilter according to the SLD specification). \n- * Default is false. For instances of OpenLayers.Rule, if elseFilter is\n- * false, the rule will always apply. For subclasses, the else property is \n- * ignored.\n- */\n- elseFilter: false,\n-\n- /**\n- * Property: symbolizer\n- * {Object} Symbolizer or hash of symbolizers for this rule. If hash of\n- * symbolizers, keys are one or more of [\"Point\", \"Line\", \"Polygon\"]. The\n- * latter if useful if it is required to style e.g. vertices of a line\n- * with a point symbolizer. Note, however, that this is not implemented\n- * yet in OpenLayers, but it is the way how symbolizers are defined in\n- * SLD.\n- */\n- symbolizer: null,\n-\n- /**\n- * Property: symbolizers\n- * {Array} Collection of symbolizers associated with this rule. If \n- * provided at construction, the symbolizers array has precedence\n- * over the deprecated symbolizer property. Note that multiple \n- * symbolizers are not currently supported by the vector renderers.\n- * Rules with multiple symbolizers are currently only useful for\n- * maintaining elements in an SLD document.\n- */\n- symbolizers: null,\n-\n- /**\n- * APIProperty: minScaleDenominator\n- * {Number} or {String} minimum scale at which to draw the feature.\n- * In the case of a String, this can be a combination of text and\n- * propertyNames in the form \"literal ${propertyName}\"\n- */\n- minScaleDenominator: null,\n-\n- /**\n- * APIProperty: maxScaleDenominator\n- * {Number} or {String} maximum scale at which to draw the feature.\n- * In the case of a String, this can be a combination of text and\n- * propertyNames in the form \"literal ${propertyName}\"\n- */\n- maxScaleDenominator: null,\n-\n- /** \n- * Constructor: OpenLayers.Rule\n- * Creates a Rule.\n- *\n- * Parameters:\n- * options - {Object} An optional object with properties to set on the\n- * rule\n- * \n- * Returns:\n- * {}\n- */\n- initialize: function(options) {\n- this.symbolizer = {};\n- OpenLayers.Util.extend(this, options);\n- if (this.symbolizers) {\n- delete this.symbolizer;\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 in this.symbolizer) {\n- this.symbolizer[i] = null;\n- }\n- this.symbolizer = null;\n- delete this.symbolizers;\n- },\n-\n- /**\n- * APIMethod: evaluate\n- * evaluates this rule for a specific feature\n- * \n- * Parameters:\n- * feature - {} feature to apply the rule to.\n- * \n- * Returns:\n- * {Boolean} true if the rule applies, false if it does not.\n- * This rule is the default rule and always returns true.\n- */\n- evaluate: function(feature) {\n- var context = this.getContext(feature);\n- var applies = true;\n-\n- if (this.minScaleDenominator || this.maxScaleDenominator) {\n- var scale = feature.layer.map.getScale();\n- }\n-\n- // check if within minScale/maxScale bounds\n- if (this.minScaleDenominator) {\n- applies = scale >= OpenLayers.Style.createLiteral(\n- this.minScaleDenominator, context);\n- }\n- if (applies && this.maxScaleDenominator) {\n- applies = scale < OpenLayers.Style.createLiteral(\n- this.maxScaleDenominator, context);\n- }\n-\n- // check if optional filter applies\n- if (applies && this.filter) {\n- // feature id filters get the feature, others get the context\n- if (this.filter.CLASS_NAME == \"OpenLayers.Filter.FeatureId\") {\n- applies = this.filter.evaluate(feature);\n- } else {\n- applies = this.filter.evaluate(context);\n- }\n- }\n-\n- return applies;\n- },\n-\n- /**\n- * Method: getContext\n- * Gets the context for evaluating this rule\n- * \n- * Paramters:\n- * feature - {} feature to take the context from if\n- * none is specified.\n- */\n- getContext: function(feature) {\n- var context = this.context;\n- if (!context) {\n- context = feature.attributes || feature.data;\n- }\n- if (typeof this.context == \"function\") {\n- context = this.context(feature);\n- }\n- return context;\n- },\n-\n- /**\n- * APIMethod: clone\n- * Clones this rule.\n- * \n- * Returns:\n- * {} Clone of this rule.\n- */\n- clone: function() {\n- var options = OpenLayers.Util.extend({}, this);\n- if (this.symbolizers) {\n- // clone symbolizers\n- var len = this.symbolizers.length;\n- options.symbolizers = new Array(len);\n- for (var i = 0; i < len; ++i) {\n- options.symbolizers[i] = this.symbolizers[i].clone();\n- }\n- } else {\n- // clone symbolizer\n- options.symbolizer = {};\n- var value, type;\n- for (var key in this.symbolizer) {\n- value = this.symbolizer[key];\n- type = typeof value;\n- if (type === \"object\") {\n- options.symbolizer[key] = OpenLayers.Util.extend({}, value);\n- } else if (type === \"string\") {\n- options.symbolizer[key] = value;\n- }\n- }\n- }\n- // clone filter\n- options.filter = this.filter && this.filter.clone();\n- // clone context\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/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-\n-\n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/Style.js\n- */\n-\n-/**\n- * Class: OpenLayers.Filter\n- * This class represents an OGC Filter.\n- */\n-OpenLayers.Filter = OpenLayers.Class({\n-\n- /** \n- * Constructor: OpenLayers.Filter\n- * This class represents a generic filter.\n- *\n- * Parameters:\n- * options - {Object} Optional object whose properties will be set on the\n- * instance.\n- * \n- * Returns:\n- * {}\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- },\n-\n- /** \n- * APIMethod: destroy\n- * Remove reference to anything added.\n- */\n- destroy: function() {},\n-\n- /**\n- * APIMethod: evaluate\n- * Evaluates this filter in a specific context. Instances or subclasses\n- * are supposed to override this method.\n- * \n- * Parameters:\n- * context - {Object} Context to use in evaluating the filter. If a vector\n- * feature is provided, the feature.attributes will be used as context.\n- * \n- * Returns:\n- * {Boolean} The filter applies.\n- */\n- evaluate: function(context) {\n- return true;\n- },\n-\n- /**\n- * APIMethod: clone\n- * Clones this filter. Should be implemented by subclasses.\n- * \n- * Returns:\n- * {} Clone of this filter.\n- */\n- clone: function() {\n- return null;\n- },\n-\n- /**\n- * APIMethod: toString\n- *\n- * Returns:\n- * {String} Include in your build to get a CQL\n- * representation of the filter returned. Otherwise \"[Object object]\"\n- * will be returned.\n- */\n- toString: function() {\n- var string;\n- if (OpenLayers.Format && OpenLayers.Format.CQL) {\n- string = OpenLayers.Format.CQL.prototype.write(this);\n- } else {\n- string = Object.prototype.toString.call(this);\n- }\n- return string;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Filter\"\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- *\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- }\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- 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- }\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-\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/Geometry/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-\n-/**\n- * @requires OpenLayers/Geometry.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry.Point\n- * Point geometry class. \n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Geometry.Point = OpenLayers.Class(OpenLayers.Geometry, {\n-\n- /** \n- * APIProperty: x \n- * {float} \n- */\n- x: null,\n-\n- /** \n- * APIProperty: y \n- * {float} \n- */\n- y: null,\n-\n- /**\n- * Constructor: OpenLayers.Geometry.Point\n- * Construct a point geometry.\n- *\n- * Parameters:\n- * x - {float} \n- * y - {float}\n- * \n- */\n- initialize: function(x, y) {\n- OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n-\n- this.x = parseFloat(x);\n- this.y = parseFloat(y);\n- },\n-\n- /**\n- * APIMethod: clone\n- * \n- * Returns:\n- * {} An exact clone of this OpenLayers.Geometry.Point\n- */\n- clone: function(obj) {\n- if (obj == null) {\n- obj = new OpenLayers.Geometry.Point(this.x, this.y);\n- }\n-\n- // catch any randomly tagged-on properties\n- OpenLayers.Util.applyDefaults(obj, this);\n-\n- return obj;\n- },\n-\n- /** \n- * Method: calculateBounds\n- * Create a new Bounds based on the lon/lat\n- */\n- calculateBounds: function() {\n- this.bounds = new OpenLayers.Bounds(this.x, this.y,\n- this.x, this.y);\n- },\n-\n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n- * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n- */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var details = edge && options && options.details;\n- var distance, x0, y0, x1, y1, result;\n- if (geometry instanceof OpenLayers.Geometry.Point) {\n- x0 = this.x;\n- y0 = this.y;\n- x1 = geometry.x;\n- y1 = geometry.y;\n- distance = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));\n- result = !details ?\n- distance : {\n- x0: x0,\n- y0: y0,\n- x1: x1,\n- y1: y1,\n- distance: distance\n- };\n- } else {\n- result = geometry.distanceTo(this, options);\n- if (details) {\n- // switch coord order since this geom is target\n- result = {\n- x0: result.x1,\n- y0: result.y1,\n- x1: result.x0,\n- y1: result.y0,\n- distance: result.distance\n- };\n- }\n- }\n- return result;\n- },\n-\n- /** \n- * APIMethod: equals\n- * Determine whether another geometry is equivalent to this one. Geometries\n- * are considered equivalent if all components have the same coordinates.\n- * \n- * Parameters:\n- * geom - {} The geometry to test. \n- *\n- * Returns:\n- * {Boolean} The supplied geometry is equivalent to this geometry.\n- */\n- equals: function(geom) {\n- var equals = false;\n- if (geom != null) {\n- equals = ((this.x == geom.x && this.y == geom.y) ||\n- (isNaN(this.x) && isNaN(this.y) && isNaN(geom.x) && isNaN(geom.y)));\n- }\n- return equals;\n- },\n-\n- /**\n- * Method: toShortString\n- *\n- * Returns:\n- * {String} Shortened String representation of Point object. \n- * (ex. \"5, 42\")\n- */\n- toShortString: function() {\n- return (this.x + \", \" + this.y);\n- },\n-\n- /**\n- * APIMethod: move\n- * Moves a geometry by the given displacement along positive x and y axes.\n- * This modifies the position of the geometry and clears the cached\n- * bounds.\n- *\n- * Parameters:\n- * x - {Float} Distance to move geometry in positive x direction. \n- * y - {Float} Distance to move geometry in positive y direction.\n- */\n- move: function(x, y) {\n- this.x = this.x + x;\n- this.y = this.y + y;\n- this.clearBounds();\n- },\n-\n- /**\n- * APIMethod: rotate\n- * Rotate a point around another.\n- *\n- * Parameters:\n- * angle - {Float} Rotation angle in degrees (measured counterclockwise\n- * from the positive x-axis)\n- * origin - {} Center point for the rotation\n- */\n- rotate: function(angle, origin) {\n- angle *= Math.PI / 180;\n- var radius = this.distanceTo(origin);\n- var theta = angle + Math.atan2(this.y - origin.y, this.x - origin.x);\n- this.x = origin.x + (radius * Math.cos(theta));\n- this.y = origin.y + (radius * Math.sin(theta));\n- this.clearBounds();\n- },\n-\n- /**\n- * APIMethod: getCentroid\n- *\n- * Returns:\n- * {} The centroid of the collection\n- */\n- getCentroid: function() {\n- return new OpenLayers.Geometry.Point(this.x, this.y);\n- },\n-\n- /**\n- * APIMethod: resize\n- * Resize a point relative to some origin. For points, this has the effect\n- * of scaling a vector (from the origin to the point). This method is\n- * more useful on geometry collection subclasses.\n- *\n- * Parameters:\n- * scale - {Float} Ratio of the new distance from the origin to the old\n- * distance from the origin. A scale of 2 doubles the\n- * distance between the point and origin.\n- * origin - {} Point of origin for resizing\n- * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n- * \n- * Returns:\n- * {} - The current geometry. \n- */\n- resize: function(scale, origin, ratio) {\n- ratio = (ratio == undefined) ? 1 : ratio;\n- this.x = origin.x + (scale * ratio * (this.x - origin.x));\n- this.y = origin.y + (scale * (this.y - origin.y));\n- this.clearBounds();\n- return this;\n- },\n-\n- /**\n- * APIMethod: intersects\n- * Determine if the input geometry intersects this one.\n- *\n- * Parameters:\n- * geometry - {} Any type of geometry.\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this one.\n- */\n- intersects: function(geometry) {\n- var intersect = false;\n- if (geometry.CLASS_NAME == \"OpenLayers.Geometry.Point\") {\n- intersect = this.equals(geometry);\n- } else {\n- intersect = geometry.intersects(this);\n- }\n- return intersect;\n- },\n-\n- /**\n- * APIMethod: transform\n- * Translate the x,y properties of the point from source to dest.\n- * \n- * Parameters:\n- * source - {} \n- * dest - {}\n- * \n- * Returns:\n- * {} \n- */\n- transform: function(source, dest) {\n- if ((source && dest)) {\n- OpenLayers.Projection.transform(\n- this, source, dest);\n- this.bounds = null;\n- }\n- return this;\n- },\n-\n- /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n- */\n- getVertices: function(nodes) {\n- return [this];\n- },\n-\n- CLASS_NAME: \"OpenLayers.Geometry.Point\"\n-});\n-/* ======================================================================\n- OpenLayers/Geometry/Collection.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/Geometry.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry.Collection\n- * A Collection is exactly what it sounds like: A collection of different \n- * Geometries. These are stored in the local parameter (which\n- * can be passed as a parameter to the constructor). \n- * \n- * As new geometries are added to the collection, they are NOT cloned. \n- * When removing geometries, they need to be specified by reference (ie you \n- * have to pass in the *exact* geometry to be removed).\n- * \n- * The and functions here merely iterate through\n- * the components, summing their respective areas and lengths.\n- *\n- * Create a new instance with the constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Geometry.Collection = OpenLayers.Class(OpenLayers.Geometry, {\n-\n- /**\n- * APIProperty: components\n- * {Array()} The component parts of this geometry\n- */\n- components: null,\n-\n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n- */\n- componentTypes: null,\n-\n- /**\n- * Constructor: OpenLayers.Geometry.Collection\n- * Creates a Geometry Collection -- a list of geoms.\n- *\n- * Parameters: \n- * components - {Array()} Optional array of geometries\n- *\n- */\n- initialize: function(components) {\n- OpenLayers.Geometry.prototype.initialize.apply(this, arguments);\n- this.components = [];\n- if (components != null) {\n- this.addComponents(components);\n- }\n- },\n-\n- /**\n- * APIMethod: destroy\n- * Destroy this geometry.\n- */\n- destroy: function() {\n- this.components.length = 0;\n- this.components = null;\n- OpenLayers.Geometry.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * APIMethod: clone\n- * Clone this geometry.\n- *\n- * Returns:\n- * {} An exact clone of this collection\n- */\n- clone: function() {\n- var geometry = eval(\"new \" + this.CLASS_NAME + \"()\");\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- geometry.addComponent(this.components[i].clone());\n- }\n-\n- // catch any randomly tagged-on properties\n- OpenLayers.Util.applyDefaults(geometry, this);\n-\n- return geometry;\n- },\n-\n- /**\n- * Method: getComponentsString\n- * Get a string representing the components for this collection\n- * \n- * Returns:\n- * {String} A string representation of the components of this geometry\n- */\n- getComponentsString: function() {\n- var strings = [];\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- strings.push(this.components[i].toShortString());\n- }\n- return strings.join(\",\");\n- },\n-\n- /**\n- * APIMethod: calculateBounds\n- * Recalculate the bounds by iterating through the components and \n- * calling calling extendBounds() on each item.\n- */\n- calculateBounds: function() {\n- this.bounds = null;\n- var bounds = new OpenLayers.Bounds();\n- var components = this.components;\n- if (components) {\n- for (var i = 0, len = components.length; i < len; i++) {\n- bounds.extend(components[i].getBounds());\n- }\n- }\n- // to preserve old behavior, we only set bounds if non-null\n- // in the future, we could add bounds.isEmpty()\n- if (bounds.left != null && bounds.bottom != null &&\n- bounds.right != null && bounds.top != null) {\n- this.setBounds(bounds);\n- }\n- },\n-\n- /**\n- * APIMethod: addComponents\n- * Add components to this geometry.\n- *\n- * Parameters:\n- * components - {Array()} An array of geometries to add\n- */\n- addComponents: function(components) {\n- if (!(OpenLayers.Util.isArray(components))) {\n- components = [components];\n- }\n- for (var i = 0, len = components.length; i < len; i++) {\n- this.addComponent(components[i]);\n- }\n- },\n-\n- /**\n- * Method: addComponent\n- * Add a new component (geometry) to the collection. If this.componentTypes\n- * is set, then the component class name must be in the componentTypes array.\n- *\n- * The bounds cache is reset.\n- * \n- * Parameters:\n- * component - {} A geometry to add\n- * index - {int} Optional index into the array to insert the component\n- *\n- * Returns:\n- * {Boolean} The component geometry was successfully added\n- */\n- addComponent: function(component, index) {\n- var added = false;\n- if (component) {\n- if (this.componentTypes == null ||\n- (OpenLayers.Util.indexOf(this.componentTypes,\n- component.CLASS_NAME) > -1)) {\n-\n- if (index != null && (index < this.components.length)) {\n- var components1 = this.components.slice(0, index);\n- var components2 = this.components.slice(index,\n- this.components.length);\n- components1.push(component);\n- this.components = components1.concat(components2);\n- } else {\n- this.components.push(component);\n- }\n- component.parent = this;\n- this.clearBounds();\n- added = true;\n- }\n- }\n- return added;\n- },\n-\n- /**\n- * APIMethod: removeComponents\n- * Remove components from this geometry.\n- *\n- * Parameters:\n- * components - {Array()} The components to be removed\n- *\n- * Returns: \n- * {Boolean} A component was removed.\n- */\n- removeComponents: function(components) {\n- var removed = false;\n-\n- if (!(OpenLayers.Util.isArray(components))) {\n- components = [components];\n- }\n- for (var i = components.length - 1; i >= 0; --i) {\n- removed = this.removeComponent(components[i]) || removed;\n- }\n- return removed;\n- },\n-\n- /**\n- * Method: removeComponent\n- * Remove a component from this geometry.\n- *\n- * Parameters:\n- * component - {} \n- *\n- * Returns: \n- * {Boolean} The component was removed.\n- */\n- removeComponent: function(component) {\n-\n- OpenLayers.Util.removeItem(this.components, component);\n-\n- // clearBounds() so that it gets recalculated on the next call\n- // to this.getBounds();\n- this.clearBounds();\n- return true;\n- },\n-\n- /**\n- * APIMethod: getLength\n- * Calculate the length of this geometry\n- *\n- * Returns:\n- * {Float} The length of the geometry\n- */\n- getLength: function() {\n- var length = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- length += this.components[i].getLength();\n- }\n- return length;\n- },\n-\n- /**\n- * APIMethod: getArea\n- * Calculate the area of this geometry. Note how this function is overridden\n- * in .\n- *\n- * Returns:\n- * {Float} The area of the collection by summing its parts\n- */\n- getArea: function() {\n- var area = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- area += this.components[i].getArea();\n- }\n- return area;\n- },\n-\n- /** \n- * APIMethod: getGeodesicArea\n- * Calculate the approximate area of the polygon were it projected onto\n- * the earth.\n- *\n- * Parameters:\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n- * Reference:\n- * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n- * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n- * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409\n- *\n- * Returns:\n- * {float} The approximate geodesic area of the geometry in square meters.\n- */\n- getGeodesicArea: function(projection) {\n- var area = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- area += this.components[i].getGeodesicArea(projection);\n- }\n- return area;\n- },\n-\n- /**\n- * APIMethod: getCentroid\n- *\n- * Compute the centroid for this geometry collection.\n- *\n- * Parameters:\n- * weighted - {Boolean} Perform the getCentroid computation recursively,\n- * returning an area weighted average of all geometries in this collection.\n- *\n- * Returns:\n- * {} The centroid of the collection\n- */\n- getCentroid: function(weighted) {\n- if (!weighted) {\n- return this.components.length && this.components[0].getCentroid();\n- }\n- var len = this.components.length;\n- if (!len) {\n- return false;\n- }\n-\n- var areas = [];\n- var centroids = [];\n- var areaSum = 0;\n- var minArea = Number.MAX_VALUE;\n- var component;\n- for (var i = 0; i < len; ++i) {\n- component = this.components[i];\n- var area = component.getArea();\n- var centroid = component.getCentroid(true);\n- if (isNaN(area) || isNaN(centroid.x) || isNaN(centroid.y)) {\n- continue;\n- }\n- areas.push(area);\n- areaSum += area;\n- minArea = (area < minArea && area > 0) ? area : minArea;\n- centroids.push(centroid);\n- }\n- len = areas.length;\n- if (areaSum === 0) {\n- // all the components in this collection have 0 area\n- // probably a collection of points -- weight all the points the same\n- for (var i = 0; i < len; ++i) {\n- areas[i] = 1;\n- }\n- areaSum = areas.length;\n- } else {\n- // normalize all the areas where the smallest area will get\n- // a value of 1\n- for (var i = 0; i < len; ++i) {\n- areas[i] /= minArea;\n- }\n- areaSum /= minArea;\n- }\n-\n- var xSum = 0,\n- ySum = 0,\n- centroid, area;\n- for (var i = 0; i < len; ++i) {\n- centroid = centroids[i];\n- area = areas[i];\n- xSum += centroid.x * area;\n- ySum += centroid.y * area;\n- }\n-\n- return new OpenLayers.Geometry.Point(xSum / areaSum, ySum / areaSum);\n- },\n-\n- /**\n- * APIMethod: getGeodesicLength\n- * Calculate the approximate length of the geometry were it projected onto\n- * the earth.\n- *\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n- * Returns:\n- * {Float} The appoximate geodesic length of the geometry in meters.\n- */\n- getGeodesicLength: function(projection) {\n- var length = 0.0;\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- length += this.components[i].getGeodesicLength(projection);\n- }\n- return length;\n- },\n-\n- /**\n- * APIMethod: move\n- * Moves a geometry by the given displacement along positive x and y axes.\n- * This modifies the position of the geometry and clears the cached\n- * bounds.\n- *\n- * Parameters:\n- * x - {Float} Distance to move geometry in positive x direction. \n- * y - {Float} Distance to move geometry in positive y direction.\n- */\n- move: function(x, y) {\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- this.components[i].move(x, y);\n- }\n- },\n-\n- /**\n- * APIMethod: rotate\n- * Rotate a geometry around some origin\n- *\n- * Parameters:\n- * angle - {Float} Rotation angle in degrees (measured counterclockwise\n- * from the positive x-axis)\n- * origin - {} Center point for the rotation\n- */\n- rotate: function(angle, origin) {\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- this.components[i].rotate(angle, origin);\n- }\n- },\n-\n- /**\n- * APIMethod: resize\n- * Resize a geometry relative to some origin. Use this method to apply\n- * a uniform scaling to a geometry.\n- *\n- * Parameters:\n- * scale - {Float} Factor by which to scale the geometry. A scale of 2\n- * doubles the size of the geometry in each dimension\n- * (lines, for example, will be twice as long, and polygons\n- * will have four times the area).\n- * origin - {} Point of origin for resizing\n- * ratio - {Float} Optional x:y ratio for resizing. Default ratio is 1.\n- * \n- * Returns:\n- * {} - The current geometry. \n- */\n- resize: function(scale, origin, ratio) {\n- for (var i = 0; i < this.components.length; ++i) {\n- this.components[i].resize(scale, origin, ratio);\n- }\n- return this;\n- },\n-\n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n- * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and y1 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n- */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var details = edge && options && options.details;\n- var result, best, distance;\n- var min = Number.POSITIVE_INFINITY;\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- result = this.components[i].distanceTo(geometry, options);\n- distance = details ? result.distance : result;\n- if (distance < min) {\n- min = distance;\n- best = result;\n- if (min == 0) {\n- break;\n- }\n- }\n- }\n- return best;\n- },\n-\n- /** \n- * APIMethod: equals\n- * Determine whether another geometry is equivalent to this one. Geometries\n- * are considered equivalent if all components have the same coordinates.\n- * \n- * Parameters:\n- * geometry - {} The geometry to test. \n- *\n- * Returns:\n- * {Boolean} The supplied geometry is equivalent to this geometry.\n- */\n- equals: function(geometry) {\n- var equivalent = true;\n- if (!geometry || !geometry.CLASS_NAME ||\n- (this.CLASS_NAME != geometry.CLASS_NAME)) {\n- equivalent = false;\n- } else if (!(OpenLayers.Util.isArray(geometry.components)) ||\n- (geometry.components.length != this.components.length)) {\n- equivalent = false;\n- } else {\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- if (!this.components[i].equals(geometry.components[i])) {\n- equivalent = false;\n- break;\n- }\n- }\n- }\n- return equivalent;\n- },\n-\n- /**\n- * APIMethod: transform\n- * Reproject the components geometry from source to dest.\n- * \n- * Parameters:\n- * source - {} \n- * dest - {}\n- * \n- * Returns:\n- * {} \n- */\n- transform: function(source, dest) {\n- if (source && dest) {\n- for (var i = 0, len = this.components.length; i < len; i++) {\n- var component = this.components[i];\n- component.transform(source, dest);\n- }\n- this.bounds = null;\n- }\n- return this;\n- },\n-\n- /**\n- * APIMethod: intersects\n- * Determine if the input geometry intersects this one.\n- *\n- * Parameters:\n- * geometry - {} Any type of geometry.\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this one.\n- */\n- intersects: function(geometry) {\n- var intersect = false;\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- intersect = geometry.intersects(this.components[i]);\n- if (intersect) {\n- break;\n- }\n- }\n- return intersect;\n- },\n-\n- /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n- */\n- getVertices: function(nodes) {\n- var vertices = [];\n- for (var i = 0, len = this.components.length; i < len; ++i) {\n- Array.prototype.push.apply(\n- vertices, this.components[i].getVertices(nodes)\n- );\n- }\n- return vertices;\n- },\n-\n-\n- CLASS_NAME: \"OpenLayers.Geometry.Collection\"\n-});\n-/* ======================================================================\n- OpenLayers/Geometry/MultiPoint.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/Geometry/Collection.js\n- * @requires OpenLayers/Geometry/Point.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry.MultiPoint\n- * MultiPoint is a collection of Points. Create a new instance with the\n- * constructor.\n- *\n- * Inherits from:\n- * - \n- * - \n- */\n-OpenLayers.Geometry.MultiPoint = OpenLayers.Class(\n- OpenLayers.Geometry.Collection, {\n-\n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of\n- * components that the collection can include. A null value means the\n- * component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.Point\"],\n-\n- /**\n- * Constructor: OpenLayers.Geometry.MultiPoint\n- * Create a new MultiPoint Geometry\n- *\n- * Parameters:\n- * components - {Array()} \n- *\n- * Returns:\n- * {}\n- */\n-\n- /**\n- * APIMethod: addPoint\n- * Wrapper for \n- *\n- * Parameters:\n- * point - {} Point to be added\n- * index - {Integer} Optional index\n- */\n- addPoint: function(point, index) {\n- this.addComponent(point, index);\n- },\n-\n- /**\n- * APIMethod: removePoint\n- * Wrapper for \n- *\n- * Parameters:\n- * point - {} Point to be removed\n- */\n- removePoint: function(point) {\n- this.removeComponent(point);\n- },\n-\n- CLASS_NAME: \"OpenLayers.Geometry.MultiPoint\"\n- });\n-/* ======================================================================\n- OpenLayers/Geometry/Curve.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/Geometry/MultiPoint.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry.Curve\n- * A Curve is a MultiPoint, whose points are assumed to be connected. To \n- * this end, we provide a \"getLength()\" function, which iterates through \n- * the points, summing the distances between them. \n- * \n- * Inherits: \n- * - \n- */\n-OpenLayers.Geometry.Curve = OpenLayers.Class(OpenLayers.Geometry.MultiPoint, {\n-\n- /**\n- * Property: componentTypes\n- * {Array(String)} An array of class names representing the types of \n- * components that the collection can include. A null \n- * value means the component types are not restricted.\n- */\n- componentTypes: [\"OpenLayers.Geometry.Point\"],\n-\n- /**\n- * Constructor: OpenLayers.Geometry.Curve\n- * \n- * Parameters:\n- * point - {Array()}\n- */\n-\n- /**\n- * APIMethod: getLength\n- * \n- * Returns:\n- * {Float} The length of the curve\n- */\n- getLength: function() {\n- var length = 0.0;\n- if (this.components && (this.components.length > 1)) {\n- for (var i = 1, len = this.components.length; i < len; i++) {\n- length += this.components[i - 1].distanceTo(this.components[i]);\n- }\n- }\n- return length;\n- },\n-\n- /**\n- * APIMethod: getGeodesicLength\n- * Calculate the approximate length of the geometry were it projected onto\n- * the earth.\n- *\n- * projection - {} The spatial reference system\n- * for the geometry coordinates. If not provided, Geographic/WGS84 is\n- * assumed.\n- * \n- * Returns:\n- * {Float} The appoximate geodesic length of the geometry in meters.\n- */\n- getGeodesicLength: function(projection) {\n- var geom = this; // so we can work with a clone if needed\n- if (projection) {\n- var gg = new OpenLayers.Projection(\"EPSG:4326\");\n- if (!gg.equals(projection)) {\n- geom = this.clone().transform(projection, gg);\n- }\n- }\n- var length = 0.0;\n- if (geom.components && (geom.components.length > 1)) {\n- var p1, p2;\n- for (var i = 1, len = geom.components.length; i < len; i++) {\n- p1 = geom.components[i - 1];\n- p2 = geom.components[i];\n- // this returns km and requires lon/lat properties\n- length += OpenLayers.Util.distVincenty({\n- lon: p1.x,\n- lat: p1.y\n- }, {\n- lon: p2.x,\n- lat: p2.y\n- });\n- }\n- }\n- // convert to m\n- return length * 1000;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Geometry.Curve\"\n-});\n-/* ======================================================================\n- OpenLayers/Geometry/LineString.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/Geometry/Curve.js\n- */\n-\n-/**\n- * Class: OpenLayers.Geometry.LineString\n- * A LineString is a Curve which, once two points have been added to it, can \n- * never be less than two points long.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Geometry.LineString = OpenLayers.Class(OpenLayers.Geometry.Curve, {\n-\n- /**\n- * Constructor: OpenLayers.Geometry.LineString\n- * Create a new LineString geometry\n- *\n- * Parameters:\n- * points - {Array()} An array of points used to\n- * generate the linestring\n- *\n- */\n-\n- /**\n- * APIMethod: removeComponent\n- * Only allows removal of a point if there are three or more points in \n- * the linestring. (otherwise the result would be just a single point)\n- *\n- * Parameters: \n- * point - {} The point to be removed\n- *\n- * Returns: \n- * {Boolean} The component was removed.\n- */\n- removeComponent: function(point) {\n- var removed = this.components && (this.components.length > 2);\n- if (removed) {\n- OpenLayers.Geometry.Collection.prototype.removeComponent.apply(this,\n- arguments);\n- }\n- return removed;\n- },\n-\n- /**\n- * APIMethod: intersects\n- * Test for instersection between two geometries. This is a cheapo\n- * implementation of the Bently-Ottmann algorigithm. It doesn't\n- * really keep track of a sweep line data structure. It is closer\n- * to the brute force method, except that segments are sorted and\n- * potential intersections are only calculated when bounding boxes\n- * intersect.\n- *\n- * Parameters:\n- * geometry - {}\n- *\n- * Returns:\n- * {Boolean} The input geometry intersects this geometry.\n- */\n- intersects: function(geometry) {\n- var intersect = false;\n- var type = geometry.CLASS_NAME;\n- if (type == \"OpenLayers.Geometry.LineString\" ||\n- type == \"OpenLayers.Geometry.LinearRing\" ||\n- type == \"OpenLayers.Geometry.Point\") {\n- var segs1 = this.getSortedSegments();\n- var segs2;\n- if (type == \"OpenLayers.Geometry.Point\") {\n- segs2 = [{\n- x1: geometry.x,\n- y1: geometry.y,\n- x2: geometry.x,\n- y2: geometry.y\n- }];\n- } else {\n- segs2 = geometry.getSortedSegments();\n- }\n- var seg1, seg1x1, seg1x2, seg1y1, seg1y2,\n- seg2, seg2y1, seg2y2;\n- // sweep right\n- outer: for (var i = 0, len = segs1.length; i < len; ++i) {\n- seg1 = segs1[i];\n- seg1x1 = seg1.x1;\n- seg1x2 = seg1.x2;\n- seg1y1 = seg1.y1;\n- seg1y2 = seg1.y2;\n- inner: for (var j = 0, jlen = segs2.length; j < jlen; ++j) {\n- seg2 = segs2[j];\n- if (seg2.x1 > seg1x2) {\n- // seg1 still left of seg2\n- break;\n- }\n- if (seg2.x2 < seg1x1) {\n- // seg2 still left of seg1\n- continue;\n- }\n- seg2y1 = seg2.y1;\n- seg2y2 = seg2.y2;\n- if (Math.min(seg2y1, seg2y2) > Math.max(seg1y1, seg1y2)) {\n- // seg2 above seg1\n- continue;\n- }\n- if (Math.max(seg2y1, seg2y2) < Math.min(seg1y1, seg1y2)) {\n- // seg2 below seg1\n- continue;\n- }\n- if (OpenLayers.Geometry.segmentsIntersect(seg1, seg2)) {\n- intersect = true;\n- break outer;\n- }\n- }\n- }\n- } else {\n- intersect = geometry.intersects(this);\n- }\n- return intersect;\n- },\n-\n- /**\n- * Method: getSortedSegments\n- *\n- * Returns:\n- * {Array} An array of segment objects. Segment objects have properties\n- * x1, y1, x2, and y2. The start point is represented by x1 and y1.\n- * The end point is represented by x2 and y2. Start and end are\n- * ordered so that x1 < x2.\n- */\n- getSortedSegments: function() {\n- var numSeg = this.components.length - 1;\n- var segments = new Array(numSeg),\n- point1, point2;\n- for (var i = 0; i < numSeg; ++i) {\n- point1 = this.components[i];\n- point2 = this.components[i + 1];\n- if (point1.x < point2.x) {\n- segments[i] = {\n- x1: point1.x,\n- y1: point1.y,\n- x2: point2.x,\n- y2: point2.y\n- };\n- } else {\n- segments[i] = {\n- x1: point2.x,\n- y1: point2.y,\n- x2: point1.x,\n- y2: point1.y\n- };\n- }\n- }\n- // more efficient to define this somewhere static\n- function byX1(seg1, seg2) {\n- return seg1.x1 - seg2.x1;\n- }\n- return segments.sort(byX1);\n- },\n-\n- /**\n- * Method: splitWithSegment\n- * Split this geometry with the given segment.\n- *\n- * Parameters:\n- * seg - {Object} An object with x1, y1, x2, and y2 properties referencing\n- * segment endpoint coordinates.\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source segment must be within the\n- * tolerance distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of one of the source segment's\n- * endpoints will be assumed to occur at the endpoint.\n- *\n- * Returns:\n- * {Object} An object with *lines* and *points* properties. If the given\n- * segment intersects this linestring, the lines array will reference\n- * geometries that result from the split. The points array will contain\n- * all intersection points. Intersection points are sorted along the\n- * segment (in order from x1,y1 to x2,y2).\n- */\n- splitWithSegment: function(seg, options) {\n- var edge = !(options && options.edge === false);\n- var tolerance = options && options.tolerance;\n- var lines = [];\n- var verts = this.getVertices();\n- var points = [];\n- var intersections = [];\n- var split = false;\n- var vert1, vert2, point;\n- var node, vertex, target;\n- var interOptions = {\n- point: true,\n- tolerance: tolerance\n- };\n- var result = null;\n- for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n- vert1 = verts[i];\n- points.push(vert1.clone());\n- vert2 = verts[i + 1];\n- target = {\n- x1: vert1.x,\n- y1: vert1.y,\n- x2: vert2.x,\n- y2: vert2.y\n- };\n- point = OpenLayers.Geometry.segmentsIntersect(\n- seg, target, interOptions\n- );\n- if (point instanceof OpenLayers.Geometry.Point) {\n- if ((point.x === seg.x1 && point.y === seg.y1) ||\n- (point.x === seg.x2 && point.y === seg.y2) ||\n- point.equals(vert1) || point.equals(vert2)) {\n- vertex = true;\n- } else {\n- vertex = false;\n- }\n- if (vertex || edge) {\n- // push intersections different than the previous\n- if (!point.equals(intersections[intersections.length - 1])) {\n- intersections.push(point.clone());\n- }\n- if (i === 0) {\n- if (point.equals(vert1)) {\n- continue;\n- }\n- }\n- if (point.equals(vert2)) {\n- continue;\n- }\n- split = true;\n- if (!point.equals(vert1)) {\n- points.push(point);\n- }\n- lines.push(new OpenLayers.Geometry.LineString(points));\n- points = [point.clone()];\n- }\n- }\n- }\n- if (split) {\n- points.push(vert2.clone());\n- lines.push(new OpenLayers.Geometry.LineString(points));\n- }\n- if (intersections.length > 0) {\n- // sort intersections along segment\n- var xDir = seg.x1 < seg.x2 ? 1 : -1;\n- var yDir = seg.y1 < seg.y2 ? 1 : -1;\n- result = {\n- lines: lines,\n- points: intersections.sort(function(p1, p2) {\n- return (xDir * p1.x - xDir * p2.x) || (yDir * p1.y - yDir * p2.y);\n- })\n- };\n- }\n- return result;\n- },\n-\n- /**\n- * Method: split\n- * Use this geometry (the source) to attempt to split a target geometry.\n- * \n- * Parameters:\n- * target - {} The target geometry.\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * mutual - {Boolean} Split the source geometry in addition to the target\n- * geometry. Default is false.\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source must be within the tolerance\n- * distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of an existing vertex on the source\n- * will be assumed to occur at the vertex.\n- * \n- * Returns:\n- * {Array} A list of geometries (of this same type as the target) that\n- * result from splitting the target with the source geometry. The\n- * source and target geometry will remain unmodified. If no split\n- * results, null will be returned. If mutual is true and a split\n- * results, return will be an array of two arrays - the first will be\n- * all geometries that result from splitting the source geometry and\n- * the second will be all geometries that result from splitting the\n- * target geometry.\n- */\n- split: function(target, options) {\n- var results = null;\n- var mutual = options && options.mutual;\n- var sourceSplit, targetSplit, sourceParts, targetParts;\n- if (target instanceof OpenLayers.Geometry.LineString) {\n- var verts = this.getVertices();\n- var vert1, vert2, seg, splits, lines, point;\n- var points = [];\n- sourceParts = [];\n- for (var i = 0, stop = verts.length - 2; i <= stop; ++i) {\n- vert1 = verts[i];\n- vert2 = verts[i + 1];\n- seg = {\n- x1: vert1.x,\n- y1: vert1.y,\n- x2: vert2.x,\n- y2: vert2.y\n- };\n- targetParts = targetParts || [target];\n- if (mutual) {\n- points.push(vert1.clone());\n- }\n- for (var j = 0; j < targetParts.length; ++j) {\n- splits = targetParts[j].splitWithSegment(seg, options);\n- if (splits) {\n- // splice in new features\n- lines = splits.lines;\n- if (lines.length > 0) {\n- lines.unshift(j, 1);\n- Array.prototype.splice.apply(targetParts, lines);\n- j += lines.length - 2;\n- }\n- if (mutual) {\n- for (var k = 0, len = splits.points.length; k < len; ++k) {\n- point = splits.points[k];\n- if (!point.equals(vert1)) {\n- points.push(point);\n- sourceParts.push(new OpenLayers.Geometry.LineString(points));\n- if (point.equals(vert2)) {\n- points = [];\n- } else {\n- points = [point.clone()];\n- }\n- }\n- }\n- }\n- }\n- }\n- }\n- if (mutual && sourceParts.length > 0 && points.length > 0) {\n- points.push(vert2.clone());\n- sourceParts.push(new OpenLayers.Geometry.LineString(points));\n- }\n- } else {\n- results = target.splitWith(this, options);\n- }\n- if (targetParts && targetParts.length > 1) {\n- targetSplit = true;\n- } else {\n- targetParts = [];\n- }\n- if (sourceParts && sourceParts.length > 1) {\n- sourceSplit = true;\n- } else {\n- sourceParts = [];\n- }\n- if (targetSplit || sourceSplit) {\n- if (mutual) {\n- results = [sourceParts, targetParts];\n- } else {\n- results = targetParts;\n- }\n- }\n- return results;\n- },\n-\n- /**\n- * Method: splitWith\n- * Split this geometry (the target) with the given geometry (the source).\n- *\n- * Parameters:\n- * geometry - {} A geometry used to split this\n- * geometry (the source).\n- * options - {Object} Properties of this object will be used to determine\n- * how the split is conducted.\n- *\n- * Valid options:\n- * mutual - {Boolean} Split the source geometry in addition to the target\n- * geometry. Default is false.\n- * edge - {Boolean} Allow splitting when only edges intersect. Default is\n- * true. If false, a vertex on the source must be within the tolerance\n- * distance of the intersection to be considered a split.\n- * tolerance - {Number} If a non-null value is provided, intersections\n- * within the tolerance distance of an existing vertex on the source\n- * will be assumed to occur at the vertex.\n- * \n- * Returns:\n- * {Array} A list of geometries (of this same type as the target) that\n- * result from splitting the target with the source geometry. The\n- * source and target geometry will remain unmodified. If no split\n- * results, null will be returned. If mutual is true and a split\n- * results, return will be an array of two arrays - the first will be\n- * all geometries that result from splitting the source geometry and\n- * the second will be all geometries that result from splitting the\n- * target geometry.\n- */\n- splitWith: function(geometry, options) {\n- return geometry.split(this, options);\n-\n- },\n-\n- /**\n- * APIMethod: getVertices\n- * Return a list of all points in this geometry.\n- *\n- * Parameters:\n- * nodes - {Boolean} For lines, only return vertices that are\n- * endpoints. If false, for lines, only vertices that are not\n- * endpoints will be returned. If not provided, all vertices will\n- * be returned.\n- *\n- * Returns:\n- * {Array} A list of all vertices in the geometry.\n- */\n- getVertices: function(nodes) {\n- var vertices;\n- if (nodes === true) {\n- vertices = [\n- this.components[0],\n- this.components[this.components.length - 1]\n- ];\n- } else if (nodes === false) {\n- vertices = this.components.slice(1, this.components.length - 1);\n- } else {\n- vertices = this.components.slice();\n- }\n- return vertices;\n- },\n-\n- /**\n- * APIMethod: distanceTo\n- * Calculate the closest distance between two geometries (on the x-y plane).\n- *\n- * Parameters:\n- * geometry - {} The target geometry.\n- * options - {Object} Optional properties for configuring the distance\n- * calculation.\n- *\n- * Valid options:\n- * details - {Boolean} Return details from the distance calculation.\n- * Default is false.\n- * edge - {Boolean} Calculate the distance from this geometry to the\n- * nearest edge of the target geometry. Default is true. If true,\n- * calling distanceTo from a geometry that is wholly contained within\n- * the target will result in a non-zero distance. If false, whenever\n- * geometries intersect, calling distanceTo will return 0. If false,\n- * details cannot be returned.\n- *\n- * Returns:\n- * {Number | Object} The distance between this geometry and the target.\n- * If details is true, the return will be an object with distance,\n- * x0, y0, x1, and x2 properties. The x0 and y0 properties represent\n- * the coordinates of the closest point on this geometry. The x1 and y1\n- * properties represent the coordinates of the closest point on the\n- * target geometry.\n- */\n- distanceTo: function(geometry, options) {\n- var edge = !(options && options.edge === false);\n- var details = edge && options && options.details;\n- var result, best = {};\n- var min = Number.POSITIVE_INFINITY;\n- if (geometry instanceof OpenLayers.Geometry.Point) {\n- var segs = this.getSortedSegments();\n- var x = geometry.x;\n- var y = geometry.y;\n- var seg;\n- for (var i = 0, len = segs.length; i < len; ++i) {\n- seg = segs[i];\n- result = OpenLayers.Geometry.distanceToSegment(geometry, seg);\n- if (result.distance < min) {\n- min = result.distance;\n- best = result;\n- if (min === 0) {\n- break;\n- }\n- } else {\n- // if distance increases and we cross y0 to the right of x0, no need to keep looking.\n- if (seg.x2 > x && ((y > seg.y1 && y < seg.y2) || (y < seg.y1 && y > seg.y2))) {\n- break;\n- }\n- }\n- }\n- if (details) {\n- best = {\n- distance: best.distance,\n- x0: best.x,\n- y0: best.y,\n- x1: x,\n- y1: y\n- };\n- } else {\n- best = best.distance;\n- }\n- } else if (geometry instanceof OpenLayers.Geometry.LineString) {\n- var segs0 = this.getSortedSegments();\n- var segs1 = geometry.getSortedSegments();\n- var seg0, seg1, intersection, x0, y0;\n- var len1 = segs1.length;\n- var interOptions = {\n- point: true\n- };\n- outer: for (var i = 0, len = segs0.length; i < len; ++i) {\n- seg0 = segs0[i];\n- x0 = seg0.x1;\n- y0 = seg0.y1;\n- for (var j = 0; j < len1; ++j) {\n- seg1 = segs1[j];\n- intersection = OpenLayers.Geometry.segmentsIntersect(seg0, seg1, interOptions);\n- if (intersection) {\n- min = 0;\n- best = {\n- distance: 0,\n- x0: intersection.x,\n- y0: intersection.y,\n- x1: intersection.x,\n- y1: intersection.y\n- };\n- break outer;\n- } else {\n- result = OpenLayers.Geometry.distanceToSegment({\n- x: x0,\n- y: y0\n- }, seg1);\n- if (result.distance < min) {\n- min = result.distance;\n- best = {\n- distance: min,\n- x0: x0,\n- y0: y0,\n- x1: result.x,\n- y1: result.y\n- };\n- }\n- }\n- }\n- }\n- if (!details) {\n- best = best.distance;\n- }\n- if (min !== 0) {\n- // check the final vertex in this line's sorted segments\n- if (seg0) {\n- result = geometry.distanceTo(\n- new OpenLayers.Geometry.Point(seg0.x2, seg0.y2),\n- options\n- );\n- var dist = details ? result.distance : result;\n- if (dist < min) {\n- if (details) {\n- best = {\n- distance: min,\n- x0: result.x1,\n- y0: result.y1,\n- x1: result.x0,\n- y1: result.y0\n- };\n- } else {\n- best = dist;\n- }\n- }\n- }\n- }\n- } else {\n- best = geometry.distanceTo(this, options);\n- // swap since target comes from this line\n- if (details) {\n- best = {\n- distance: best.distance,\n- x0: best.x1,\n- y0: best.y1,\n- x1: best.x0,\n- y1: best.y0\n- };\n- }\n- }\n- return best;\n- },\n-\n- /**\n- * APIMethod: simplify\n- * This function will return a simplified LineString.\n- * Simplification is based on the Douglas-Peucker algorithm.\n- *\n- *\n- * Parameters:\n- * tolerance - {number} threshhold for simplification in map units\n- *\n- * Returns:\n- * {OpenLayers.Geometry.LineString} the simplified LineString\n- */\n- simplify: function(tolerance) {\n- if (this && this !== null) {\n- var points = this.getVertices();\n- if (points.length < 3) {\n- return this;\n- }\n-\n- var compareNumbers = function(a, b) {\n- return (a - b);\n- };\n-\n- /**\n- * Private function doing the Douglas-Peucker reduction\n- */\n- var douglasPeuckerReduction = function(points, firstPoint, lastPoint, tolerance) {\n- var maxDistance = 0;\n- var indexFarthest = 0;\n-\n- for (var index = firstPoint, distance; index < lastPoint; index++) {\n- distance = perpendicularDistance(points[firstPoint], points[lastPoint], points[index]);\n- if (distance > maxDistance) {\n- maxDistance = distance;\n- indexFarthest = index;\n- }\n- }\n-\n- if (maxDistance > tolerance && indexFarthest != firstPoint) {\n- //Add the largest point that exceeds the tolerance\n- pointIndexsToKeep.push(indexFarthest);\n- douglasPeuckerReduction(points, firstPoint, indexFarthest, tolerance);\n- douglasPeuckerReduction(points, indexFarthest, lastPoint, tolerance);\n- }\n- };\n-\n- /**\n- * Private function calculating the perpendicular distance\n- * TODO: check whether OpenLayers.Geometry.LineString::distanceTo() is faster or slower\n- */\n- var perpendicularDistance = function(point1, point2, point) {\n- //Area = |(1/2)(x1y2 + x2y3 + x3y1 - x2y1 - x3y2 - x1y3)| *Area of triangle\n- //Base = v((x1-x2)\u00b2+(x1-x2)\u00b2) *Base of Triangle*\n- //Area = .5*Base*H *Solve for height\n- //Height = Area/.5/Base\n-\n- var area = Math.abs(0.5 * (point1.x * point2.y + point2.x * point.y + point.x * point1.y - point2.x * point1.y - point.x * point2.y - point1.x * point.y));\n- var bottom = Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));\n- var height = area / bottom * 2;\n-\n- return height;\n- };\n-\n- var firstPoint = 0;\n- var lastPoint = points.length - 1;\n- var pointIndexsToKeep = [];\n-\n- //Add the first and last index to the keepers\n- pointIndexsToKeep.push(firstPoint);\n- pointIndexsToKeep.push(lastPoint);\n-\n- //The first and the last point cannot be the same\n- while (points[firstPoint].equals(points[lastPoint])) {\n- lastPoint--;\n- //Addition: the first point not equal to first point in the LineString is kept as well\n- pointIndexsToKeep.push(lastPoint);\n- }\n-\n- douglasPeuckerReduction(points, firstPoint, lastPoint, tolerance);\n- var returnPoints = [];\n- pointIndexsToKeep.sort(compareNumbers);\n- for (var index = 0; index < pointIndexsToKeep.length; index++) {\n- returnPoints.push(points[pointIndexsToKeep[index]]);\n- }\n- return new OpenLayers.Geometry.LineString(returnPoints);\n-\n- } else {\n- return this;\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Geometry.LineString\"\n-});\n-/* ======================================================================\n- OpenLayers/Geometry/MultiLineString.js\n- ====================================================================== */\n+ CLASS_NAME: \"OpenLayers.Geometry.LineString\"\n+});\n+/* ======================================================================\n+ OpenLayers/Geometry/MultiLineString.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@@ -22754,14 +15841,104 @@\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/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+\n+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/Style.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Filter\n+ * This class represents an OGC Filter.\n+ */\n+OpenLayers.Filter = OpenLayers.Class({\n+\n+ /** \n+ * Constructor: OpenLayers.Filter\n+ * This class represents a generic filter.\n+ *\n+ * Parameters:\n+ * options - {Object} Optional object whose properties will be set on the\n+ * instance.\n+ * \n+ * Returns:\n+ * {}\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ },\n+\n+ /** \n+ * APIMethod: destroy\n+ * Remove reference to anything added.\n+ */\n+ destroy: function() {},\n+\n+ /**\n+ * APIMethod: evaluate\n+ * Evaluates this filter in a specific context. Instances or subclasses\n+ * are supposed to override this method.\n+ * \n+ * Parameters:\n+ * context - {Object} Context to use in evaluating the filter. If a vector\n+ * feature is provided, the feature.attributes will be used as context.\n+ * \n+ * Returns:\n+ * {Boolean} The filter applies.\n+ */\n+ evaluate: function(context) {\n+ return true;\n+ },\n+\n+ /**\n+ * APIMethod: clone\n+ * Clones this filter. Should be implemented by subclasses.\n+ * \n+ * Returns:\n+ * {} Clone of this filter.\n+ */\n+ clone: function() {\n+ return null;\n+ },\n+\n+ /**\n+ * APIMethod: toString\n+ *\n+ * Returns:\n+ * {String} Include in your build to get a CQL\n+ * representation of the filter returned. Otherwise \"[Object object]\"\n+ * will be returned.\n+ */\n+ toString: function() {\n+ var string;\n+ if (OpenLayers.Format && OpenLayers.Format.CQL) {\n+ string = OpenLayers.Format.CQL.prototype.write(this);\n+ } else {\n+ string = Object.prototype.toString.call(this);\n+ }\n+ return string;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Filter\"\n+});\n+/* ======================================================================\n OpenLayers/Filter/Spatial.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@@ -28848,3971 +22025,5256 @@\n rawDataOutput: {\n identifier: output.identifier,\n mimeType: this.findMimeType(output.complexOutput.supported.formats, options.supportedFormats)\n }\n };\n },\n \n- /**\n- * Method: getOutputIndex\n- * Gets the index of a processOutput by its identifier\n- *\n- * Parameters:\n- * outputs - {Array} The processOutputs array to look at\n- * identifier - {String} The identifier of the output\n- *\n- * Returns\n- * {Integer} The index of the processOutput with the provided identifier\n- * in the outputs array.\n- */\n- getOutputIndex: function(outputs, identifier) {\n- var output;\n- if (identifier) {\n- for (var i = outputs.length - 1; i >= 0; --i) {\n- if (outputs[i].identifier === identifier) {\n- output = i;\n- break;\n+ /**\n+ * Method: getOutputIndex\n+ * Gets the index of a processOutput by its identifier\n+ *\n+ * Parameters:\n+ * outputs - {Array} The processOutputs array to look at\n+ * identifier - {String} The identifier of the output\n+ *\n+ * Returns\n+ * {Integer} The index of the processOutput with the provided identifier\n+ * in the outputs array.\n+ */\n+ getOutputIndex: function(outputs, identifier) {\n+ var output;\n+ if (identifier) {\n+ for (var i = outputs.length - 1; i >= 0; --i) {\n+ if (outputs[i].identifier === identifier) {\n+ output = i;\n+ break;\n+ }\n+ }\n+ } else {\n+ output = 0;\n+ }\n+ return output;\n+ },\n+\n+ /**\n+ * Method: chainProcess\n+ * Sets a fully configured chained process as input for this process.\n+ *\n+ * Parameters:\n+ * input - {Object} The dataInput that the chained process provides.\n+ * chainLink - {} The process to chain.\n+ */\n+ chainProcess: function(input, chainLink) {\n+ var output = this.getOutputIndex(\n+ chainLink.process.description.processOutputs, chainLink.output\n+ );\n+ input.reference.mimeType = this.findMimeType(\n+ input.complexData.supported.formats,\n+ chainLink.process.description.processOutputs[output].complexOutput.supported.formats\n+ );\n+ var formats = {};\n+ formats[input.reference.mimeType] = true;\n+ chainLink.process.setResponseForm({\n+ outputIndex: output,\n+ supportedFormats: formats\n+ });\n+ input.reference.body = chainLink.process.description;\n+ while (this.executeCallbacks.length > 0) {\n+ this.executeCallbacks[0]();\n+ }\n+ },\n+\n+ /**\n+ * Method: toFeatures\n+ * Converts spatial input into features so it can be processed by\n+ * instances.\n+ *\n+ * Parameters:\n+ * source - {Mixed} An , an\n+ * , or an array of geometries or features\n+ *\n+ * Returns:\n+ * {Array()}\n+ */\n+ toFeatures: function(source) {\n+ var isArray = OpenLayers.Util.isArray(source);\n+ if (!isArray) {\n+ source = [source];\n+ }\n+ var target = new Array(source.length),\n+ current;\n+ for (var i = 0, ii = source.length; i < ii; ++i) {\n+ current = source[i];\n+ target[i] = current instanceof OpenLayers.Feature.Vector ?\n+ current : new OpenLayers.Feature.Vector(current);\n+ }\n+ return isArray ? target : target[0];\n+ },\n+\n+ /**\n+ * Method: findMimeType\n+ * Finds a supported mime type.\n+ *\n+ * Parameters:\n+ * sourceFormats - {Object} An object literal with mime types as key and\n+ * true as value for supported formats.\n+ * targetFormats - {Object} Like , but optional to check for\n+ * supported mime types on a different target than this process.\n+ * Default is to check against this process's supported formats.\n+ *\n+ * Returns:\n+ * {String} A supported mime type.\n+ */\n+ findMimeType: function(sourceFormats, targetFormats) {\n+ targetFormats = targetFormats || this.formats;\n+ for (var f in sourceFormats) {\n+ if (f in targetFormats) {\n+ return f;\n+ }\n+ }\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.WPSProcess\"\n+\n+});\n+\n+/**\n+ * Class: OpenLayers.WPSProcess.ChainLink\n+ * Type for chaining processes.\n+ */\n+OpenLayers.WPSProcess.ChainLink = OpenLayers.Class({\n+\n+ /**\n+ * Property: process\n+ * {} The process to chain\n+ */\n+ process: null,\n+\n+ /**\n+ * Property: output\n+ * {String} The output identifier of the output we are going to use as\n+ * input for another process.\n+ */\n+ output: null,\n+\n+ /**\n+ * Constructor: OpenLayers.WPSProcess.ChainLink\n+ *\n+ * Parameters:\n+ * options - {Object} Properties to set on the instance.\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.WPSProcess.ChainLink\"\n+\n+});\n+/* ======================================================================\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+ * @requires OpenLayers/Format/XML.js\n+ * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Format.WPSDescribeProcess\n+ * Read WPS DescribeProcess responses. \n+ *\n+ * Inherits from:\n+ * - \n+ */\n+OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(\n+ OpenLayers.Format.XML, {\n+\n+ /**\n+ * Constant: VERSION\n+ * {String} 1.0.0\n+ */\n+ VERSION: \"1.0.0\",\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+ /**\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: defaultPrefix\n+ */\n+ defaultPrefix: \"wps\",\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+ /**\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: 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+ /**\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+ CLASS_NAME: \"OpenLayers.Format.WPSDescribeProcess\"\n+\n+ });\n+/* ======================================================================\n+ OpenLayers/WPSClient.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+ * @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+ * 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+ */\n+ servers: 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+ */\n+ version: '1.0.0',\n+\n+ /**\n+ * Property: lazy\n+ * {Boolean} Should the DescribeProcess be deferred until a process is\n+ * fully configured? Default is false.\n+ */\n+ lazy: false,\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+ */\n+ events: null,\n+\n+ /**\n+ * Constructor: OpenLayers.WPSClient\n+ *\n+ * Parameters:\n+ * options - {Object} Object whose properties will be set on the instance.\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+ *\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+ * lazy - {Boolean} Optional. Set to true if DescribeProcess should not be\n+ * requested until a process is fully configured. Default is false.\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+ }\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+ *\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+ */\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+ * APIMethod: getProcess\n+ * Creates an .\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+ * Returns:\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: describeProcess\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+ */\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: destroy\n+ */\n+ destroy: function() {\n+ this.events.destroy();\n+ this.events = null;\n+ this.servers = null;\n+ },\n+\n+ CLASS_NAME: 'OpenLayers.WPSClient'\n+\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+\n+/**\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Util.js\n+ */\n+\n+/**\n+ * Namespace: OpenLayers.Projection\n+ * Methods for coordinate transforms between coordinate systems. By default,\n+ * OpenLayers ships with the ability to transform coordinates between\n+ * geographic (EPSG:4326) and web or spherical mercator (EPSG:900913 et al.)\n+ * coordinate reference systems. See the method for details\n+ * on usage.\n+ *\n+ * Additional transforms may be added by using the \n+ * library. If the proj4js library is included, the method \n+ * will work between any two coordinate reference systems with proj4js \n+ * definitions.\n+ *\n+ * If the proj4js library is not included, or if you wish to allow transforms\n+ * between arbitrary coordinate reference systems, use the \n+ * method to register a custom transform method.\n+ */\n+OpenLayers.Projection = OpenLayers.Class({\n+\n+ /**\n+ * Property: proj\n+ * {Object} Proj4js.Proj instance.\n+ */\n+ proj: null,\n+\n+ /**\n+ * Property: projCode\n+ * {String}\n+ */\n+ projCode: null,\n+\n+ /**\n+ * Property: titleRegEx\n+ * {RegExp} regular expression to strip the title from a proj4js definition\n+ */\n+ titleRegEx: /\\+title=[^\\+]*/,\n+\n+ /**\n+ * Constructor: OpenLayers.Projection\n+ * This class offers several methods for interacting with a wrapped \n+ * pro4js projection object. \n+ *\n+ * Parameters:\n+ * projCode - {String} A string identifying the Well Known Identifier for\n+ * the projection.\n+ * options - {Object} An optional object to set additional properties\n+ * on the projection.\n+ *\n+ * Returns:\n+ * {} A projection object.\n+ */\n+ initialize: function(projCode, options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.projCode = projCode;\n+ if (typeof Proj4js == \"object\") {\n+ this.proj = new Proj4js.Proj(projCode);\n+ }\n+ },\n+\n+ /**\n+ * APIMethod: getCode\n+ * Get the string SRS code.\n+ *\n+ * Returns:\n+ * {String} The SRS code.\n+ */\n+ getCode: function() {\n+ return this.proj ? this.proj.srsCode : this.projCode;\n+ },\n+\n+ /**\n+ * APIMethod: getUnits\n+ * Get the units string for the projection -- returns null if \n+ * proj4js is not available.\n+ *\n+ * Returns:\n+ * {String} The units abbreviation.\n+ */\n+ getUnits: function() {\n+ return this.proj ? this.proj.units : null;\n+ },\n+\n+ /**\n+ * Method: toString\n+ * Convert projection to string (getCode wrapper).\n+ *\n+ * Returns:\n+ * {String} The projection code.\n+ */\n+ toString: function() {\n+ return this.getCode();\n+ },\n+\n+ /**\n+ * Method: equals\n+ * Test equality of two projection instances. Determines equality based\n+ * soley on the projection code.\n+ *\n+ * Returns:\n+ * {Boolean} The two projections are equivalent.\n+ */\n+ equals: function(projection) {\n+ var p = projection,\n+ equals = false;\n+ if (p) {\n+ if (!(p instanceof OpenLayers.Projection)) {\n+ p = new OpenLayers.Projection(p);\n+ }\n+ if ((typeof Proj4js == \"object\") && this.proj.defData && p.proj.defData) {\n+ equals = this.proj.defData.replace(this.titleRegEx, \"\") ==\n+ p.proj.defData.replace(this.titleRegEx, \"\");\n+ } else if (p.getCode) {\n+ var source = this.getCode(),\n+ target = p.getCode();\n+ equals = source == target ||\n+ !!OpenLayers.Projection.transforms[source] &&\n+ OpenLayers.Projection.transforms[source][target] ===\n+ OpenLayers.Projection.nullTransform;\n+ }\n+ }\n+ return equals;\n+ },\n+\n+ /* Method: destroy\n+ * Destroy projection object.\n+ */\n+ destroy: function() {\n+ delete this.proj;\n+ delete this.projCode;\n+ },\n+\n+ CLASS_NAME: \"OpenLayers.Projection\"\n+});\n+\n+/**\n+ * Property: transforms\n+ * {Object} Transforms is an object, with from properties, each of which may\n+ * have a to property. This allows you to define projections without \n+ * requiring support for proj4js to be included.\n+ *\n+ * This object has keys which correspond to a 'source' projection object. The\n+ * keys should be strings, corresponding to the projection.getCode() value.\n+ * Each source projection object should have a set of destination projection\n+ * keys included in the object. \n+ * \n+ * Each value in the destination object should be a transformation function,\n+ * where the function is expected to be passed an object with a .x and a .y\n+ * property. The function should return the object, with the .x and .y\n+ * transformed according to the transformation function.\n+ *\n+ * Note - Properties on this object should not be set directly. To add a\n+ * transform method to this object, use the method. For an\n+ * example of usage, see the OpenLayers.Layer.SphericalMercator file.\n+ */\n+OpenLayers.Projection.transforms = {};\n+\n+/**\n+ * APIProperty: defaults\n+ * {Object} Defaults for the SRS codes known to OpenLayers (currently\n+ * EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,\n+ * EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,\n+ * maxExtent (the validity extent for the SRS) and yx (true if this SRS is\n+ * known to have a reverse axis order).\n+ */\n+OpenLayers.Projection.defaults = {\n+ \"EPSG:4326\": {\n+ units: \"degrees\",\n+ maxExtent: [-180, -90, 180, 90],\n+ yx: true\n+ },\n+ \"CRS:84\": {\n+ units: \"degrees\",\n+ maxExtent: [-180, -90, 180, 90]\n+ },\n+ \"EPSG:900913\": {\n+ units: \"m\",\n+ maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]\n+ }\n+};\n+\n+/**\n+ * APIMethod: addTransform\n+ * Set a custom transform method between two projections. Use this method in\n+ * cases where the proj4js lib is not available or where custom projections\n+ * need to be handled.\n+ *\n+ * Parameters:\n+ * from - {String} The code for the source projection\n+ * to - {String} the code for the destination projection\n+ * method - {Function} A function that takes a point as an argument and\n+ * transforms that point from the source to the destination projection\n+ * in place. The original point should be modified.\n+ */\n+OpenLayers.Projection.addTransform = function(from, to, method) {\n+ if (method === OpenLayers.Projection.nullTransform) {\n+ var defaults = OpenLayers.Projection.defaults[from];\n+ if (defaults && !OpenLayers.Projection.defaults[to]) {\n+ OpenLayers.Projection.defaults[to] = defaults;\n+ }\n+ }\n+ if (!OpenLayers.Projection.transforms[from]) {\n+ OpenLayers.Projection.transforms[from] = {};\n+ }\n+ OpenLayers.Projection.transforms[from][to] = method;\n+};\n+\n+/**\n+ * APIMethod: transform\n+ * Transform a point coordinate from one projection to another. Note that\n+ * the input point is transformed in place.\n+ * \n+ * Parameters:\n+ * point - { | Object} An object with x and y\n+ * properties representing coordinates in those dimensions.\n+ * source - {OpenLayers.Projection} Source map coordinate system\n+ * dest - {OpenLayers.Projection} Destination map coordinate system\n+ *\n+ * Returns:\n+ * point - {object} A transformed coordinate. The original point is modified.\n+ */\n+OpenLayers.Projection.transform = function(point, source, dest) {\n+ if (source && dest) {\n+ if (!(source instanceof OpenLayers.Projection)) {\n+ source = new OpenLayers.Projection(source);\n+ }\n+ if (!(dest instanceof OpenLayers.Projection)) {\n+ dest = new OpenLayers.Projection(dest);\n+ }\n+ if (source.proj && dest.proj) {\n+ point = Proj4js.transform(source.proj, dest.proj, point);\n+ } else {\n+ var sourceCode = source.getCode();\n+ var destCode = dest.getCode();\n+ var transforms = OpenLayers.Projection.transforms;\n+ if (transforms[sourceCode] && transforms[sourceCode][destCode]) {\n+ transforms[sourceCode][destCode](point);\n+ }\n+ }\n+ }\n+ return point;\n+};\n+\n+/**\n+ * APIFunction: nullTransform\n+ * A null transformation - useful for defining projection aliases when\n+ * proj4js is not available:\n+ *\n+ * (code)\n+ * OpenLayers.Projection.addTransform(\"EPSG:3857\", \"EPSG:900913\",\n+ * OpenLayers.Projection.nullTransform);\n+ * OpenLayers.Projection.addTransform(\"EPSG:900913\", \"EPSG:3857\",\n+ * OpenLayers.Projection.nullTransform);\n+ * (end)\n+ */\n+OpenLayers.Projection.nullTransform = function(point) {\n+ return point;\n+};\n+\n+/**\n+ * Note: Transforms for web mercator <-> geographic\n+ * OpenLayers recognizes EPSG:3857, EPSG:900913, EPSG:102113 and EPSG:102100.\n+ * OpenLayers originally started referring to EPSG:900913 as web mercator.\n+ * The EPSG has declared EPSG:3857 to be web mercator.\n+ * ArcGIS 10 recognizes the EPSG:3857, EPSG:102113, and EPSG:102100 as\n+ * equivalent. See http://blogs.esri.com/Dev/blogs/arcgisserver/archive/2009/11/20/ArcGIS-Online-moving-to-Google-_2F00_-Bing-tiling-scheme_3A00_-What-does-this-mean-for-you_3F00_.aspx#12084.\n+ * For geographic, OpenLayers recognizes EPSG:4326, CRS:84 and\n+ * urn:ogc:def:crs:EPSG:6.6:4326. OpenLayers also knows about the reverse axis\n+ * order for EPSG:4326. \n+ */\n+(function() {\n+\n+ var pole = 20037508.34;\n+\n+ function inverseMercator(xy) {\n+ xy.x = 180 * xy.x / pole;\n+ xy.y = 180 / Math.PI * (2 * Math.atan(Math.exp((xy.y / pole) * Math.PI)) - Math.PI / 2);\n+ return xy;\n+ }\n+\n+ function forwardMercator(xy) {\n+ xy.x = xy.x * pole / 180;\n+ var y = Math.log(Math.tan((90 + xy.y) * Math.PI / 360)) / Math.PI * pole;\n+ xy.y = Math.max(-20037508.34, Math.min(y, 20037508.34));\n+ return xy;\n+ }\n+\n+ function map(base, codes) {\n+ var add = OpenLayers.Projection.addTransform;\n+ var same = OpenLayers.Projection.nullTransform;\n+ var i, len, code, other, j;\n+ for (i = 0, len = codes.length; i < len; ++i) {\n+ code = codes[i];\n+ add(base, code, forwardMercator);\n+ add(code, base, inverseMercator);\n+ for (j = i + 1; j < len; ++j) {\n+ other = codes[j];\n+ add(code, other, same);\n+ add(other, code, same);\n+ }\n+ }\n+ }\n+\n+ // list of equivalent codes for web mercator\n+ var mercator = [\"EPSG:900913\", \"EPSG:3857\", \"EPSG:102113\", \"EPSG:102100\"],\n+ geographic = [\"CRS:84\", \"urn:ogc:def:crs:EPSG:6.6:4326\", \"EPSG:4326\"],\n+ i;\n+ for (i = mercator.length - 1; i >= 0; --i) {\n+ map(mercator[i], geographic);\n+ }\n+ for (i = geographic.length - 1; i >= 0; --i) {\n+ map(geographic[i], mercator);\n+ }\n+\n+})();\n+/* ======================================================================\n+ OpenLayers/Map.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/Util.js\n+ * @requires OpenLayers/Util/vendorPrefix.js\n+ * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/Tween.js\n+ * @requires OpenLayers/Projection.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Map\n+ * Instances of OpenLayers.Map are interactive maps embedded in a web page.\n+ * Create a new map with the constructor.\n+ * \n+ * On their own maps do not provide much functionality. To extend a map\n+ * it's necessary to add controls () and \n+ * layers () to the map. \n+ */\n+OpenLayers.Map = OpenLayers.Class({\n+\n+ /**\n+ * Constant: Z_INDEX_BASE\n+ * {Object} Base z-indexes for different classes of thing \n+ */\n+ Z_INDEX_BASE: {\n+ BaseLayer: 100,\n+ Overlay: 325,\n+ Feature: 725,\n+ Popup: 750,\n+ Control: 1000\n+ },\n+\n+ /**\n+ * APIProperty: events\n+ * {}\n+ *\n+ * Register a listener for a particular event with the following syntax:\n+ * (code)\n+ * map.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 map.events.object.\n+ * element - {DOMElement} A reference to map.events.element.\n+ *\n+ * Browser events have the following additional properties:\n+ * xy - {} The pixel location of the event (relative\n+ * to the the map viewport).\n+ *\n+ * Supported map event types:\n+ * preaddlayer - triggered before a layer has been added. The event\n+ * object will include a *layer* property that references the layer \n+ * to be added. When a listener returns \"false\" the adding will be \n+ * aborted.\n+ * addlayer - triggered after a layer has been added. The event object\n+ * will include a *layer* property that references the added layer.\n+ * preremovelayer - triggered before a layer has been removed. The event\n+ * object will include a *layer* property that references the layer \n+ * to be removed. When a listener returns \"false\" the removal will be \n+ * aborted.\n+ * removelayer - triggered after a layer has been removed. The event\n+ * object will include a *layer* property that references the removed\n+ * layer.\n+ * changelayer - triggered after a layer name change, order change,\n+ * opacity change, params change, visibility change (actual visibility,\n+ * not the layer's visibility property) or attribution change (due to\n+ * extent change). Listeners will receive an event object with *layer*\n+ * and *property* properties. The *layer* property will be a reference\n+ * to the changed layer. The *property* property will be a key to the\n+ * changed property (name, order, opacity, params, visibility or\n+ * attribution).\n+ * movestart - triggered after the start of a drag, pan, or zoom. The event\n+ * object may include a *zoomChanged* property that tells whether the\n+ * zoom has changed.\n+ * move - triggered after each drag, pan, or zoom\n+ * moveend - triggered after a drag, pan, or zoom completes\n+ * zoomend - triggered after a zoom completes\n+ * mouseover - triggered after mouseover the map\n+ * mouseout - triggered after mouseout the map\n+ * mousemove - triggered after mousemove the map\n+ * changebaselayer - triggered after the base layer changes\n+ * updatesize - triggered after the method was executed\n+ */\n+\n+ /**\n+ * Property: id\n+ * {String} Unique identifier for the map\n+ */\n+ id: null,\n+\n+ /**\n+ * Property: fractionalZoom\n+ * {Boolean} For a base layer that supports it, allow the map resolution\n+ * to be set to a value between one of the values in the resolutions\n+ * array. Default is false.\n+ *\n+ * When fractionalZoom is set to true, it is possible to zoom to\n+ * an arbitrary extent. This requires a base layer from a source\n+ * that supports requests for arbitrary extents (i.e. not cached\n+ * tiles on a regular lattice). This means that fractionalZoom\n+ * will not work with commercial layers (Google, Yahoo, VE), layers\n+ * using TileCache, or any other pre-cached data sources.\n+ *\n+ * If you are using fractionalZoom, then you should also use\n+ * instead of layer.resolutions[zoom] as the\n+ * former works for non-integer zoom levels.\n+ */\n+ fractionalZoom: false,\n+\n+ /**\n+ * APIProperty: events\n+ * {} An events object that handles all \n+ * events on the map\n+ */\n+ events: null,\n+\n+ /**\n+ * APIProperty: allOverlays\n+ * {Boolean} Allow the map to function with \"overlays\" only. Defaults to\n+ * false. If true, the lowest layer in the draw order will act as\n+ * the base layer. In addition, if set to true, all layers will\n+ * have isBaseLayer set to false when they are added to the map.\n+ *\n+ * Note:\n+ * If you set map.allOverlays to true, then you *cannot* use\n+ * map.setBaseLayer or layer.setIsBaseLayer. With allOverlays true,\n+ * the lowest layer in the draw layer is the base layer. So, to change\n+ * the base layer, use or to set the layer\n+ * index to 0.\n+ */\n+ allOverlays: false,\n+\n+ /**\n+ * APIProperty: div\n+ * {DOMElement|String} The element that contains the map (or an id for\n+ * that element). If the constructor is called\n+ * with two arguments, this should be provided as the first argument.\n+ * Alternatively, the map constructor can be called with the options\n+ * object as the only argument. In this case (one argument), a\n+ * div property may or may not be provided. If the div property\n+ * is not provided, the map can be rendered to a container later\n+ * using the method.\n+ * \n+ * Note:\n+ * If you are calling after map construction, do not use\n+ * auto. Instead, divide your by your\n+ * maximum expected dimension.\n+ */\n+ div: null,\n+\n+ /**\n+ * Property: dragging\n+ * {Boolean} The map is currently being dragged.\n+ */\n+ dragging: false,\n+\n+ /**\n+ * Property: size\n+ * {} Size of the main div (this.div)\n+ */\n+ size: null,\n+\n+ /**\n+ * Property: viewPortDiv\n+ * {HTMLDivElement} The element that represents the map viewport\n+ */\n+ viewPortDiv: null,\n+\n+ /**\n+ * Property: layerContainerOrigin\n+ * {} The lonlat at which the later container was\n+ * re-initialized (on-zoom)\n+ */\n+ layerContainerOrigin: null,\n+\n+ /**\n+ * Property: layerContainerDiv\n+ * {HTMLDivElement} The element that contains the layers.\n+ */\n+ layerContainerDiv: null,\n+\n+ /**\n+ * APIProperty: layers\n+ * {Array()} Ordered list of layers in the map\n+ */\n+ layers: null,\n+\n+ /**\n+ * APIProperty: controls\n+ * {Array()} List of controls associated with the map.\n+ *\n+ * If not provided in the map options at construction, the map will\n+ * by default be given the following controls if present in the build:\n+ * - or \n+ * - or \n+ * - \n+ * - \n+ */\n+ controls: null,\n+\n+ /**\n+ * Property: popups\n+ * {Array()} List of popups associated with the map\n+ */\n+ popups: null,\n+\n+ /**\n+ * APIProperty: baseLayer\n+ * {} The currently selected base layer. This determines\n+ * min/max zoom level, projection, etc.\n+ */\n+ baseLayer: null,\n+\n+ /**\n+ * Property: center\n+ * {} The current center of the map\n+ */\n+ center: null,\n+\n+ /**\n+ * Property: resolution\n+ * {Float} The resolution of the map.\n+ */\n+ resolution: null,\n+\n+ /**\n+ * Property: zoom\n+ * {Integer} The current zoom level of the map\n+ */\n+ zoom: 0,\n+\n+ /**\n+ * Property: panRatio\n+ * {Float} The ratio of the current extent within\n+ * which panning will tween.\n+ */\n+ panRatio: 1.5,\n+\n+ /**\n+ * APIProperty: options\n+ * {Object} The options object passed to the class constructor. Read-only.\n+ */\n+ options: null,\n+\n+ // Options\n+\n+ /**\n+ * APIProperty: tileSize\n+ * {} Set in the map options to override the default tile\n+ * size for this map.\n+ */\n+ tileSize: null,\n+\n+ /**\n+ * APIProperty: projection\n+ * {String} Set in the map options to specify the default projection \n+ * for layers added to this map. When using a projection other than EPSG:4326\n+ * (CRS:84, Geographic) or EPSG:3857 (EPSG:900913, Web Mercator),\n+ * also set maxExtent, maxResolution or resolutions. Default is \"EPSG:4326\".\n+ * Note that the projection of the map is usually determined\n+ * by that of the current baseLayer (see and ).\n+ */\n+ projection: \"EPSG:4326\",\n+\n+ /**\n+ * APIProperty: units\n+ * {String} The map units. Possible values are 'degrees' (or 'dd'), 'm', \n+ * 'ft', 'km', 'mi', 'inches'. 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: resolutions\n+ * {Array(Float)} A list of map resolutions (map units per pixel) in \n+ * descending order. If this is not set in the layer constructor, it \n+ * will be set based on other resolution related properties \n+ * (maxExtent, maxResolution, maxScale, etc.).\n+ */\n+ resolutions: null,\n+\n+ /**\n+ * APIProperty: maxResolution\n+ * {Float} Required if you are not displaying the whole world on a tile\n+ * with the size specified in .\n+ */\n+ maxResolution: null,\n+\n+ /**\n+ * APIProperty: minResolution\n+ * {Float}\n+ */\n+ minResolution: null,\n+\n+ /**\n+ * APIProperty: maxScale\n+ * {Float}\n+ */\n+ maxScale: null,\n+\n+ /**\n+ * APIProperty: minScale\n+ * {Float}\n+ */\n+ minScale: 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 map.\n+ * Default depends on projection; if this is one of those defined in OpenLayers.Projection.defaults\n+ * (EPSG:4326 or web mercator), maxExtent will be set to the value defined there;\n+ * else, defaults to null.\n+ * To restrict user panning and zooming of the map, use instead.\n+ * The value for will change calculations for tile URLs.\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 map. Defaults to null.\n+ */\n+ minExtent: null,\n+\n+ /**\n+ * APIProperty: restrictedExtent\n+ * {|Array} If provided as an array, the array\n+ * should consist of four values (left, bottom, right, top).\n+ * Limit map navigation to this extent where possible.\n+ * If a non-null restrictedExtent is set, panning will be restricted\n+ * to the given bounds. In addition, zooming to a resolution that\n+ * displays more than the restricted extent will center the map\n+ * on the restricted extent. If you wish to limit the zoom level\n+ * or resolution, use maxResolution.\n+ */\n+ restrictedExtent: null,\n+\n+ /**\n+ * APIProperty: numZoomLevels\n+ * {Integer} Number of zoom levels for the map. Defaults to 16. Set a\n+ * different value in the map options if needed.\n+ */\n+ numZoomLevels: 16,\n+\n+ /**\n+ * APIProperty: theme\n+ * {String} Relative path to a CSS file from which to load theme styles.\n+ * Specify null in the map options (e.g. {theme: null}) if you \n+ * want to get cascading style declarations - by putting links to \n+ * stylesheets or style declarations directly in your page.\n+ */\n+ theme: null,\n+\n+ /** \n+ * APIProperty: displayProjection\n+ * {} Requires proj4js support for projections other\n+ * than EPSG:4326 or EPSG:900913/EPSG:3857. Projection used by\n+ * several controls to display data to user. If this property is set,\n+ * it will be set on any control which has a null displayProjection\n+ * property at the time the control is added to the map. \n+ */\n+ displayProjection: null,\n+\n+ /**\n+ * APIProperty: tileManager\n+ * {|Object} By default, and if the build contains\n+ * TileManager.js, the map will use the TileManager to queue image requests\n+ * and to cache tile image elements. To create a map without a TileManager\n+ * configure the map with tileManager: null. To create a TileManager with\n+ * non-default options, supply the options instead or alternatively supply\n+ * an instance of {}.\n+ */\n+\n+ /**\n+ * APIProperty: fallThrough\n+ * {Boolean} Should OpenLayers allow events on the map to fall through to\n+ * other elements on the page, or should it swallow them? (#457)\n+ * Default is to swallow.\n+ */\n+ fallThrough: false,\n+\n+ /**\n+ * APIProperty: autoUpdateSize\n+ * {Boolean} Should OpenLayers automatically update the size of the map\n+ * when the resize event is fired. Default is true.\n+ */\n+ autoUpdateSize: true,\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+ * Property: panTween\n+ * {} Animated panning tween object, see panTo()\n+ */\n+ panTween: null,\n+\n+ /**\n+ * APIProperty: panMethod\n+ * {Function} The Easing function to be used for tweening. Default is\n+ * OpenLayers.Easing.Expo.easeOut. Setting this to 'null' turns off\n+ * animated panning.\n+ */\n+ panMethod: OpenLayers.Easing.Expo.easeOut,\n+\n+ /**\n+ * Property: panDuration\n+ * {Integer} The number of steps to be passed to the\n+ * OpenLayers.Tween.start() method when the map is\n+ * panned.\n+ * Default is 50.\n+ */\n+ panDuration: 50,\n+\n+ /**\n+ * Property: zoomTween\n+ * {} Animated zooming tween object, see zoomTo()\n+ */\n+ zoomTween: null,\n+\n+ /**\n+ * APIProperty: zoomMethod\n+ * {Function} The Easing function to be used for tweening. Default is\n+ * OpenLayers.Easing.Quad.easeOut. Setting this to 'null' turns off\n+ * animated zooming.\n+ */\n+ zoomMethod: OpenLayers.Easing.Quad.easeOut,\n+\n+ /**\n+ * Property: zoomDuration\n+ * {Integer} The number of steps to be passed to the\n+ * OpenLayers.Tween.start() method when the map is zoomed.\n+ * Default is 20.\n+ */\n+ zoomDuration: 20,\n+\n+ /**\n+ * Property: paddingForPopups\n+ * {} Outside margin of the popup. Used to prevent \n+ * the popup from getting too close to the map border.\n+ */\n+ paddingForPopups: null,\n+\n+ /**\n+ * Property: layerContainerOriginPx\n+ * {Object} Cached object representing the layer container origin (in pixels).\n+ */\n+ layerContainerOriginPx: null,\n+\n+ /**\n+ * Property: minPx\n+ * {Object} An object with a 'x' and 'y' values that is the lower\n+ * left of maxExtent in viewport pixel space.\n+ * Used to verify in moveByPx that the new location we're moving to\n+ * is valid. It is also used in the getLonLatFromViewPortPx function\n+ * of Layer.\n+ */\n+ minPx: null,\n+\n+ /**\n+ * Property: maxPx\n+ * {Object} An object with a 'x' and 'y' values that is the top\n+ * right of maxExtent in viewport pixel space.\n+ * Used to verify in moveByPx that the new location we're moving to\n+ * is valid.\n+ */\n+ maxPx: null,\n+\n+ /**\n+ * Constructor: OpenLayers.Map\n+ * Constructor for a new OpenLayers.Map instance. There are two possible\n+ * ways to call the map constructor. See the examples below.\n+ *\n+ * Parameters:\n+ * div - {DOMElement|String} The element or id of an element in your page\n+ * that will contain the map. May be omitted if the
option is\n+ * provided or if you intend to call the method later.\n+ * options - {Object} Optional object with properties to tag onto the map.\n+ *\n+ * Valid options (in addition to the listed API properties):\n+ * center - {|Array} The default initial center of the map.\n+ * If provided as array, the first value is the x coordinate,\n+ * and the 2nd value is the y coordinate.\n+ * Only specify if is provided.\n+ * Note that if an ArgParser/Permalink control is present,\n+ * and the querystring contains coordinates, center will be set\n+ * by that, and this option will be ignored.\n+ * zoom - {Number} The initial zoom level for the map. Only specify if\n+ * is provided.\n+ * Note that if an ArgParser/Permalink control is present,\n+ * and the querystring contains a zoom level, zoom will be set\n+ * by that, and this option will be ignored.\n+ * extent - {|Array} The initial extent of the map.\n+ * If provided as an array, the array should consist of\n+ * four values (left, bottom, right, top).\n+ * Only specify if
and are not provided.\n+ * \n+ * Examples:\n+ * (code)\n+ * // create a map with default options in an element with the id \"map1\"\n+ * var map = new OpenLayers.Map(\"map1\");\n+ *\n+ * // create a map with non-default options in an element with id \"map2\"\n+ * var options = {\n+ * projection: \"EPSG:3857\",\n+ * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000),\n+ * center: new OpenLayers.LonLat(-12356463.476333, 5621521.4854095)\n+ * };\n+ * var map = new OpenLayers.Map(\"map2\", options);\n+ *\n+ * // map with non-default options - same as above but with a single argument,\n+ * // a restricted extent, and using arrays for bounds and center\n+ * var map = new OpenLayers.Map({\n+ * div: \"map_id\",\n+ * projection: \"EPSG:3857\",\n+ * maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146],\n+ * restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962],\n+ * center: [-12356463.476333, 5621521.4854095]\n+ * });\n+ *\n+ * // create a map without a reference to a container - call render later\n+ * var map = new OpenLayers.Map({\n+ * projection: \"EPSG:3857\",\n+ * maxExtent: new OpenLayers.Bounds(-200000, -200000, 200000, 200000)\n+ * });\n+ * (end)\n+ */\n+ initialize: function(div, options) {\n+\n+ // If only one argument is provided, check if it is an object.\n+ if (arguments.length === 1 && typeof div === \"object\") {\n+ options = div;\n+ div = options && options.div;\n+ }\n+\n+ // Simple-type defaults are set in class definition. \n+ // Now set complex-type defaults \n+ this.tileSize = new OpenLayers.Size(OpenLayers.Map.TILE_WIDTH,\n+ OpenLayers.Map.TILE_HEIGHT);\n+\n+ this.paddingForPopups = new OpenLayers.Bounds(15, 15, 15, 15);\n+\n+ this.theme = OpenLayers._getScriptLocation() +\n+ 'theme/default/style.css';\n+\n+ // backup original options\n+ this.options = OpenLayers.Util.extend({}, options);\n+\n+ // now override default options \n+ OpenLayers.Util.extend(this, options);\n+\n+ var projCode = this.projection instanceof OpenLayers.Projection ?\n+ this.projection.projCode : this.projection;\n+ OpenLayers.Util.applyDefaults(this, OpenLayers.Projection.defaults[projCode]);\n+\n+ // allow extents and center to be arrays\n+ if (this.maxExtent && !(this.maxExtent instanceof OpenLayers.Bounds)) {\n+ this.maxExtent = new OpenLayers.Bounds(this.maxExtent);\n+ }\n+ if (this.minExtent && !(this.minExtent instanceof OpenLayers.Bounds)) {\n+ this.minExtent = new OpenLayers.Bounds(this.minExtent);\n+ }\n+ if (this.restrictedExtent && !(this.restrictedExtent instanceof OpenLayers.Bounds)) {\n+ this.restrictedExtent = new OpenLayers.Bounds(this.restrictedExtent);\n+ }\n+ if (this.center && !(this.center instanceof OpenLayers.LonLat)) {\n+ this.center = new OpenLayers.LonLat(this.center);\n+ }\n+\n+ // initialize layers array\n+ this.layers = [];\n+\n+ this.id = OpenLayers.Util.createUniqueID(\"OpenLayers.Map_\");\n+\n+ this.div = OpenLayers.Util.getElement(div);\n+ if (!this.div) {\n+ this.div = document.createElement(\"div\");\n+ this.div.style.height = \"1px\";\n+ this.div.style.width = \"1px\";\n+ }\n+\n+ OpenLayers.Element.addClass(this.div, 'olMap');\n+\n+ // the viewPortDiv is the outermost div we modify\n+ var id = this.id + \"_OpenLayers_ViewPort\";\n+ this.viewPortDiv = OpenLayers.Util.createDiv(id, null, null, null,\n+ \"relative\", null,\n+ \"hidden\");\n+ this.viewPortDiv.style.width = \"100%\";\n+ this.viewPortDiv.style.height = \"100%\";\n+ this.viewPortDiv.className = \"olMapViewport\";\n+ this.div.appendChild(this.viewPortDiv);\n+\n+ this.events = new OpenLayers.Events(\n+ this, this.viewPortDiv, null, this.fallThrough, {\n+ includeXY: true\n+ }\n+ );\n+\n+ if (OpenLayers.TileManager && this.tileManager !== null) {\n+ if (!(this.tileManager instanceof OpenLayers.TileManager)) {\n+ this.tileManager = new OpenLayers.TileManager(this.tileManager);\n+ }\n+ this.tileManager.addMap(this);\n+ }\n+\n+ // the layerContainerDiv is the one that holds all the layers\n+ id = this.id + \"_OpenLayers_Container\";\n+ this.layerContainerDiv = OpenLayers.Util.createDiv(id);\n+ this.layerContainerDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] - 1;\n+ this.layerContainerOriginPx = {\n+ x: 0,\n+ y: 0\n+ };\n+ this.applyTransform();\n+\n+ this.viewPortDiv.appendChild(this.layerContainerDiv);\n+\n+ this.updateSize();\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n+ }\n+\n+ if (this.autoUpdateSize === true) {\n+ // updateSize on catching the window's resize\n+ // Note that this is ok, as updateSize() does nothing if the \n+ // map's size has not actually changed.\n+ this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,\n+ this);\n+ OpenLayers.Event.observe(window, 'resize',\n+ this.updateSizeDestroy);\n+ }\n+\n+ // only append link stylesheet if the theme property is set\n+ if (this.theme) {\n+ // check existing links for equivalent url\n+ var addNode = true;\n+ var nodes = document.getElementsByTagName('link');\n+ for (var i = 0, len = nodes.length; i < len; ++i) {\n+ if (OpenLayers.Util.isEquivalentUrl(nodes.item(i).href,\n+ this.theme)) {\n+ addNode = false;\n+ break;\n+ }\n+ }\n+ // only add a new node if one with an equivalent url hasn't already\n+ // been added\n+ if (addNode) {\n+ var cssNode = document.createElement('link');\n+ cssNode.setAttribute('rel', 'stylesheet');\n+ cssNode.setAttribute('type', 'text/css');\n+ cssNode.setAttribute('href', this.theme);\n+ document.getElementsByTagName('head')[0].appendChild(cssNode);\n+ }\n+ }\n+\n+ if (this.controls == null) { // default controls\n+ this.controls = [];\n+ if (OpenLayers.Control != null) { // running full or lite?\n+ // Navigation or TouchNavigation depending on what is in build\n+ if (OpenLayers.Control.Navigation) {\n+ this.controls.push(new OpenLayers.Control.Navigation());\n+ } else if (OpenLayers.Control.TouchNavigation) {\n+ this.controls.push(new OpenLayers.Control.TouchNavigation());\n+ }\n+ if (OpenLayers.Control.Zoom) {\n+ this.controls.push(new OpenLayers.Control.Zoom());\n+ } else if (OpenLayers.Control.PanZoom) {\n+ this.controls.push(new OpenLayers.Control.PanZoom());\n+ }\n+\n+ if (OpenLayers.Control.ArgParser) {\n+ this.controls.push(new OpenLayers.Control.ArgParser());\n+ }\n+ if (OpenLayers.Control.Attribution) {\n+ this.controls.push(new OpenLayers.Control.Attribution());\n }\n }\n- } else {\n- output = 0;\n }\n- return output;\n- },\n \n- /**\n- * Method: chainProcess\n- * Sets a fully configured chained process as input for this process.\n- *\n- * Parameters:\n- * input - {Object} The dataInput that the chained process provides.\n- * chainLink - {} The process to chain.\n- */\n- chainProcess: function(input, chainLink) {\n- var output = this.getOutputIndex(\n- chainLink.process.description.processOutputs, chainLink.output\n- );\n- input.reference.mimeType = this.findMimeType(\n- input.complexData.supported.formats,\n- chainLink.process.description.processOutputs[output].complexOutput.supported.formats\n- );\n- var formats = {};\n- formats[input.reference.mimeType] = true;\n- chainLink.process.setResponseForm({\n- outputIndex: output,\n- supportedFormats: formats\n- });\n- input.reference.body = chainLink.process.description;\n- while (this.executeCallbacks.length > 0) {\n- this.executeCallbacks[0]();\n+ for (var i = 0, len = this.controls.length; i < len; i++) {\n+ this.addControlToMap(this.controls[i]);\n+ }\n+\n+ this.popups = [];\n+\n+ this.unloadDestroy = OpenLayers.Function.bind(this.destroy, this);\n+\n+\n+ // always call map.destroy()\n+ OpenLayers.Event.observe(window, 'unload', this.unloadDestroy);\n+\n+ // add any initial layers\n+ if (options && options.layers) {\n+ /** \n+ * If you have set options.center, the map center property will be\n+ * set at this point. However, since setCenter has not been called,\n+ * addLayers gets confused. So we delete the map center in this \n+ * case. Because the check below uses options.center, it will\n+ * be properly set below.\n+ */\n+ delete this.center;\n+ delete this.zoom;\n+ this.addLayers(options.layers);\n+ // set center (and optionally zoom)\n+ if (options.center && !this.getCenter()) {\n+ // zoom can be undefined here\n+ this.setCenter(options.center, options.zoom);\n+ }\n+ }\n+\n+ if (this.panMethod) {\n+ this.panTween = new OpenLayers.Tween(this.panMethod);\n+ }\n+ if (this.zoomMethod && this.applyTransform.transform) {\n+ this.zoomTween = new OpenLayers.Tween(this.zoomMethod);\n }\n },\n \n- /**\n- * Method: toFeatures\n- * Converts spatial input into features so it can be processed by\n- * instances.\n- *\n- * Parameters:\n- * source - {Mixed} An , an\n- * , or an array of geometries or features\n+ /** \n+ * APIMethod: getViewport\n+ * Get the DOMElement representing the view port.\n *\n * Returns:\n- * {Array()}\n+ * {DOMElement}\n */\n- toFeatures: function(source) {\n- var isArray = OpenLayers.Util.isArray(source);\n- if (!isArray) {\n- source = [source];\n- }\n- var target = new Array(source.length),\n- current;\n- for (var i = 0, ii = source.length; i < ii; ++i) {\n- current = source[i];\n- target[i] = current instanceof OpenLayers.Feature.Vector ?\n- current : new OpenLayers.Feature.Vector(current);\n- }\n- return isArray ? target : target[0];\n+ getViewport: function() {\n+ return this.viewPortDiv;\n },\n \n /**\n- * Method: findMimeType\n- * Finds a supported mime type.\n- *\n+ * APIMethod: render\n+ * Render the map to a specified container.\n+ * \n * Parameters:\n- * sourceFormats - {Object} An object literal with mime types as key and\n- * true as value for supported formats.\n- * targetFormats - {Object} Like , but optional to check for\n- * supported mime types on a different target than this process.\n- * Default is to check against this process's supported formats.\n- *\n- * Returns:\n- * {String} A supported mime type.\n+ * div - {String|DOMElement} The container that the map should be rendered\n+ * to. If different than the current container, the map viewport\n+ * will be moved from the current to the new container.\n */\n- findMimeType: function(sourceFormats, targetFormats) {\n- targetFormats = targetFormats || this.formats;\n- for (var f in sourceFormats) {\n- if (f in targetFormats) {\n- return f;\n- }\n- }\n+ render: function(div) {\n+ this.div = OpenLayers.Util.getElement(div);\n+ OpenLayers.Element.addClass(this.div, 'olMap');\n+ this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);\n+ this.div.appendChild(this.viewPortDiv);\n+ this.updateSize();\n },\n \n- CLASS_NAME: \"OpenLayers.WPSProcess\"\n-\n-});\n-\n-/**\n- * Class: OpenLayers.WPSProcess.ChainLink\n- * Type for chaining processes.\n- */\n-OpenLayers.WPSProcess.ChainLink = OpenLayers.Class({\n-\n /**\n- * Property: process\n- * {} The process to chain\n+ * Method: unloadDestroy\n+ * Function that is called to destroy the map on page unload. stored here\n+ * so that if map is manually destroyed, we can unregister this.\n */\n- process: null,\n+ unloadDestroy: null,\n \n /**\n- * Property: output\n- * {String} The output identifier of the output we are going to use as\n- * input for another process.\n+ * Method: updateSizeDestroy\n+ * When the map is destroyed, we need to stop listening to updateSize\n+ * events: this method stores the function we need to unregister in \n+ * non-IE browsers.\n */\n- output: null,\n+ updateSizeDestroy: null,\n \n /**\n- * Constructor: OpenLayers.WPSProcess.ChainLink\n- *\n- * Parameters:\n- * options - {Object} Properties to set on the instance.\n+ * APIMethod: destroy\n+ * Destroy this map.\n+ * Note that if you are using an application which removes a container\n+ * of the map from the DOM, you need to ensure that you destroy the\n+ * map *before* this happens; otherwise, the page unload handler\n+ * will fail because the DOM elements that map.destroy() wants\n+ * to clean up will be gone. (See \n+ * http://trac.osgeo.org/openlayers/ticket/2277 for more information).\n+ * This will apply to GeoExt and also to other applications which\n+ * modify the DOM of the container of the OpenLayers Map.\n */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- },\n-\n- CLASS_NAME: \"OpenLayers.WPSProcess.ChainLink\"\n-\n-});\n-/* ======================================================================\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- * @requires OpenLayers/Format/XML.js\n- * @requires OpenLayers/Format/OWSCommon/v1_1_0.js\n- */\n-\n-/**\n- * Class: OpenLayers.Format.WPSDescribeProcess\n- * Read WPS DescribeProcess responses. \n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Format.WPSDescribeProcess = OpenLayers.Class(\n- OpenLayers.Format.XML, {\n-\n- /**\n- * Constant: VERSION\n- * {String} 1.0.0\n- */\n- VERSION: \"1.0.0\",\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+ destroy: function() {\n+ // if unloadDestroy is null, we've already been destroyed\n+ if (!this.unloadDestroy) {\n+ return false;\n+ }\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+ // make sure panning doesn't continue after destruction\n+ if (this.panTween) {\n+ this.panTween.stop();\n+ this.panTween = null;\n+ }\n+ // make sure zooming doesn't continue after destruction\n+ if (this.zoomTween) {\n+ this.zoomTween.stop();\n+ this.zoomTween = null;\n+ }\n \n- /**\n- * Property: defaultPrefix\n- */\n- defaultPrefix: \"wps\",\n+ // map has been destroyed. dont do it again!\n+ OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);\n+ this.unloadDestroy = 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+ if (this.updateSizeDestroy) {\n+ OpenLayers.Event.stopObserving(window, 'resize',\n+ this.updateSizeDestroy);\n+ }\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+ this.paddingForPopups = 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+ if (this.controls != null) {\n+ for (var i = this.controls.length - 1; i >= 0; --i) {\n+ this.controls[i].destroy();\n }\n- if (data && data.nodeType == 9) {\n- data = data.documentElement;\n+ this.controls = null;\n+ }\n+ if (this.layers != null) {\n+ for (var i = this.layers.length - 1; i >= 0; --i) {\n+ //pass 'false' to destroy so that map wont try to set a new \n+ // baselayer after each baselayer is removed\n+ this.layers[i].destroy(false);\n }\n- var info = {};\n- this.readNode(data, info);\n- return info;\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- },\n- \"ows\": OpenLayers.Format.OWSCommon.v1_1_0.prototype.readers[\"ows\"]\n- },\n-\n- CLASS_NAME: \"OpenLayers.Format.WPSDescribeProcess\"\n-\n- });\n-/* ======================================================================\n- OpenLayers/WPSClient.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+ this.layers = null;\n+ }\n+ if (this.viewPortDiv && this.viewPortDiv.parentNode) {\n+ this.viewPortDiv.parentNode.removeChild(this.viewPortDiv);\n+ }\n+ this.viewPortDiv = null;\n \n-/**\n- * @requires OpenLayers/SingleFile.js\n- */\n+ if (this.tileManager) {\n+ this.tileManager.removeMap(this);\n+ this.tileManager = null;\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+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n+ this.eventListeners = null;\n+ }\n+ this.events.destroy();\n+ this.events = null;\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+ this.options = null;\n+ },\n \n /**\n- * Property: servers\n- * {Object} Service metadata, keyed by a local identifier.\n+ * APIMethod: setOptions\n+ * Change the map options\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+ * Parameters:\n+ * options - {Object} Hashtable of options to tag to the map\n */\n- servers: null,\n+ setOptions: function(options) {\n+ var updatePxExtent = this.minPx &&\n+ options.restrictedExtent != this.restrictedExtent;\n+ OpenLayers.Util.extend(this, options);\n+ // force recalculation of minPx and maxPx\n+ updatePxExtent && this.moveTo(this.getCachedCenter(), this.zoom, {\n+ forceZoomChange: true\n+ });\n+ },\n \n /**\n- * Property: version\n- * {String} The default WPS version to use if none is configured. Default\n- * is '1.0.0'.\n+ * APIMethod: getTileSize\n+ * Get the tile size for the map\n+ *\n+ * Returns:\n+ * {}\n */\n- version: '1.0.0',\n+ getTileSize: function() {\n+ return this.tileSize;\n+ },\n+\n \n /**\n- * Property: lazy\n- * {Boolean} Should the DescribeProcess be deferred until a process is\n- * fully configured? Default is false.\n+ * APIMethod: getBy\n+ * Get a list of objects given a property and a match item.\n+ *\n+ * Parameters:\n+ * array - {String} A property on the map whose value is an array.\n+ * property - {String} A property on each item of the given array.\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(map[array][i][property]) evaluates to true, the item will\n+ * be included in the array returned. If no items are found, an empty\n+ * array is returned.\n+ *\n+ * Returns:\n+ * {Array} An array of items where the given property matches the given\n+ * criteria.\n */\n- lazy: false,\n+ getBy: function(array, property, match) {\n+ var test = (typeof match.test == \"function\");\n+ var found = OpenLayers.Array.filter(this[array], function(item) {\n+ return item[property] == match || (test && match.test(item[property]));\n+ });\n+ return found;\n+ },\n \n /**\n- * Property: events\n- * {}\n+ * APIMethod: getLayersBy\n+ * Get a list of layers with properties matching the given criteria.\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+ * Parameters:\n+ * property - {String} A layer 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(layer[property]) evaluates to true, the layer will be\n+ * included in the array returned. If no layers are found, an empty\n+ * array is returned.\n+ *\n+ * Returns:\n+ * {Array()} A list of layers matching the given criteria.\n+ * An empty array is returned if no matches are found.\n */\n- events: null,\n+ getLayersBy: function(property, match) {\n+ return this.getBy(\"layers\", property, match);\n+ },\n \n /**\n- * Constructor: OpenLayers.WPSClient\n+ * APIMethod: getLayersByName\n+ * Get a list of layers with names matching the given name.\n *\n * Parameters:\n- * options - {Object} Object whose properties will be set on the instance.\n+ * match - {String | Object} A layer 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(layer.name) evaluates to true, the layer will be included\n+ * in the list of layers returned. If no layers are found, an empty\n+ * array is returned.\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+ * Returns:\n+ * {Array()} A list of layers matching the given name.\n+ * An empty array is returned if no matches are found.\n+ */\n+ getLayersByName: function(match) {\n+ return this.getLayersBy(\"name\", match);\n+ },\n+\n+ /**\n+ * APIMethod: getLayersByClass\n+ * Get a list of layers of a given class (CLASS_NAME).\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+ * match - {String | Object} A layer class name. The match 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(layer.CLASS_NAME) evaluates to true, the layer will\n+ * be included in the list of layers returned. If no layers are\n+ * found, an empty array is returned.\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+ * {Array()} A list of layers matching the given class.\n+ * An empty array is returned if no matches are found.\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- }\n+ getLayersByClass: function(match) {\n+ return this.getLayersBy(\"CLASS_NAME\", match);\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+ * APIMethod: getControlsBy\n+ * Get a list of controls with properties matching the given criteria.\n *\n * Parameters:\n- * options - {Object} Options for the execute operation.\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(layer[property]) evaluates to true, the layer will be\n+ * included in the array returned. If no layers are found, an empty\n+ * array is returned.\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+ * Returns:\n+ * {Array()} A list of controls matching the given\n+ * criteria. An empty array is returned if no matches are found.\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+ getControlsBy: function(property, match) {\n+ return this.getBy(\"controls\", property, match);\n },\n \n /**\n- * APIMethod: getProcess\n- * Creates an .\n+ * APIMethod: getControlsByClass\n+ * Get a list of controls of a given class (CLASS_NAME).\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+ * match - {String | Object} A control class name. The match 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- * {}\n+ * {Array()} A list of controls matching the given class.\n+ * An empty array is returned if no matches are found.\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+ getControlsByClass: function(match) {\n+ return this.getControlsBy(\"CLASS_NAME\", match);\n },\n \n+ /********************************************************/\n+ /* */\n+ /* Layer Functions */\n+ /* */\n+ /* The following functions deal with adding and */\n+ /* removing Layers to and from the Map */\n+ /* */\n+ /********************************************************/\n+\n /**\n- * Method: describeProcess\n+ * APIMethod: getLayer\n+ * Get a layer based on its id\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+ * id - {String} A layer id\n+ *\n+ * Returns:\n+ * {} The Layer with the corresponding id from the map's \n+ * layer collection, or null if not found.\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+ getLayer: function(id) {\n+ var foundLayer = null;\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n+ var layer = this.layers[i];\n+ if (layer.id == id) {\n+ foundLayer = layer;\n+ break;\n }\n- } else {\n- window.setTimeout(function() {\n- callback.call(scope, server.processDescription[processID]);\n- }, 0);\n }\n+ return foundLayer;\n },\n \n /**\n- * Method: destroy\n+ * Method: setLayerZIndex\n+ * \n+ * Parameters:\n+ * layer - {} \n+ * zIdx - {int} \n */\n- destroy: function() {\n- this.events.destroy();\n- this.events = null;\n- this.servers = null;\n+ setLayerZIndex: function(layer, zIdx) {\n+ layer.setZIndex(\n+ this.Z_INDEX_BASE[layer.isBaseLayer ? 'BaseLayer' : 'Overlay'] +\n+ zIdx * 5);\n },\n \n- CLASS_NAME: 'OpenLayers.WPSClient'\n+ /**\n+ * Method: resetLayersZIndex\n+ * Reset each layer's z-index based on layer's array index\n+ */\n+ resetLayersZIndex: function() {\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n+ var layer = this.layers[i];\n+ this.setLayerZIndex(layer, i);\n+ }\n+ },\n \n-});\n-/* ======================================================================\n- OpenLayers/Tile.js\n- ====================================================================== */\n+ /**\n+ * APIMethod: addLayer\n+ *\n+ * Parameters:\n+ * layer - {} \n+ *\n+ * Returns:\n+ * {Boolean} True if the layer has been added to the map.\n+ */\n+ addLayer: function(layer) {\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n+ if (this.layers[i] == layer) {\n+ return false;\n+ }\n+ }\n+ if (this.events.triggerEvent(\"preaddlayer\", {\n+ layer: layer\n+ }) === false) {\n+ return false;\n+ }\n+ if (this.allOverlays) {\n+ layer.isBaseLayer = false;\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+ layer.div.className = \"olLayerDiv\";\n+ layer.div.style.overflow = \"\";\n+ this.setLayerZIndex(layer, this.layers.length);\n \n+ if (layer.isFixed) {\n+ this.viewPortDiv.appendChild(layer.div);\n+ } else {\n+ this.layerContainerDiv.appendChild(layer.div);\n+ }\n+ this.layers.push(layer);\n+ layer.setMap(this);\n \n-/**\n- * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Util.js\n- */\n+ if (layer.isBaseLayer || (this.allOverlays && !this.baseLayer)) {\n+ if (this.baseLayer == null) {\n+ // set the first baselaye we add as the baselayer\n+ this.setBaseLayer(layer);\n+ } else {\n+ layer.setVisibility(false);\n+ }\n+ } else {\n+ layer.redraw();\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+ this.events.triggerEvent(\"addlayer\", {\n+ layer: layer\n+ });\n+ layer.events.triggerEvent(\"added\", {\n+ map: this,\n+ layer: layer\n+ });\n+ layer.afterAdd();\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+ return true;\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+ * APIMethod: addLayers \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+ * Parameters:\n+ * layers - {Array()} \n */\n- id: null,\n+ addLayers: function(layers) {\n+ for (var i = 0, len = layers.length; i < len; i++) {\n+ this.addLayer(layers[i]);\n+ }\n+ },\n \n /** \n- * Property: layer \n- * {} layer the tile is attached to \n+ * APIMethod: removeLayer\n+ * Removes a layer from the map by removing its visual element (the \n+ * layer.div property), then removing it from the map's internal list \n+ * of layers, setting the layer's map property to null. \n+ * \n+ * a \"removelayer\" event is triggered.\n+ * \n+ * very worthy of mention is that simply removing a layer from a map\n+ * will not cause the removal of any popups which may have been created\n+ * by the layer. this is due to the fact that it was decided at some\n+ * point that popups would not belong to layers. thus there is no way \n+ * for us to know here to which layer the popup belongs.\n+ * \n+ * A simple solution to this is simply to call destroy() on the layer.\n+ * the default OpenLayers.Layer class's destroy() function\n+ * automatically takes care to remove itself from whatever map it has\n+ * been attached to. \n+ * \n+ * The correct solution is for the layer itself to register an \n+ * event-handler on \"removelayer\" and when it is called, if it \n+ * recognizes itself as the layer being removed, then it cycles through\n+ * its own personal list of popups, removing them from the map.\n+ * \n+ * Parameters:\n+ * layer - {} \n+ * setNewBaseLayer - {Boolean} Default is true\n */\n- layer: null,\n+ removeLayer: function(layer, setNewBaseLayer) {\n+ if (this.events.triggerEvent(\"preremovelayer\", {\n+ layer: layer\n+ }) === false) {\n+ return;\n+ }\n+ if (setNewBaseLayer == null) {\n+ setNewBaseLayer = true;\n+ }\n+\n+ if (layer.isFixed) {\n+ this.viewPortDiv.removeChild(layer.div);\n+ } else {\n+ this.layerContainerDiv.removeChild(layer.div);\n+ }\n+ OpenLayers.Util.removeItem(this.layers, layer);\n+ layer.removeMap(this);\n+ layer.map = null;\n+\n+ // if we removed the base layer, need to set a new one\n+ if (this.baseLayer == layer) {\n+ this.baseLayer = null;\n+ if (setNewBaseLayer) {\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n+ var iLayer = this.layers[i];\n+ if (iLayer.isBaseLayer || this.allOverlays) {\n+ this.setBaseLayer(iLayer);\n+ break;\n+ }\n+ }\n+ }\n+ }\n+\n+ this.resetLayersZIndex();\n+\n+ this.events.triggerEvent(\"removelayer\", {\n+ layer: layer\n+ });\n+ layer.events.triggerEvent(\"removed\", {\n+ map: this,\n+ layer: layer\n+ });\n+ },\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+ * APIMethod: getNumLayers\n+ * \n+ * Returns:\n+ * {Int} The number of layers attached to the map.\n */\n- url: null,\n+ getNumLayers: function() {\n+ return this.layers.length;\n+ },\n \n /** \n- * APIProperty: bounds \n- * {} null\n+ * APIMethod: getLayerIndex\n+ *\n+ * Parameters:\n+ * layer - {}\n+ *\n+ * Returns:\n+ * {Integer} The current (zero-based) index of the given layer in the map's\n+ * layer stack. Returns -1 if the layer isn't on the map.\n */\n- bounds: null,\n+ getLayerIndex: function(layer) {\n+ return OpenLayers.Util.indexOf(this.layers, layer);\n+ },\n \n /** \n- * Property: size \n- * {} null\n+ * APIMethod: setLayerIndex\n+ * Move the given layer to the specified (zero-based) index in the layer\n+ * list, changing its z-index in the map display. Use\n+ * map.getLayerIndex() to find out the current index of a layer. Note\n+ * that this cannot (or at least should not) be effectively used to\n+ * raise base layers above overlays.\n+ *\n+ * Parameters:\n+ * layer - {} \n+ * idx - {int} \n */\n- size: null,\n+ setLayerIndex: function(layer, idx) {\n+ var base = this.getLayerIndex(layer);\n+ if (idx < 0) {\n+ idx = 0;\n+ } else if (idx > this.layers.length) {\n+ idx = this.layers.length;\n+ }\n+ if (base != idx) {\n+ this.layers.splice(base, 1);\n+ this.layers.splice(idx, 0, layer);\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n+ this.setLayerZIndex(this.layers[i], i);\n+ }\n+ this.events.triggerEvent(\"changelayer\", {\n+ layer: layer,\n+ property: \"order\"\n+ });\n+ if (this.allOverlays) {\n+ if (idx === 0) {\n+ this.setBaseLayer(layer);\n+ } else if (this.baseLayer !== this.layers[0]) {\n+ this.setBaseLayer(this.layers[0]);\n+ }\n+ }\n+ }\n+ },\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+ * APIMethod: raiseLayer\n+ * Change the index of the given layer by delta. If delta is positive, \n+ * the layer is moved up the map's layer stack; if delta is negative,\n+ * the layer is moved down. Again, note that this cannot (or at least\n+ * should not) be effectively used to raise base layers above overlays.\n+ *\n+ * Paremeters:\n+ * layer - {} \n+ * delta - {int} \n */\n+ raiseLayer: function(layer, delta) {\n+ var idx = this.getLayerIndex(layer) + delta;\n+ this.setLayerIndex(layer, idx);\n+ },\n \n /** \n- * Constructor: OpenLayers.Tile\n- * Constructor for a new instance.\n+ * APIMethod: setBaseLayer\n+ * Allows user to specify one of the currently-loaded layers as the Map's\n+ * new base layer.\n * \n * Parameters:\n- * layer - {} layer that the tile will go in.\n- * position - {}\n- * bounds - {}\n- * url - {}\n- * size - {}\n- * options - {Object}\n+ * newBaseLayer - {}\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+ setBaseLayer: function(newBaseLayer) {\n \n- //give the tile a unique id based on its BBOX.\n- this.id = OpenLayers.Util.createUniqueID(\"Tile_\");\n+ if (newBaseLayer != this.baseLayer) {\n \n- OpenLayers.Util.extend(this, options);\n+ // ensure newBaseLayer is already loaded\n+ if (OpenLayers.Util.indexOf(this.layers, newBaseLayer) != -1) {\n \n- this.events = new OpenLayers.Events(this);\n- if (this.eventListeners instanceof Object) {\n- this.events.on(this.eventListeners);\n+ // preserve center and scale when changing base layers\n+ var center = this.getCachedCenter();\n+ var newResolution = OpenLayers.Util.getResolutionFromScale(\n+ this.getScale(), newBaseLayer.units\n+ );\n+\n+ // make the old base layer invisible \n+ if (this.baseLayer != null && !this.allOverlays) {\n+ this.baseLayer.setVisibility(false);\n+ }\n+\n+ // set new baselayer\n+ this.baseLayer = newBaseLayer;\n+\n+ if (!this.allOverlays || this.baseLayer.visibility) {\n+ this.baseLayer.setVisibility(true);\n+ // Layer may previously have been visible but not in range.\n+ // In this case we need to redraw it to make it visible.\n+ if (this.baseLayer.inRange === false) {\n+ this.baseLayer.redraw();\n+ }\n+ }\n+\n+ // recenter the map\n+ if (center != null) {\n+ // new zoom level derived from old scale\n+ var newZoom = this.getZoomForResolution(\n+ newResolution || this.resolution, true\n+ );\n+ // zoom and force zoom change\n+ this.setCenter(center, newZoom, false, true);\n+ }\n+\n+ this.events.triggerEvent(\"changebaselayer\", {\n+ layer: this.baseLayer\n+ });\n+ }\n }\n },\n \n+\n+ /********************************************************/\n+ /* */\n+ /* Control Functions */\n+ /* */\n+ /* The following functions deal with adding and */\n+ /* removing Controls to and from the Map */\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+ * APIMethod: addControl\n+ * Add the passed over control to the map. Optionally \n+ * position the control at the given pixel.\n+ * \n+ * Parameters:\n+ * control - {}\n+ * px - {}\n */\n- unload: function() {\n- if (this.isLoading) {\n- this.isLoading = false;\n- this.events.triggerEvent(\"unload\");\n- }\n+ addControl: function(control, px) {\n+ this.controls.push(control);\n+ this.addControlToMap(control, px);\n },\n \n- /** \n- * APIMethod: destroy\n- * Nullify references to prevent circular references and memory leaks.\n+ /**\n+ * APIMethod: addControls\n+ * Add all of the passed over controls to the map. \n+ * You can pass over an optional second array\n+ * with pixel-objects to position the controls.\n+ * The indices of the two arrays should match and\n+ * you can add null as pixel for those controls \n+ * you want to be autopositioned. \n+ * \n+ * Parameters:\n+ * controls - {Array()}\n+ * pixels - {Array()}\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+ addControls: function(controls, pixels) {\n+ var pxs = (arguments.length === 1) ? [] : pixels;\n+ for (var i = 0, len = controls.length; i < len; i++) {\n+ var ctrl = controls[i];\n+ var px = (pxs[i]) ? pxs[i] : null;\n+ this.addControl(ctrl, px);\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+ * Method: addControlToMap\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+ * control - {}\n+ * px - {}\n */\n- draw: function(force) {\n- if (!force) {\n- //clear tile's contents and mark as not drawn\n- this.clear();\n+ addControlToMap: function(control, px) {\n+ // If a control doesn't have a div at this point, it belongs in the\n+ // viewport.\n+ control.outsideViewport = (control.div != null);\n+\n+ // If the map has a displayProjection, and the control doesn't, set \n+ // the display projection.\n+ if (this.displayProjection && !control.displayProjection) {\n+ control.displayProjection = this.displayProjection;\n }\n- var draw = this.shouldDraw();\n- if (draw && !force && this.events.triggerEvent(\"beforedraw\") === false) {\n- draw = null;\n+\n+ control.setMap(this);\n+ var div = control.draw(px);\n+ if (div) {\n+ if (!control.outsideViewport) {\n+ div.style.zIndex = this.Z_INDEX_BASE['Control'] +\n+ this.controls.length;\n+ this.viewPortDiv.appendChild(div);\n+ }\n+ }\n+ if (control.autoActivate) {\n+ control.activate();\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+ * APIMethod: getControl\n+ * \n+ * Parameters:\n+ * id - {String} ID of the control to return.\n * \n * Returns:\n- * {Boolean} Whether or not the tile should actually be drawn.\n+ * {} The control from the map's list of controls \n+ * which has a matching 'id'. If none found, \n+ * returns null.\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+ getControl: function(id) {\n+ var returnControl = null;\n+ for (var i = 0, len = this.controls.length; i < len; i++) {\n+ var control = this.controls[i];\n+ if (control.id == id) {\n+ returnControl = control;\n+ break;\n }\n }\n-\n- return withinMaxExtent || this.layer.displayOutsideMaxExtent;\n+ return returnControl;\n },\n \n- /**\n- * Method: setBounds\n- * Sets the bounds on this instance\n- *\n+ /** \n+ * APIMethod: removeControl\n+ * Remove a control from the map. Removes the control both from the map \n+ * object's internal array of controls, as well as from the map's \n+ * viewPort (assuming the control was not added outsideViewport)\n+ * \n * Parameters:\n- * bounds {}\n+ * control - {} The control to remove.\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+ removeControl: function(control) {\n+ //make sure control is non-null and actually part of our map\n+ if ((control) && (control == this.getControl(control.id))) {\n+ if (control.div && (control.div.parentNode == this.viewPortDiv)) {\n+ this.viewPortDiv.removeChild(control.div);\n+ }\n+ OpenLayers.Util.removeItem(this.controls, control);\n }\n- this.bounds = bounds;\n },\n \n+ /********************************************************/\n+ /* */\n+ /* Popup Functions */\n+ /* */\n+ /* The following functions deal with adding and */\n+ /* removing Popups to and from the Map */\n+ /* */\n+ /********************************************************/\n+\n /** \n- * Method: moveTo\n- * Reposition the tile.\n- *\n+ * APIMethod: addPopup\n+ * \n * Parameters:\n- * bounds - {}\n- * position - {}\n- * redraw - {Boolean} Call draw method on tile after moving.\n- * Default is true\n+ * popup - {}\n+ * exclusive - {Boolean} If true, closes all other popups first\n */\n- moveTo: function(bounds, position, redraw) {\n- if (redraw == null) {\n- redraw = true;\n+ addPopup: function(popup, exclusive) {\n+\n+ if (exclusive) {\n+ //remove all other popups from screen\n+ for (var i = this.popups.length - 1; i >= 0; --i) {\n+ this.removePopup(this.popups[i]);\n+ }\n }\n \n- this.setBounds(bounds);\n- this.position = position.clone();\n- if (redraw) {\n- this.draw();\n+ popup.map = this;\n+ this.popups.push(popup);\n+ var popupDiv = popup.draw();\n+ if (popupDiv) {\n+ popupDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] +\n+ this.popups.length;\n+ this.layerContainerDiv.appendChild(popupDiv);\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+ * APIMethod: removePopup\n+ * \n+ * Parameters:\n+ * popup - {}\n */\n- clear: function(draw) {\n- // to be extended by subclasses\n+ removePopup: function(popup) {\n+ OpenLayers.Util.removeItem(this.popups, popup);\n+ if (popup.div) {\n+ try {\n+ this.layerContainerDiv.removeChild(popup.div);\n+ } catch (e) {} // Popups sometimes apparently get disconnected\n+ // from the layerContainerDiv, and cause complaints.\n+ }\n+ popup.map = null;\n },\n \n- CLASS_NAME: \"OpenLayers.Tile\"\n-});\n-/* ======================================================================\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/BaseTypes/Class.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+ /* Container Div Functions */\n+ /* */\n+ /* The following functions deal with the access to */\n+ /* and maintenance of the size of the container div */\n+ /* */\n+ /********************************************************/\n \n- /** \n- * Property: container\n- * {DOMElement} \n+ /**\n+ * APIMethod: getSize\n+ * \n+ * Returns:\n+ * {} An object that represents the \n+ * size, in pixels, of the div into which OpenLayers \n+ * has been loaded. \n+ * Note - A clone() of this locally cached variable is\n+ * returned, so as not to allow users to modify it.\n */\n- container: null,\n+ getSize: function() {\n+ var size = null;\n+ if (this.size != null) {\n+ size = this.size.clone();\n+ }\n+ return size;\n+ },\n \n /**\n- * Property: root\n- * {DOMElement}\n+ * APIMethod: updateSize\n+ * This function should be called by any external code which dynamically\n+ * changes the size of the map div (because mozilla wont let us catch \n+ * the \"onresize\" for an element)\n */\n- root: null,\n+ updateSize: function() {\n+ // the div might have moved on the page, also\n+ var newSize = this.getCurrentSize();\n+ if (newSize && !isNaN(newSize.h) && !isNaN(newSize.w)) {\n+ this.events.clearMouseCache();\n+ var oldSize = this.getSize();\n+ if (oldSize == null) {\n+ this.size = oldSize = newSize;\n+ }\n+ if (!newSize.equals(oldSize)) {\n \n- /** \n- * Property: extent\n- * {}\n- */\n- extent: null,\n+ // store the new size\n+ this.size = newSize;\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- */\n- locked: false,\n+ //notify layers of mapresize\n+ for (var i = 0, len = this.layers.length; i < len; i++) {\n+ this.layers[i].onMapResize();\n+ }\n \n- /** \n- * Property: size\n- * {} \n- */\n- size: null,\n+ var center = this.getCachedCenter();\n \n- /**\n- * Property: resolution\n- * {Float} cache of current map resolution\n- */\n- resolution: null,\n+ if (this.baseLayer != null && center != null) {\n+ var zoom = this.getZoom();\n+ this.zoom = null;\n+ this.setCenter(center, zoom);\n+ }\n \n- /**\n- * Property: map \n- * {} Reference to the map -- this is set in Vector's setMap()\n- */\n- map: null,\n+ }\n+ }\n+ this.events.triggerEvent(\"updatesize\");\n+ },\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+ * Method: getCurrentSize\n+ * \n+ * Returns:\n+ * {} A new object with the dimensions \n+ * of the map div\n */\n- featureDx: 0,\n+ getCurrentSize: function() {\n \n- /**\n- * Constructor: OpenLayers.Renderer \n- *\n- * Parameters:\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+ var size = new OpenLayers.Size(this.div.clientWidth,\n+ this.div.clientHeight);\n+\n+ if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {\n+ size.w = this.div.offsetWidth;\n+ size.h = this.div.offsetHeight;\n+ }\n+ if (size.w == 0 && size.h == 0 || isNaN(size.w) && isNaN(size.h)) {\n+ size.w = parseInt(this.div.style.width);\n+ size.h = parseInt(this.div.style.height);\n+ }\n+ return size;\n },\n \n- /**\n- * APIMethod: destroy\n+ /** \n+ * Method: calculateBounds\n+ * \n+ * Parameters:\n+ * center - {} Default is this.getCenter()\n+ * resolution - {float} Default is this.getResolution() \n+ * \n+ * Returns:\n+ * {} A bounds based on resolution, center, and \n+ * current mapsize.\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+ calculateBounds: function(center, resolution) {\n+\n+ var extent = null;\n+\n+ if (center == null) {\n+ center = this.getCachedCenter();\n+ }\n+ if (resolution == null) {\n+ resolution = this.getResolution();\n+ }\n+\n+ if ((center != null) && (resolution != null)) {\n+ var halfWDeg = (this.size.w * resolution) / 2;\n+ var halfHDeg = (this.size.h * resolution) / 2;\n+\n+ extent = new OpenLayers.Bounds(center.lon - halfWDeg,\n+ center.lat - halfHDeg,\n+ center.lon + halfWDeg,\n+ center.lat + halfHDeg);\n+ }\n+\n+ return extent;\n },\n \n+\n+ /********************************************************/\n+ /* */\n+ /* Zoom, Center, Pan Functions */\n+ /* */\n+ /* The following functions handle the validation, */\n+ /* getting and setting of the Zoom Level and Center */\n+ /* as well as the panning of the Map */\n+ /* */\n+ /********************************************************/\n /**\n- * APIMethod: supported\n- * This should be overridden by specific subclasses\n+ * APIMethod: getCenter\n * \n * Returns:\n- * {Boolean} Whether or not the browser supports the renderer class\n+ * {}\n */\n- supported: function() {\n- return false;\n+ getCenter: function() {\n+ var center = null;\n+ var cachedCenter = this.getCachedCenter();\n+ if (cachedCenter) {\n+ center = cachedCenter.clone();\n+ }\n+ return center;\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- *\n- * Parameters:\n- * extent - {}\n- * resolutionChanged - {Boolean}\n+ * Method: getCachedCenter\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+ * {}\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+ getCachedCenter: function() {\n+ if (!this.center && this.size) {\n+ this.center = this.getLonLatFromViewPortPx({\n+ x: this.size.w / 2,\n+ y: this.size.h / 2\n+ });\n }\n- return true;\n+ return this.center;\n },\n \n /**\n- * Method: setSize\n- * Sets the size of the drawing surface.\n+ * APIMethod: getZoom\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- * size - {} \n+ * Returns:\n+ * {Integer}\n */\n- setSize: function(size) {\n- this.size = size.clone();\n- this.resolution = null;\n+ getZoom: function() {\n+ return this.zoom;\n },\n \n /** \n- * Method: getResolution\n- * Uses cached copy of resolution if available to minimize computing\n+ * APIMethod: pan\n+ * Allows user to pan by a value of screen pixels\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- *\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+ * dx - {Integer}\n+ * dy - {Integer}\n+ * options - {Object} Options to configure panning:\n+ * - *animate* {Boolean} Use panTo instead of setCenter. Default is true.\n+ * - *dragging* {Boolean} Call setCenter with dragging true. Default is\n+ * false.\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+ pan: function(dx, dy, options) {\n+ options = OpenLayers.Util.applyDefaults(options, {\n+ animate: true,\n+ dragging: false\n+ });\n+ if (options.dragging) {\n+ if (dx != 0 || dy != 0) {\n+ this.moveByPx(dx, dy);\n+ }\n+ } else {\n+ // getCenter\n+ var centerPx = this.getViewPortPxFromLonLat(this.getCachedCenter());\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+ // adjust\n+ var newCenterPx = centerPx.add(dx, dy);\n+\n+ if (this.dragging || !newCenterPx.equals(centerPx)) {\n+ var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx);\n+ if (options.animate) {\n+ this.panTo(newCenterLonLat);\n } else {\n- this.removeText(feature.id);\n+ this.moveTo(newCenterLonLat);\n+ if (this.dragging) {\n+ this.dragging = false;\n+ this.events.triggerEvent(\"moveend\");\n+ }\n }\n- return rendered;\n }\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- }\n },\n \n /** \n- * Method: drawGeometry\n+ * APIMethod: panTo\n+ * Allows user to pan to a new lonlat\n+ * If the new lonlat is in the current extent the map will slide smoothly\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+ * lonlat - {}\n */\n- drawGeometry: function(geometry, style, featureId) {},\n+ panTo: function(lonlat) {\n+ if (this.panTween && this.getExtent().scale(this.panRatio).containsLonLat(lonlat)) {\n+ var center = this.getCachedCenter();\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+ // center will not change, don't do nothing\n+ if (lonlat.equals(center)) {\n+ return;\n+ }\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 from = this.getPixelFromLonLat(center);\n+ var to = this.getPixelFromLonLat(lonlat);\n+ var vector = {\n+ x: to.x - from.x,\n+ y: to.y - from.y\n+ };\n+ var last = {\n+ x: 0,\n+ y: 0\n+ };\n \n- /**\n- * Method: clear\n- * Clear all vectors from the renderer.\n- * virtual function.\n- */\n- clear: function() {},\n+ this.panTween.start({\n+ x: 0,\n+ y: 0\n+ }, vector, this.panDuration, {\n+ callbacks: {\n+ eachStep: OpenLayers.Function.bind(function(px) {\n+ var x = px.x - last.x,\n+ y = px.y - last.y;\n+ this.moveByPx(x, y);\n+ last.x = Math.round(px.x);\n+ last.y = Math.round(px.y);\n+ }, this),\n+ done: OpenLayers.Function.bind(function(px) {\n+ this.moveTo(lonlat);\n+ this.dragging = false;\n+ this.events.triggerEvent(\"moveend\");\n+ }, this)\n+ }\n+ });\n+ } else {\n+ this.setCenter(lonlat);\n+ }\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+ * APIMethod: setCenter\n+ * Set the map center (and optionally, the zoom level).\n * \n * Parameters:\n- * evt - {} \n+ * lonlat - {|Array} The new center location.\n+ * If provided as array, the first value is the x coordinate,\n+ * and the 2nd value is the y coordinate.\n+ * zoom - {Integer} Optional zoom level.\n+ * dragging - {Boolean} Specifies whether or not to trigger \n+ * movestart/end events\n+ * forceZoomChange - {Boolean} Specifies whether or not to trigger zoom \n+ * change events (needed on baseLayer change)\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+ * TBD: reconsider forceZoomChange in 3.0\n */\n- eraseFeatures: function(features) {\n- if (!(OpenLayers.Util.isArray(features))) {\n- features = [features];\n+ setCenter: function(lonlat, zoom, dragging, forceZoomChange) {\n+ if (this.panTween) {\n+ this.panTween.stop();\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+ if (this.zoomTween) {\n+ this.zoomTween.stop();\n }\n+ this.moveTo(lonlat, zoom, {\n+ 'dragging': dragging,\n+ 'forceZoomChange': forceZoomChange\n+ });\n },\n \n- /**\n- * Method: eraseGeometry\n- * Remove a geometry from the renderer (by id).\n- * virtual function.\n- * \n+ /** \n+ * Method: moveByPx\n+ * Drag the map by pixels.\n+ *\n * Parameters:\n- * geometry - {} \n- * featureId - {String}\n+ * dx - {Number}\n+ * dy - {Number}\n */\n- eraseGeometry: function(geometry, featureId) {},\n+ moveByPx: function(dx, dy) {\n+ var hw = this.size.w / 2;\n+ var hh = this.size.h / 2;\n+ var x = hw + dx;\n+ var y = hh + dy;\n+ var wrapDateLine = this.baseLayer.wrapDateLine;\n+ var xRestriction = 0;\n+ var yRestriction = 0;\n+ if (this.restrictedExtent) {\n+ xRestriction = hw;\n+ yRestriction = hh;\n+ // wrapping the date line makes no sense for restricted extents\n+ wrapDateLine = false;\n+ }\n+ dx = wrapDateLine ||\n+ x <= this.maxPx.x - xRestriction &&\n+ x >= this.minPx.x + xRestriction ? Math.round(dx) : 0;\n+ dy = y <= this.maxPx.y - yRestriction &&\n+ y >= this.minPx.y + yRestriction ? Math.round(dy) : 0;\n+ if (dx || dy) {\n+ if (!this.dragging) {\n+ this.dragging = true;\n+ this.events.triggerEvent(\"movestart\");\n+ }\n+ this.center = null;\n+ if (dx) {\n+ this.layerContainerOriginPx.x -= dx;\n+ this.minPx.x -= dx;\n+ this.maxPx.x -= dx;\n+ }\n+ if (dy) {\n+ this.layerContainerOriginPx.y -= dy;\n+ this.minPx.y -= dy;\n+ this.maxPx.y -= dy;\n+ }\n+ this.applyTransform();\n+ var layer, i, len;\n+ for (i = 0, len = this.layers.length; i < len; ++i) {\n+ layer = this.layers[i];\n+ if (layer.visibility &&\n+ (layer === this.baseLayer || layer.inRange)) {\n+ layer.moveByPx(dx, dy);\n+ layer.events.triggerEvent(\"move\");\n+ }\n+ }\n+ this.events.triggerEvent(\"move\");\n+ }\n+ },\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+ * Method: adjustZoom\n+ *\n * Parameters:\n- * renderer - {} target renderer for the moved root\n+ * zoom - {Number} The zoom level to adjust\n+ *\n+ * Returns:\n+ * {Integer} Adjusted zoom level that shows a map not wider than its\n+ * 's maxExtent.\n */\n- moveRoot: function(renderer) {},\n+ adjustZoom: function(zoom) {\n+ if (this.baseLayer && this.baseLayer.wrapDateLine) {\n+ var resolution, resolutions = this.baseLayer.resolutions,\n+ maxResolution = this.getMaxExtent().getWidth() / this.size.w;\n+ if (this.getResolutionForZoom(zoom) > maxResolution) {\n+ if (this.fractionalZoom) {\n+ zoom = this.getZoomForResolution(maxResolution);\n+ } else {\n+ for (var i = zoom | 0, ii = resolutions.length; i < ii; ++i) {\n+ if (resolutions[i] <= maxResolution) {\n+ zoom = i;\n+ break;\n+ }\n+ }\n+ }\n+ }\n+ }\n+ return zoom;\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+ * APIMethod: getMinZoom\n+ * Returns the minimum zoom level for the current map view. If the base\n+ * layer is configured with set to true, this will be the\n+ * first zoom level that shows no more than one world width in the current\n+ * map viewport. Components that rely on this value (e.g. zoom sliders)\n+ * should also listen to the map's \"updatesize\" event and call this method\n+ * in the \"updatesize\" listener.\n+ *\n * Returns:\n- * {String} the id of the output layer.\n+ * {Number} Minimum zoom level that shows a map not wider than its\n+ * 's maxExtent. This is an Integer value, unless the map is\n+ * configured with set to true.\n */\n- getRenderLayerId: function() {\n- return this.container.id;\n+ getMinZoom: function() {\n+ return this.adjustZoom(0);\n },\n \n /**\n- * Method: applyDefaultSymbolizer\n- * \n+ * Method: moveTo\n+ *\n * Parameters:\n- * symbolizer - {Object}\n- * \n- * Returns:\n- * {Object}\n+ * lonlat - {}\n+ * zoom - {Integer}\n+ * options - {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+ moveTo: function(lonlat, zoom, options) {\n+ if (lonlat != null && !(lonlat instanceof OpenLayers.LonLat)) {\n+ lonlat = new OpenLayers.LonLat(lonlat);\n }\n- if (symbolizer.fill === false) {\n- delete result.fillColor;\n+ if (!options) {\n+ options = {};\n }\n- OpenLayers.Util.extend(result, symbolizer);\n- return result;\n- },\n+ if (zoom != null) {\n+ zoom = parseFloat(zoom);\n+ if (!this.fractionalZoom) {\n+ zoom = Math.round(zoom);\n+ }\n+ }\n+ var requestedZoom = zoom;\n+ zoom = this.adjustZoom(zoom);\n+ if (zoom !== requestedZoom) {\n+ // zoom was adjusted, so keep old lonlat to avoid panning\n+ lonlat = this.getCenter();\n+ }\n+ // dragging is false by default\n+ var dragging = options.dragging || this.dragging;\n+ // forceZoomChange is false by default\n+ var forceZoomChange = options.forceZoomChange;\n \n- CLASS_NAME: \"OpenLayers.Renderer\"\n-});\n+ if (!this.getCachedCenter() && !this.isValidLonLat(lonlat)) {\n+ lonlat = this.maxExtent.getCenterLonLat();\n+ this.center = lonlat.clone();\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+ if (this.restrictedExtent != null) {\n+ // In 3.0, decide if we want to change interpretation of maxExtent.\n+ if (lonlat == null) {\n+ lonlat = this.center;\n+ }\n+ if (zoom == null) {\n+ zoom = this.getZoom();\n+ }\n+ var resolution = this.getResolutionForZoom(zoom);\n+ var extent = this.calculateBounds(lonlat, resolution);\n+ if (!this.restrictedExtent.containsBounds(extent)) {\n+ var maxCenter = this.restrictedExtent.getCenterLonLat();\n+ if (extent.getWidth() > this.restrictedExtent.getWidth()) {\n+ lonlat = new OpenLayers.LonLat(maxCenter.lon, lonlat.lat);\n+ } else if (extent.left < this.restrictedExtent.left) {\n+ lonlat = lonlat.add(this.restrictedExtent.left -\n+ extent.left, 0);\n+ } else if (extent.right > this.restrictedExtent.right) {\n+ lonlat = lonlat.add(this.restrictedExtent.right -\n+ extent.right, 0);\n+ }\n+ if (extent.getHeight() > this.restrictedExtent.getHeight()) {\n+ lonlat = new OpenLayers.LonLat(lonlat.lon, maxCenter.lat);\n+ } else if (extent.bottom < this.restrictedExtent.bottom) {\n+ lonlat = lonlat.add(0, this.restrictedExtent.bottom -\n+ extent.bottom);\n+ } else if (extent.top > this.restrictedExtent.top) {\n+ lonlat = lonlat.add(0, this.restrictedExtent.top -\n+ extent.top);\n+ }\n+ }\n+ }\n \n+ var zoomChanged = forceZoomChange || (\n+ (this.isValidZoomLevel(zoom)) &&\n+ (zoom != this.getZoom()));\n \n+ var centerChanged = (this.isValidLonLat(lonlat)) &&\n+ (!lonlat.equals(this.center));\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/HTTPRequest.js\n- ====================================================================== */\n+ // if neither center nor zoom will change, no need to do anything\n+ if (zoomChanged || centerChanged || dragging) {\n+ dragging || this.events.triggerEvent(\"movestart\", {\n+ zoomChanged: zoomChanged\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+ if (centerChanged) {\n+ if (!zoomChanged && this.center) {\n+ // if zoom hasnt changed, just slide layerContainer\n+ // (must be done before setting this.center to new value)\n+ this.centerLayerContainer(lonlat);\n+ }\n+ this.center = lonlat.clone();\n+ }\n \n+ var res = zoomChanged ?\n+ this.getResolutionForZoom(zoom) : this.getResolution();\n+ // (re)set the layerContainerDiv's location\n+ if (zoomChanged || this.layerContainerOrigin == null) {\n+ this.layerContainerOrigin = this.getCachedCenter();\n+ this.layerContainerOriginPx.x = 0;\n+ this.layerContainerOriginPx.y = 0;\n+ this.applyTransform();\n+ var maxExtent = this.getMaxExtent({\n+ restricted: true\n+ });\n+ var maxExtentCenter = maxExtent.getCenterLonLat();\n+ var lonDelta = this.center.lon - maxExtentCenter.lon;\n+ var latDelta = maxExtentCenter.lat - this.center.lat;\n+ var extentWidth = Math.round(maxExtent.getWidth() / res);\n+ var extentHeight = Math.round(maxExtent.getHeight() / res);\n+ this.minPx = {\n+ x: (this.size.w - extentWidth) / 2 - lonDelta / res,\n+ y: (this.size.h - extentHeight) / 2 - latDelta / res\n+ };\n+ this.maxPx = {\n+ x: this.minPx.x + Math.round(maxExtent.getWidth() / res),\n+ y: this.minPx.y + Math.round(maxExtent.getHeight() / res)\n+ };\n+ }\n \n-/**\n- * @requires OpenLayers/Layer.js\n- */\n+ if (zoomChanged) {\n+ this.zoom = zoom;\n+ this.resolution = res;\n+ }\n \n-/**\n- * Class: OpenLayers.Layer.HTTPRequest\n- * \n- * Inherits from: \n- * - \n- */\n-OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {\n+ var bounds = this.getExtent();\n \n- /** \n- * Constant: URL_HASH_FACTOR\n- * {Float} Used to hash URL param strings for multi-WMS server selection.\n- * Set to the Golden Ratio per Knuth's recommendation.\n- */\n- URL_HASH_FACTOR: (Math.sqrt(5) - 1) / 2,\n+ //send the move call to the baselayer and all the overlays \n \n- /** \n- * Property: url\n- * {Array(String) or String} This is either an array of url strings or \n- * a single url string. \n- */\n- url: null,\n+ if (this.baseLayer.visibility) {\n+ this.baseLayer.moveTo(bounds, zoomChanged, options.dragging);\n+ options.dragging || this.baseLayer.events.triggerEvent(\n+ \"moveend\", {\n+ zoomChanged: zoomChanged\n+ }\n+ );\n+ }\n \n- /** \n- * Property: params\n- * {Object} Hashtable of key/value parameters\n- */\n- params: null,\n+ bounds = this.baseLayer.getExtent();\n \n- /** \n- * APIProperty: reproject\n- * *Deprecated*. See http://docs.openlayers.org/library/spherical_mercator.html\n- * for information on the replacement for this functionality. \n- * {Boolean} Whether layer should reproject itself based on base layer \n- * locations. This allows reprojection onto commercial layers. \n- * Default is false: Most layers can't reproject, but layers \n- * which can create non-square geographic pixels can, like WMS.\n- * \n- */\n- reproject: false,\n+ for (var i = this.layers.length - 1; i >= 0; --i) {\n+ var layer = this.layers[i];\n+ if (layer !== this.baseLayer && !layer.isBaseLayer) {\n+ var inRange = layer.calculateInRange();\n+ if (layer.inRange != inRange) {\n+ // the inRange property has changed. If the layer is\n+ // no longer in range, we turn it off right away. If\n+ // the layer is no longer out of range, the moveTo\n+ // call below will turn on the layer.\n+ layer.inRange = inRange;\n+ if (!inRange) {\n+ layer.display(false);\n+ }\n+ this.events.triggerEvent(\"changelayer\", {\n+ layer: layer,\n+ property: \"visibility\"\n+ });\n+ }\n+ if (inRange && layer.visibility) {\n+ layer.moveTo(bounds, zoomChanged, options.dragging);\n+ options.dragging || layer.events.triggerEvent(\n+ \"moveend\", {\n+ zoomChanged: zoomChanged\n+ }\n+ );\n+ }\n+ }\n+ }\n \n- /**\n- * Constructor: OpenLayers.Layer.HTTPRequest\n+ this.events.triggerEvent(\"move\");\n+ dragging || this.events.triggerEvent(\"moveend\");\n+\n+ if (zoomChanged) {\n+ //redraw popups\n+ for (var i = 0, len = this.popups.length; i < len; i++) {\n+ this.popups[i].updatePosition();\n+ }\n+ this.events.triggerEvent(\"zoomend\");\n+ }\n+ }\n+ },\n+\n+ /** \n+ * Method: centerLayerContainer\n+ * This function takes care to recenter the layerContainerDiv.\n * \n * Parameters:\n- * name - {String}\n- * url - {Array(String) or String}\n- * params - {Object}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ * lonlat - {}\n */\n- initialize: function(name, url, params, options) {\n- OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);\n- this.url = url;\n- if (!this.params) {\n- this.params = OpenLayers.Util.extend({}, params);\n+ centerLayerContainer: function(lonlat) {\n+ var originPx = this.getViewPortPxFromLonLat(this.layerContainerOrigin);\n+ var newPx = this.getViewPortPxFromLonLat(lonlat);\n+\n+ if ((originPx != null) && (newPx != null)) {\n+ var oldLeft = this.layerContainerOriginPx.x;\n+ var oldTop = this.layerContainerOriginPx.y;\n+ var newLeft = Math.round(originPx.x - newPx.x);\n+ var newTop = Math.round(originPx.y - newPx.y);\n+ this.applyTransform(\n+ (this.layerContainerOriginPx.x = newLeft),\n+ (this.layerContainerOriginPx.y = newTop));\n+ var dx = oldLeft - newLeft;\n+ var dy = oldTop - newTop;\n+ this.minPx.x -= dx;\n+ this.maxPx.x -= dx;\n+ this.minPx.y -= dy;\n+ this.maxPx.y -= dy;\n }\n },\n \n /**\n- * APIMethod: destroy\n+ * Method: isValidZoomLevel\n+ * \n+ * Parameters:\n+ * zoomLevel - {Integer}\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the zoom level passed in is non-null and \n+ * within the min/max range of zoom levels.\n */\n- destroy: function() {\n- this.url = null;\n- this.params = null;\n- OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n+ isValidZoomLevel: function(zoomLevel) {\n+ return ((zoomLevel != null) &&\n+ (zoomLevel >= 0) &&\n+ (zoomLevel < this.getNumZoomLevels()));\n },\n \n /**\n- * APIMethod: clone\n+ * Method: isValidLonLat\n * \n * Parameters:\n- * obj - {Object}\n+ * lonlat - {}\n * \n * Returns:\n- * {} An exact clone of this \n- * \n+ * {Boolean} Whether or not the lonlat passed in is non-null and within\n+ * the maxExtent bounds\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.HTTPRequest(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n+ isValidLonLat: function(lonlat) {\n+ var valid = false;\n+ if (lonlat != null) {\n+ var maxExtent = this.getMaxExtent();\n+ var worldBounds = this.baseLayer.wrapDateLine && maxExtent;\n+ valid = maxExtent.containsLonLat(lonlat, {\n+ worldBounds: worldBounds\n+ });\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-\n- return obj;\n+ return valid;\n },\n \n- /** \n- * APIMethod: setUrl\n+ /********************************************************/\n+ /* */\n+ /* Layer Options */\n+ /* */\n+ /* Accessor functions to Layer Options parameters */\n+ /* */\n+ /********************************************************/\n+\n+ /**\n+ * APIMethod: getProjection\n+ * This method returns a string representing the projection. In \n+ * the case of projection support, this will be the srsCode which\n+ * is loaded -- otherwise it will simply be the string value that\n+ * was passed to the projection at startup.\n+ *\n+ * FIXME: In 3.0, we will remove getProjectionObject, and instead\n+ * return a Projection object from this function. \n * \n- * Parameters:\n- * newUrl - {String}\n+ * Returns:\n+ * {String} The Projection string from the base layer or null. \n */\n- setUrl: function(newUrl) {\n- this.url = newUrl;\n+ getProjection: function() {\n+ var projection = this.getProjectionObject();\n+ return projection ? projection.getCode() : null;\n },\n \n /**\n- * APIMethod: mergeNewParams\n- * \n- * Parameters:\n- * newParams - {Object}\n+ * APIMethod: getProjectionObject\n+ * Returns the projection obect from the baselayer.\n *\n * Returns:\n- * redrawn: {Boolean} whether the layer was actually redrawn.\n+ * {} The Projection of the base layer.\n */\n- mergeNewParams: function(newParams) {\n- this.params = OpenLayers.Util.extend(this.params, newParams);\n- var ret = this.redraw();\n- if (this.map != null) {\n- this.map.events.triggerEvent(\"changelayer\", {\n- layer: this,\n- property: \"params\"\n- });\n+ getProjectionObject: function() {\n+ var projection = null;\n+ if (this.baseLayer != null) {\n+ projection = this.baseLayer.projection;\n }\n- return ret;\n+ return projection;\n },\n \n /**\n- * APIMethod: redraw\n- * Redraws the layer. Returns true if the layer was redrawn, false if not.\n- *\n- * Parameters:\n- * force - {Boolean} Force redraw by adding random parameter.\n- *\n+ * APIMethod: getMaxResolution\n+ * \n * Returns:\n- * {Boolean} The layer was redrawn.\n+ * {String} The Map's Maximum Resolution\n */\n- redraw: function(force) {\n- if (force) {\n- return this.mergeNewParams({\n- \"_olSalt\": Math.random()\n- });\n- } else {\n- return OpenLayers.Layer.prototype.redraw.apply(this, []);\n+ getMaxResolution: function() {\n+ var maxResolution = null;\n+ if (this.baseLayer != null) {\n+ maxResolution = this.baseLayer.maxResolution;\n }\n+ return maxResolution;\n },\n \n /**\n- * Method: selectUrl\n- * selectUrl() implements the standard floating-point multiplicative\n- * hash function described by Knuth, and hashes the contents of the \n- * given param string into a float between 0 and 1. This float is then\n- * scaled to the size of the provided urls array, and used to select\n- * a URL.\n+ * APIMethod: getMaxExtent\n *\n * Parameters:\n- * paramString - {String}\n- * urls - {Array(String)}\n+ * options - {Object} \n * \n+ * Allowed Options:\n+ * restricted - {Boolean} If true, returns restricted extent (if it is \n+ * available.)\n+ *\n * Returns:\n- * {String} An entry from the urls array, deterministically selected based\n- * on the paramString.\n+ * {} The maxExtent property as set on the current \n+ * baselayer, unless the 'restricted' option is set, in which case\n+ * the 'restrictedExtent' option from the map is returned (if it\n+ * is set).\n */\n- selectUrl: function(paramString, urls) {\n- var product = 1;\n- for (var i = 0, len = paramString.length; i < len; i++) {\n- product *= paramString.charCodeAt(i) * this.URL_HASH_FACTOR;\n- product -= Math.floor(product);\n+ getMaxExtent: function(options) {\n+ var maxExtent = null;\n+ if (options && options.restricted && this.restrictedExtent) {\n+ maxExtent = this.restrictedExtent;\n+ } else if (this.baseLayer != null) {\n+ maxExtent = this.baseLayer.maxExtent;\n }\n- return urls[Math.floor(product * urls.length)];\n+ return maxExtent;\n },\n \n- /** \n- * Method: getFullRequestString\n- * Combine url with layer's params and these newParams. \n- * \n- * does checking on the serverPath variable, allowing for cases when it \n- * is supplied with trailing ? or &, as well as cases where not. \n- *\n- * return in formatted string like this:\n- * \"server?key1=value1&key2=value2&key3=value3\"\n+ /**\n+ * APIMethod: getNumZoomLevels\n * \n- * WARNING: The altUrl parameter is deprecated and will be removed in 3.0.\n- *\n- * Parameters:\n- * newParams - {Object}\n- * altUrl - {String} Use this as the url instead of the layer's url\n- * \n- * Returns: \n- * {String}\n+ * Returns:\n+ * {Integer} The total number of zoom levels that can be displayed by the \n+ * current baseLayer.\n */\n- getFullRequestString: function(newParams, altUrl) {\n-\n- // if not altUrl passed in, use layer's url\n- var url = altUrl || this.url;\n-\n- // create a new params hashtable with all the layer params and the \n- // new params together. then convert to string\n- var allParams = OpenLayers.Util.extend({}, this.params);\n- allParams = OpenLayers.Util.extend(allParams, newParams);\n- var paramsString = OpenLayers.Util.getParameterString(allParams);\n-\n- // if url is not a string, it should be an array of strings, \n- // in which case we will deterministically select one of them in \n- // order to evenly distribute requests to different urls.\n- //\n- if (OpenLayers.Util.isArray(url)) {\n- url = this.selectUrl(paramsString, url);\n- }\n-\n- // ignore parameters that are already in the url search string\n- var urlParams =\n- OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));\n- for (var key in allParams) {\n- if (key.toUpperCase() in urlParams) {\n- delete allParams[key];\n- }\n+ getNumZoomLevels: function() {\n+ var numZoomLevels = null;\n+ if (this.baseLayer != null) {\n+ numZoomLevels = this.baseLayer.numZoomLevels;\n }\n- paramsString = OpenLayers.Util.getParameterString(allParams);\n-\n- return OpenLayers.Util.urlAppend(url, paramsString);\n+ return numZoomLevels;\n },\n \n- CLASS_NAME: \"OpenLayers.Layer.HTTPRequest\"\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-\n-\n-/**\n- * @requires OpenLayers/Tile.js\n- * @requires OpenLayers/Animation.js\n- * @requires OpenLayers/Util.js\n- */\n-\n-/**\n- * Class: OpenLayers.Tile.Image\n- * Instances of OpenLayers.Tile.Image are used to manage the image tiles\n- * used by various layers. Create a new image tile with the\n- * constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {\n+ /********************************************************/\n+ /* */\n+ /* Baselayer Functions */\n+ /* */\n+ /* The following functions, all publicly exposed */\n+ /* in the API?, are all merely wrappers to the */\n+ /* the same calls on whatever layer is set as */\n+ /* the current base layer */\n+ /* */\n+ /********************************************************/\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 (in addition to the events):\n- * beforeload - Triggered before an image is prepared for loading, when the\n- * url for the image is known already. Listeners may call on\n- * the tile instance. If they do so, that image will be used and no new\n- * one will be created.\n- */\n-\n- /** \n- * APIProperty: url\n- * {String} The URL of the image being requested. No default. Filled in by\n- * layer.getURL() function. May be modified by loadstart listeners.\n- */\n- url: null,\n-\n- /** \n- * Property: imgDiv\n- * {HTMLImageElement} The image for this tile.\n+ * APIMethod: getExtent\n+ * \n+ * Returns:\n+ * {} A Bounds object which represents the lon/lat \n+ * bounds of the current viewPort. \n+ * If no baselayer is set, returns null.\n */\n- imgDiv: null,\n+ getExtent: function() {\n+ var extent = null;\n+ if (this.baseLayer != null) {\n+ extent = this.baseLayer.getExtent();\n+ }\n+ return extent;\n+ },\n \n /**\n- * Property: frame\n- * {DOMElement} The image element is appended to the frame. Any gutter on\n- * the image will be hidden behind the frame. If no gutter is set,\n- * this will be null.\n- */\n- frame: null,\n-\n- /** \n- * Property: imageReloadAttempts\n- * {Integer} Attempts to load the image.\n+ * APIMethod: getResolution\n+ * \n+ * Returns:\n+ * {Float} The current resolution of the map. \n+ * If no baselayer is set, returns null.\n */\n- imageReloadAttempts: null,\n+ getResolution: function() {\n+ var resolution = null;\n+ if (this.baseLayer != null) {\n+ resolution = this.baseLayer.getResolution();\n+ } else if (this.allOverlays === true && this.layers.length > 0) {\n+ // while adding the 1st layer to the map in allOverlays mode,\n+ // this.baseLayer is not set yet when we need the resolution\n+ // for calculateInRange.\n+ resolution = this.layers[0].getResolution();\n+ }\n+ return resolution;\n+ },\n \n /**\n- * Property: layerAlphaHack\n- * {Boolean} True if the png alpha hack needs to be applied on the layer's div.\n+ * APIMethod: getUnits\n+ * \n+ * Returns:\n+ * {Float} The current units of the map. \n+ * If no baselayer is set, returns null.\n */\n- layerAlphaHack: null,\n+ getUnits: function() {\n+ var units = null;\n+ if (this.baseLayer != null) {\n+ units = this.baseLayer.units;\n+ }\n+ return units;\n+ },\n \n /**\n- * Property: asyncRequestId\n- * {Integer} ID of an request to see if request is still valid. This is a\n- * number which increments by 1 for each asynchronous request.\n+ * APIMethod: getScale\n+ * \n+ * Returns:\n+ * {Float} The current scale denominator of the map. \n+ * If no baselayer is set, returns null.\n */\n- asyncRequestId: null,\n+ getScale: function() {\n+ var scale = null;\n+ if (this.baseLayer != null) {\n+ var res = this.getResolution();\n+ var units = this.baseLayer.units;\n+ scale = OpenLayers.Util.getScaleFromResolution(res, units);\n+ }\n+ return scale;\n+ },\n+\n \n /**\n- * APIProperty: maxGetUrlLength\n- * {Number} If set, requests that would result in GET urls with more\n- * characters than the number provided will be made using form-encoded\n- * HTTP POST. It is good practice to avoid urls that are longer than 2048\n- * characters.\n- *\n- * Caution:\n- * Older versions of Gecko based browsers (e.g. Firefox < 3.5) and most\n- * Opera versions do not fully support this option. On all browsers,\n- * transition effects are not supported if POST requests are used.\n+ * APIMethod: getZoomForExtent\n+ * \n+ * Parameters: \n+ * bounds - {}\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} A suitable zoom level for the specified bounds.\n+ * If no baselayer is set, returns null.\n */\n- maxGetUrlLength: null,\n+ getZoomForExtent: function(bounds, closest) {\n+ var zoom = null;\n+ if (this.baseLayer != null) {\n+ zoom = this.baseLayer.getZoomForExtent(bounds, closest);\n+ }\n+ return zoom;\n+ },\n \n /**\n- * Property: canvasContext\n- * {CanvasRenderingContext2D} A canvas context associated with\n- * the tile image.\n+ * APIMethod: getResolutionForZoom\n+ * \n+ * Parameters:\n+ * zoom - {Float}\n+ * \n+ * Returns:\n+ * {Float} A suitable resolution for the specified zoom. If no baselayer\n+ * is set, returns null.\n */\n- canvasContext: null,\n+ getResolutionForZoom: function(zoom) {\n+ var resolution = null;\n+ if (this.baseLayer) {\n+ resolution = this.baseLayer.getResolutionForZoom(zoom);\n+ }\n+ return resolution;\n+ },\n \n /**\n- * APIProperty: crossOriginKeyword\n- * The value of the crossorigin keyword to use when loading images. This is\n- * only relevant when using for tiles from remote\n- * origins and should be set to either 'anonymous' or 'use-credentials'\n- * for servers that send Access-Control-Allow-Origin headers with their\n- * tiles.\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+ * \n+ * Returns:\n+ * {Integer} A suitable zoom level for the specified resolution.\n+ * If no baselayer is set, returns null.\n */\n- crossOriginKeyword: null,\n+ getZoomForResolution: function(resolution, closest) {\n+ var zoom = null;\n+ if (this.baseLayer != null) {\n+ zoom = this.baseLayer.getZoomForResolution(resolution, closest);\n+ }\n+ return zoom;\n+ },\n \n- /** TBD 3.0 - reorder the parameters to the init function to remove \n- * URL. the getUrl() function on the layer gets called on \n- * each draw(), so no need to specify it here.\n- */\n+ /********************************************************/\n+ /* */\n+ /* Zooming Functions */\n+ /* */\n+ /* The following functions, all publicly exposed */\n+ /* in the API, are all merely wrappers to the */\n+ /* the setCenter() function */\n+ /* */\n+ /********************************************************/\n \n /** \n- * Constructor: OpenLayers.Tile.Image\n- * Constructor for a new instance.\n+ * APIMethod: zoomTo\n+ * Zoom to a specific zoom level. Zooming will be animated unless the map\n+ * is configured with {zoomMethod: null}. To zoom without animation, use\n+ * without a lonlat argument.\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+ * zoom - {Integer}\n */\n- initialize: function(layer, position, bounds, url, size, options) {\n- OpenLayers.Tile.prototype.initialize.apply(this, arguments);\n-\n- this.url = url; //deprecated remove me\n-\n- this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();\n+ zoomTo: function(zoom, xy) {\n+ // non-API arguments:\n+ // xy - {} optional zoom origin\n \n- if (this.maxGetUrlLength != null || this.layer.gutter || this.layerAlphaHack) {\n- // only create frame if it's needed\n- this.frame = document.createElement(\"div\");\n- this.frame.style.position = \"absolute\";\n- this.frame.style.overflow = \"hidden\";\n- }\n- if (this.maxGetUrlLength != null) {\n- OpenLayers.Util.extend(this, OpenLayers.Tile.Image.IFrame);\n+ var map = this;\n+ if (map.isValidZoomLevel(zoom)) {\n+ if (map.baseLayer.wrapDateLine) {\n+ zoom = map.adjustZoom(zoom);\n+ }\n+ if (map.zoomTween) {\n+ var currentRes = map.getResolution(),\n+ targetRes = map.getResolutionForZoom(zoom),\n+ start = {\n+ scale: 1\n+ },\n+ end = {\n+ scale: currentRes / targetRes\n+ };\n+ if (map.zoomTween.playing && map.zoomTween.duration < 3 * map.zoomDuration) {\n+ // update the end scale, and reuse the running zoomTween\n+ map.zoomTween.finish = {\n+ scale: map.zoomTween.finish.scale * end.scale\n+ };\n+ } else {\n+ if (!xy) {\n+ var size = map.getSize();\n+ xy = {\n+ x: size.w / 2,\n+ y: size.h / 2\n+ };\n+ }\n+ map.zoomTween.start(start, end, map.zoomDuration, {\n+ minFrameRate: 50, // don't spend much time zooming\n+ callbacks: {\n+ eachStep: function(data) {\n+ var containerOrigin = map.layerContainerOriginPx,\n+ scale = data.scale,\n+ dx = ((scale - 1) * (containerOrigin.x - xy.x)) | 0,\n+ dy = ((scale - 1) * (containerOrigin.y - xy.y)) | 0;\n+ map.applyTransform(containerOrigin.x + dx, containerOrigin.y + dy, scale);\n+ },\n+ done: function(data) {\n+ map.applyTransform();\n+ var resolution = map.getResolution() / data.scale,\n+ zoom = map.getZoomForResolution(resolution, true)\n+ map.moveTo(map.getZoomTargetCenter(xy, resolution), zoom, true);\n+ }\n+ }\n+ });\n+ }\n+ } else {\n+ var center = xy ?\n+ map.getZoomTargetCenter(xy, map.getResolutionForZoom(zoom)) :\n+ null;\n+ map.setCenter(center, zoom);\n+ }\n }\n },\n \n- /** \n- * APIMethod: destroy\n- * nullify references to prevent circular references and memory leaks\n+ /**\n+ * APIMethod: zoomIn\n+ * \n */\n- destroy: function() {\n- if (this.imgDiv) {\n- this.clear();\n- this.imgDiv = null;\n- this.frame = null;\n- }\n- // don't handle async requests any more\n- this.asyncRequestId = null;\n- OpenLayers.Tile.prototype.destroy.apply(this, arguments);\n+ zoomIn: function() {\n+ this.zoomTo(this.getZoom() + 1);\n },\n \n /**\n- * Method: draw\n- * Check that a tile should be drawn, and draw it.\n+ * APIMethod: zoomOut\n * \n- * Returns:\n- * {Boolean} Was a tile drawn? Or null if a beforedraw listener returned\n- * false.\n */\n- draw: function() {\n- var shouldDraw = OpenLayers.Tile.prototype.draw.apply(this, arguments);\n- if (shouldDraw) {\n- // The layer's reproject option is deprecated.\n- if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {\n- // getBoundsFromBaseLayer is defined in deprecated.js.\n- this.bounds = this.getBoundsFromBaseLayer(this.position);\n- }\n- if (this.isLoading) {\n- //if we're already loading, send 'reload' instead of 'loadstart'.\n- this._loadEvent = \"reload\";\n- } else {\n- this.isLoading = true;\n- this._loadEvent = \"loadstart\";\n- }\n- this.renderTile();\n- this.positionTile();\n- } else if (shouldDraw === false) {\n- this.unload();\n- }\n- return shouldDraw;\n+ zoomOut: function() {\n+ this.zoomTo(this.getZoom() - 1);\n },\n \n /**\n- * Method: renderTile\n- * Internal function to actually initialize the image tile,\n- * position it correctly, and set its url.\n+ * APIMethod: zoomToExtent\n+ * Zoom to the passed in bounds, recenter\n+ * \n+ * Parameters:\n+ * bounds - {|Array} If provided as an array, the array\n+ * should consist of four values (left, bottom, right, top).\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 */\n- renderTile: function() {\n- if (this.layer.async) {\n- // Asynchronous image requests call the asynchronous getURL method\n- // on the layer to fetch an image that covers 'this.bounds'.\n- var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1;\n- this.layer.getURLasync(this.bounds, function(url) {\n- if (id == this.asyncRequestId) {\n- this.url = url;\n- this.initImage();\n- }\n- }, this);\n- } else {\n- // synchronous image requests get the url immediately.\n- this.url = this.layer.getURL(this.bounds);\n- this.initImage();\n+ zoomToExtent: function(bounds, closest) {\n+ if (!(bounds instanceof OpenLayers.Bounds)) {\n+ bounds = new OpenLayers.Bounds(bounds);\n }\n- },\n+ var center = bounds.getCenterLonLat();\n+ if (this.baseLayer.wrapDateLine) {\n+ var maxExtent = this.getMaxExtent();\n \n- /**\n- * Method: positionTile\n- * Using the properties currenty set on the layer, position the tile correctly.\n- * This method is used both by the async and non-async versions of the Tile.Image\n- * code.\n- */\n- positionTile: function() {\n- var style = this.getTile().style,\n- size = this.frame ? this.size :\n- this.layer.getImageSize(this.bounds),\n- ratio = 1;\n- if (this.layer instanceof OpenLayers.Layer.Grid) {\n- ratio = this.layer.getServerResolution() / this.layer.map.getResolution();\n+ //fix straddling bounds (in the case of a bbox that straddles the \n+ // dateline, it's left and right boundaries will appear backwards. \n+ // we fix this by allowing a right value that is greater than the\n+ // max value at the dateline -- this allows us to pass a valid \n+ // bounds to calculate zoom)\n+ //\n+ bounds = bounds.clone();\n+ while (bounds.right < bounds.left) {\n+ bounds.right += maxExtent.getWidth();\n+ }\n+ //if the bounds was straddling (see above), then the center point \n+ // we got from it was wrong. So we take our new bounds and ask it\n+ // for the center.\n+ //\n+ center = bounds.getCenterLonLat().wrapDateLine(maxExtent);\n }\n- style.left = this.position.x + \"px\";\n- style.top = this.position.y + \"px\";\n- style.width = Math.round(ratio * size.w) + \"px\";\n- style.height = Math.round(ratio * size.h) + \"px\";\n+ this.setCenter(center, this.getZoomForExtent(bounds, closest));\n },\n \n /** \n- * Method: clear\n- * Remove the tile from the DOM, clear it of any image related data so that\n- * it can be reused in a new location.\n+ * APIMethod: zoomToMaxExtent\n+ * Zoom to the full extent and recenter.\n+ *\n+ * Parameters:\n+ * options - {Object}\n+ * \n+ * Allowed Options:\n+ * restricted - {Boolean} True to zoom to restricted extent if it is \n+ * set. Defaults to true.\n */\n- clear: function() {\n- OpenLayers.Tile.prototype.clear.apply(this, arguments);\n- var img = this.imgDiv;\n- if (img) {\n- var tile = this.getTile();\n- if (tile.parentNode === this.layer.div) {\n- this.layer.div.removeChild(tile);\n- }\n- this.setImgSrc();\n- if (this.layerAlphaHack === true) {\n- img.style.filter = \"\";\n- }\n- OpenLayers.Element.removeClass(img, \"olImageLoadError\");\n- }\n- this.canvasContext = null;\n+ zoomToMaxExtent: function(options) {\n+ //restricted is true by default\n+ var restricted = (options) ? options.restricted : true;\n+\n+ var maxExtent = this.getMaxExtent({\n+ 'restricted': restricted\n+ });\n+ this.zoomToExtent(maxExtent);\n },\n \n- /**\n- * Method: getImage\n- * Returns or creates and returns the tile image.\n+ /** \n+ * APIMethod: zoomToScale\n+ * Zoom to a specified scale \n+ * \n+ * Parameters:\n+ * scale - {float}\n+ * closest - {Boolean} Find the zoom level that most closely fits the \n+ * specified scale. Note that this may result in a zoom that does \n+ * not exactly contain the entire extent.\n+ * Default is false.\n+ * \n */\n- getImage: function() {\n- if (!this.imgDiv) {\n- this.imgDiv = OpenLayers.Tile.Image.IMAGE.cloneNode(false);\n+ zoomToScale: function(scale, closest) {\n+ var res = OpenLayers.Util.getResolutionFromScale(scale,\n+ this.baseLayer.units);\n \n- var style = this.imgDiv.style;\n- if (this.frame) {\n- var left = 0,\n- top = 0;\n- if (this.layer.gutter) {\n- left = this.layer.gutter / this.layer.tileSize.w * 100;\n- top = this.layer.gutter / this.layer.tileSize.h * 100;\n- }\n- style.left = -left + \"%\";\n- style.top = -top + \"%\";\n- style.width = (2 * left + 100) + \"%\";\n- style.height = (2 * top + 100) + \"%\";\n- }\n- style.visibility = \"hidden\";\n- style.opacity = 0;\n- if (this.layer.opacity < 1) {\n- style.filter = 'alpha(opacity=' +\n- (this.layer.opacity * 100) +\n- ')';\n- }\n- style.position = \"absolute\";\n- if (this.layerAlphaHack) {\n- // move the image out of sight\n- style.paddingTop = style.height;\n- style.height = \"0\";\n- style.width = \"100%\";\n- }\n- if (this.frame) {\n- this.frame.appendChild(this.imgDiv);\n- }\n- }\n+ var halfWDeg = (this.size.w * res) / 2;\n+ var halfHDeg = (this.size.h * res) / 2;\n+ var center = this.getCachedCenter();\n \n- return this.imgDiv;\n+ var extent = new OpenLayers.Bounds(center.lon - halfWDeg,\n+ center.lat - halfHDeg,\n+ center.lon + halfWDeg,\n+ center.lat + halfHDeg);\n+ this.zoomToExtent(extent, closest);\n },\n \n+ /********************************************************/\n+ /* */\n+ /* Translation Functions */\n+ /* */\n+ /* The following functions translate between */\n+ /* LonLat, LayerPx, and ViewPortPx */\n+ /* */\n+ /********************************************************/\n+\n+ //\n+ // TRANSLATION: LonLat <-> ViewPortPx\n+ //\n+\n /**\n- * APIMethod: setImage\n- * Sets the image element for this tile. This method should only be called\n- * from beforeload listeners.\n- *\n- * Parameters\n- * img - {HTMLImageElement} The image to use for this tile.\n+ * Method: 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 view \n+ * port , translated into lon/lat\n+ * by the current base layer.\n */\n- setImage: function(img) {\n- this.imgDiv = img;\n+ getLonLatFromViewPortPx: function(viewPortPx) {\n+ var lonlat = null;\n+ if (this.baseLayer != null) {\n+ lonlat = this.baseLayer.getLonLatFromViewPortPx(viewPortPx);\n+ }\n+ return lonlat;\n },\n \n /**\n- * Method: initImage\n- * Creates the content for the frame on the tile.\n+ * APIMethod: getViewPortPxFromLonLat\n+ * \n+ * Parameters:\n+ * lonlat - {}\n+ * \n+ * Returns:\n+ * {} An OpenLayers.Pixel which is the passed-in \n+ * , translated into view port \n+ * pixels by the current base layer.\n */\n- initImage: function() {\n- if (!this.url && !this.imgDiv) {\n- // fast path out - if there is no tile url and no previous image\n- this.isLoading = false;\n- return;\n- }\n- this.events.triggerEvent('beforeload');\n- this.layer.div.appendChild(this.getTile());\n- this.events.triggerEvent(this._loadEvent);\n- var img = this.getImage();\n- var src = img.getAttribute('src') || '';\n- if (this.url && OpenLayers.Util.isEquivalentUrl(src, this.url)) {\n- this._loadTimeout = window.setTimeout(\n- OpenLayers.Function.bind(this.onImageLoad, this), 0\n- );\n- } else {\n- this.stopLoading();\n- if (this.crossOriginKeyword) {\n- img.removeAttribute(\"crossorigin\");\n- }\n- OpenLayers.Event.observe(img, \"load\",\n- OpenLayers.Function.bind(this.onImageLoad, this)\n- );\n- OpenLayers.Event.observe(img, \"error\",\n- OpenLayers.Function.bind(this.onImageError, this)\n- );\n- this.imageReloadAttempts = 0;\n- this.setImgSrc(this.url);\n+ getViewPortPxFromLonLat: function(lonlat) {\n+ var px = null;\n+ if (this.baseLayer != null) {\n+ px = this.baseLayer.getViewPortPxFromLonLat(lonlat);\n }\n+ return px;\n },\n \n /**\n- * Method: setImgSrc\n- * Sets the source for the tile image\n+ * Method: getZoomTargetCenter\n *\n * Parameters:\n- * url - {String} or undefined to hide the image\n+ * xy - {} The zoom origin pixel location on the screen\n+ * resolution - {Float} The resolution we want to get the center for\n+ *\n+ * Returns:\n+ * {} The location of the map center after the\n+ * transformation described by the origin xy and the target resolution.\n */\n- setImgSrc: function(url) {\n- var img = this.imgDiv;\n- if (url) {\n- img.style.visibility = 'hidden';\n- img.style.opacity = 0;\n- // don't set crossOrigin if the url is a data URL\n- if (this.crossOriginKeyword) {\n- if (url.substr(0, 5) !== 'data:') {\n- img.setAttribute(\"crossorigin\", this.crossOriginKeyword);\n- } else {\n- img.removeAttribute(\"crossorigin\");\n- }\n- }\n- img.src = url;\n- } else {\n- // Remove reference to the image, and leave it to the browser's\n- // caching and garbage collection.\n- this.stopLoading();\n- this.imgDiv = null;\n- if (img.parentNode) {\n- img.parentNode.removeChild(img);\n- }\n+ getZoomTargetCenter: function(xy, resolution) {\n+ var lonlat = null,\n+ size = this.getSize(),\n+ deltaX = size.w / 2 - xy.x,\n+ deltaY = xy.y - size.h / 2,\n+ zoomPoint = this.getLonLatFromPixel(xy);\n+ if (zoomPoint) {\n+ lonlat = new OpenLayers.LonLat(\n+ zoomPoint.lon + deltaX * resolution,\n+ zoomPoint.lat + deltaY * resolution\n+ );\n }\n+ return lonlat;\n },\n \n+ //\n+ // CONVENIENCE TRANSLATION FUNCTIONS FOR API\n+ //\n+\n /**\n- * Method: getTile\n- * Get the tile's markup.\n+ * APIMethod: getLonLatFromPixel\n+ * \n+ * Parameters:\n+ * px - {|Object} An OpenLayers.Pixel or an object with\n+ * a 'x' and 'y' properties.\n *\n * Returns:\n- * {DOMElement} The tile's markup\n+ * {} An OpenLayers.LonLat corresponding to the given\n+ * OpenLayers.Pixel, translated into lon/lat by the \n+ * current base layer\n */\n- getTile: function() {\n- return this.frame ? this.frame : this.getImage();\n+ getLonLatFromPixel: function(px) {\n+ return this.getLonLatFromViewPortPx(px);\n },\n \n /**\n- * Method: createBackBuffer\n- * Create a backbuffer for this tile. A backbuffer isn't exactly a clone\n- * of the tile's markup, because we want to avoid the reloading of the\n- * image. So we clone the frame, and steal the image from the tile.\n- *\n+ * APIMethod: getPixelFromLonLat\n+ * Returns a pixel location given a map location. The map location is\n+ * translated to an integer pixel location (in viewport pixel\n+ * coordinates) by the current base layer.\n+ * \n+ * Parameters:\n+ * lonlat - {} A map location.\n+ * \n+ * Returns: \n+ * {} An OpenLayers.Pixel corresponding to the \n+ * translated into view port pixels by the current\n+ * base layer.\n+ */\n+ getPixelFromLonLat: function(lonlat) {\n+ var px = this.getViewPortPxFromLonLat(lonlat);\n+ px.x = Math.round(px.x);\n+ px.y = Math.round(px.y);\n+ return px;\n+ },\n+\n+ /**\n+ * Method: getGeodesicPixelSize\n+ * \n+ * Parameters:\n+ * px - {} The pixel to get the geodesic length for. If\n+ * not provided, the center pixel of the map viewport will be used.\n+ * \n * Returns:\n- * {DOMElement} The markup, or undefined if the tile has no image\n- * or if it's currently loading.\n+ * {} The geodesic size of the pixel in kilometers.\n */\n- createBackBuffer: function() {\n- if (!this.imgDiv || this.isLoading) {\n- return;\n- }\n- var backBuffer;\n- if (this.frame) {\n- backBuffer = this.frame.cloneNode(false);\n- backBuffer.appendChild(this.imgDiv);\n- } else {\n- backBuffer = this.imgDiv;\n+ getGeodesicPixelSize: function(px) {\n+ var lonlat = px ? this.getLonLatFromPixel(px) : (\n+ this.getCachedCenter() || new OpenLayers.LonLat(0, 0));\n+ var res = this.getResolution();\n+ var left = lonlat.add(-res / 2, 0);\n+ var right = lonlat.add(res / 2, 0);\n+ var bottom = lonlat.add(0, -res / 2);\n+ var top = lonlat.add(0, res / 2);\n+ var dest = new OpenLayers.Projection(\"EPSG:4326\");\n+ var source = this.getProjectionObject() || dest;\n+ if (!source.equals(dest)) {\n+ left.transform(source, dest);\n+ right.transform(source, dest);\n+ bottom.transform(source, dest);\n+ top.transform(source, dest);\n }\n- this.imgDiv = null;\n- return backBuffer;\n+\n+ return new OpenLayers.Size(\n+ OpenLayers.Util.distVincenty(left, right),\n+ OpenLayers.Util.distVincenty(bottom, top)\n+ );\n },\n \n+\n+\n+ //\n+ // TRANSLATION: ViewPortPx <-> LayerPx\n+ //\n+\n /**\n- * Method: onImageLoad\n- * Handler for the image onload event\n+ * APIMethod: getViewPortPxFromLayerPx\n+ * \n+ * Parameters:\n+ * layerPx - {}\n+ * \n+ * Returns:\n+ * {} Layer Pixel translated into ViewPort Pixel \n+ * coordinates\n */\n- onImageLoad: function() {\n- var img = this.imgDiv;\n- this.stopLoading();\n- img.style.visibility = 'inherit';\n- img.style.opacity = this.layer.opacity;\n- this.isLoading = false;\n- this.canvasContext = null;\n- this.events.triggerEvent(\"loadend\");\n-\n- if (this.layerAlphaHack === true) {\n- img.style.filter =\n- \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='\" +\n- img.src + \"', sizingMethod='scale')\";\n+ getViewPortPxFromLayerPx: function(layerPx) {\n+ var viewPortPx = null;\n+ if (layerPx != null) {\n+ var dX = this.layerContainerOriginPx.x;\n+ var dY = this.layerContainerOriginPx.y;\n+ viewPortPx = layerPx.add(dX, dY);\n }\n+ return viewPortPx;\n },\n \n /**\n- * Method: onImageError\n- * Handler for the image onerror event\n+ * APIMethod: getLayerPxFromViewPortPx\n+ * \n+ * Parameters:\n+ * viewPortPx - {}\n+ * \n+ * Returns:\n+ * {} ViewPort Pixel translated into Layer Pixel \n+ * coordinates\n */\n- onImageError: function() {\n- var img = this.imgDiv;\n- if (img.src != null) {\n- this.imageReloadAttempts++;\n- if (this.imageReloadAttempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {\n- this.setImgSrc(this.layer.getURL(this.bounds));\n- } else {\n- OpenLayers.Element.addClass(img, \"olImageLoadError\");\n- this.events.triggerEvent(\"loaderror\");\n- this.onImageLoad();\n+ getLayerPxFromViewPortPx: function(viewPortPx) {\n+ var layerPx = null;\n+ if (viewPortPx != null) {\n+ var dX = -this.layerContainerOriginPx.x;\n+ var dY = -this.layerContainerOriginPx.y;\n+ layerPx = viewPortPx.add(dX, dY);\n+ if (isNaN(layerPx.x) || isNaN(layerPx.y)) {\n+ layerPx = null;\n }\n }\n+ return layerPx;\n },\n \n+ //\n+ // TRANSLATION: LonLat <-> LayerPx\n+ //\n+\n /**\n- * Method: stopLoading\n- * Stops a loading sequence so won't be executed.\n+ * Method: getLonLatFromLayerPx\n+ * \n+ * Parameters:\n+ * px - {}\n+ *\n+ * Returns:\n+ * {}\n */\n- stopLoading: function() {\n- OpenLayers.Event.stopObservingElement(this.imgDiv);\n- window.clearTimeout(this._loadTimeout);\n- delete this._loadTimeout;\n+ getLonLatFromLayerPx: function(px) {\n+ //adjust for displacement of layerContainerDiv\n+ px = this.getViewPortPxFromLayerPx(px);\n+ return this.getLonLatFromViewPortPx(px);\n },\n \n /**\n- * APIMethod: getCanvasContext\n- * Returns a canvas context associated with the tile image (with\n- * the image drawn on it).\n- * Returns undefined if the browser does not support canvas, if\n- * the tile has no image or if it's currently loading.\n- *\n- * The function returns a canvas context instance but the\n- * underlying canvas is still available in the 'canvas' property:\n- * (code)\n- * var context = tile.getCanvasContext();\n- * if (context) {\n- * var data = context.canvas.toDataURL('image/jpeg');\n- * }\n- * (end)\n+ * APIMethod: getLayerPxFromLonLat\n+ * \n+ * Parameters:\n+ * lonlat - {} lonlat\n *\n * Returns:\n- * {Boolean}\n+ * {} An OpenLayers.Pixel which is the passed-in \n+ * , translated into layer pixels \n+ * by the current base layer\n */\n- getCanvasContext: function() {\n- if (OpenLayers.CANVAS_SUPPORTED && this.imgDiv && !this.isLoading) {\n- if (!this.canvasContext) {\n- var canvas = document.createElement(\"canvas\");\n- canvas.width = this.size.w;\n- canvas.height = this.size.h;\n- this.canvasContext = canvas.getContext(\"2d\");\n- this.canvasContext.drawImage(this.imgDiv, 0, 0);\n+ getLayerPxFromLonLat: function(lonlat) {\n+ //adjust for displacement of layerContainerDiv\n+ var px = this.getPixelFromLonLat(lonlat);\n+ return this.getLayerPxFromViewPortPx(px);\n+ },\n+\n+ /**\n+ * Method: applyTransform\n+ * Applies the given transform to the . This method has\n+ * a 2-stage fallback from translate3d/scale3d via translate/scale to plain\n+ * style.left/style.top, in which case no scaling is supported.\n+ *\n+ * Parameters:\n+ * x - {Number} x parameter for the translation. Defaults to the x value of\n+ * the map's \n+ * y - {Number} y parameter for the translation. Defaults to the y value of\n+ * the map's \n+ * scale - {Number} scale. Defaults to 1 if not provided.\n+ */\n+ applyTransform: function(x, y, scale) {\n+ scale = scale || 1;\n+ var origin = this.layerContainerOriginPx,\n+ needTransform = scale !== 1;\n+ x = x || origin.x;\n+ y = y || origin.y;\n+\n+ var style = this.layerContainerDiv.style,\n+ transform = this.applyTransform.transform,\n+ template = this.applyTransform.template;\n+\n+ if (transform === undefined) {\n+ transform = OpenLayers.Util.vendorPrefix.style('transform');\n+ this.applyTransform.transform = transform;\n+ if (transform) {\n+ // Try translate3d, but only if the viewPortDiv has a transform\n+ // defined in a stylesheet\n+ var computedStyle = OpenLayers.Element.getStyle(this.viewPortDiv,\n+ OpenLayers.Util.vendorPrefix.css('transform'));\n+ if (!computedStyle || computedStyle !== 'none') {\n+ template = ['translate3d(', ',0) ', 'scale3d(', ',1)'];\n+ style[transform] = [template[0], '0,0', template[1]].join('');\n+ }\n+ // If no transform is defined in the stylesheet or translate3d\n+ // does not stick, use translate and scale\n+ if (!template || !~style[transform].indexOf(template[0])) {\n+ template = ['translate(', ') ', 'scale(', ')'];\n+ }\n+ this.applyTransform.template = template;\n }\n- return this.canvasContext;\n }\n- },\n \n- CLASS_NAME: \"OpenLayers.Tile.Image\"\n+ // If we do 3d transforms, we always want to use them. If we do 2d\n+ // transforms, we only use them when we need to.\n+ if (transform !== null && (template[0] === 'translate3d(' || needTransform === true)) {\n+ // Our 2d transforms are combined with style.left and style.top, so\n+ // adjust x and y values and set the origin as left and top\n+ if (needTransform === true && template[0] === 'translate(') {\n+ x -= origin.x;\n+ y -= origin.y;\n+ style.left = origin.x + 'px';\n+ style.top = origin.y + 'px';\n+ }\n+ style[transform] = [\n+ template[0], x, 'px,', y, 'px', template[1],\n+ template[2], scale, ',', scale, template[3]\n+ ].join('');\n+ } else {\n+ style.left = x + 'px';\n+ style.top = y + 'px';\n+ // We previously might have had needTransform, so remove transform\n+ if (transform !== null) {\n+ style[transform] = '';\n+ }\n+ }\n+ },\n \n+ CLASS_NAME: \"OpenLayers.Map\"\n });\n \n-/** \n- * Constant: OpenLayers.Tile.Image.IMAGE\n- * {HTMLImageElement} The image for a tile.\n+/**\n+ * Constant: TILE_WIDTH\n+ * {Integer} 256 Default tile width (unless otherwise specified)\n */\n-OpenLayers.Tile.Image.IMAGE = (function() {\n- var img = new Image();\n- img.className = \"olTileImage\";\n- // avoid image gallery menu in IE6\n- img.galleryImg = \"no\";\n- return img;\n-}());\n-\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/Layer/Grid.js\n+ OpenLayers/Layer.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/HTTPRequest.js\n- * @requires OpenLayers/Tile/Image.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Map.js\n+ * @requires OpenLayers/Projection.js\n */\n \n /**\n- * Class: OpenLayers.Layer.Grid\n- * Base class for layers that use a lattice of tiles. Create a new grid\n- * layer with the constructor.\n- *\n- * Inherits from:\n- * - \n+ * Class: OpenLayers.Layer\n */\n-OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {\n-\n- /**\n- * APIProperty: tileSize\n- * {}\n- */\n- tileSize: null,\n-\n- /**\n- * Property: tileOriginCorner\n- * {String} If the property is not provided, the tile origin \n- * will be derived from the layer's . The corner of the \n- * used is determined by this property. Acceptable values\n- * are \"tl\" (top left), \"tr\" (top right), \"bl\" (bottom left), and \"br\"\n- * (bottom right). Default is \"bl\".\n- */\n- tileOriginCorner: \"bl\",\n-\n- /**\n- * APIProperty: tileOrigin\n- * {} Optional origin for aligning the grid of tiles.\n- * If provided, requests for tiles at all resolutions will be aligned\n- * with this location (no tiles shall overlap this location). If\n- * not provided, the grid of tiles will be aligned with the layer's\n- * . Default is ``null``.\n- */\n- tileOrigin: null,\n-\n- /** APIProperty: tileOptions\n- * {Object} optional configuration options for instances\n- * created by this Layer, if supported by the tile class.\n- */\n- tileOptions: null,\n-\n- /**\n- * APIProperty: tileClass\n- * {} The tile class to use for this layer.\n- * Defaults is OpenLayers.Tile.Image.\n- */\n- tileClass: OpenLayers.Tile.Image,\n-\n- /**\n- * Property: grid\n- * {Array(Array())} This is an array of rows, each row is \n- * an array of tiles.\n- */\n- grid: null,\n-\n- /**\n- * APIProperty: singleTile\n- * {Boolean} Moves the layer into single-tile mode, meaning that one tile \n- * will be loaded. The tile's size will be determined by the 'ratio'\n- * property. When the tile is dragged such that it does not cover the \n- * entire viewport, it is reloaded.\n- */\n- singleTile: false,\n-\n- /** APIProperty: ratio\n- * {Float} Used only when in single-tile mode, this specifies the \n- * ratio of the size of the single tile to the size of the map.\n- * Default value is 1.5.\n- */\n- ratio: 1.5,\n-\n- /**\n- * APIProperty: buffer\n- * {Integer} Used only when in gridded mode, this specifies the number of \n- * extra rows and colums of tiles on each side which will\n- * surround the minimum grid tiles to cover the map.\n- * For very slow loading layers, a larger value may increase\n- * performance somewhat when dragging, but will increase bandwidth\n- * use significantly. \n- */\n- buffer: 0,\n-\n- /**\n- * APIProperty: transitionEffect\n- * {String} The transition effect to use when the map is zoomed.\n- * Two posible values:\n- *\n- * \"resize\" - Existing tiles are resized on zoom to provide a visual\n- * effect of the zoom having taken place immediately. As the\n- * new tiles become available, they are drawn on top of the\n- * resized tiles (this is the default setting).\n- * \"map-resize\" - Existing tiles are resized on zoom and placed below the\n- * base layer. New tiles for the base layer will cover existing tiles.\n- * This setting is recommended when having an overlay duplicated during\n- * the transition is undesirable (e.g. street labels or big transparent\n- * fills). \n- * null - No transition effect.\n- *\n- * Using \"resize\" on non-opaque layers can cause undesired visual\n- * effects. Set transitionEffect to null in this case.\n- */\n- transitionEffect: \"resize\",\n-\n- /**\n- * APIProperty: numLoadingTiles\n- * {Integer} How many tiles are still loading?\n- */\n- numLoadingTiles: 0,\n-\n- /**\n- * Property: serverResolutions\n- * {Array(Number}} This property is documented in subclasses as\n- * an API property.\n- */\n- serverResolutions: null,\n-\n- /**\n- * Property: loading\n- * {Boolean} Indicates if tiles are being loaded.\n- */\n- loading: false,\n+OpenLayers.Layer = OpenLayers.Class({\n \n /**\n- * Property: backBuffer\n- * {DOMElement} The back buffer.\n+ * APIProperty: id\n+ * {String}\n */\n- backBuffer: null,\n+ id: null,\n \n- /**\n- * Property: gridResolution\n- * {Number} The resolution of the current grid. Used for backbuffer and\n- * client zoom. This property is updated every time the grid is\n- * initialized.\n+ /** \n+ * APIProperty: name\n+ * {String}\n */\n- gridResolution: null,\n+ name: null,\n \n- /**\n- * Property: backBufferResolution\n- * {Number} The resolution of the current back buffer. This property is\n- * updated each time a back buffer is created.\n+ /** \n+ * APIProperty: div\n+ * {DOMElement}\n */\n- backBufferResolution: null,\n+ div: null,\n \n /**\n- * Property: backBufferLonLat\n- * {Object} The top-left corner of the current back buffer. Includes lon\n- * and lat properties. This object is updated each time a back buffer\n- * is created.\n+ * APIProperty: opacity\n+ * {Float} The layer's opacity. Float number between 0.0 and 1.0. Default\n+ * is 1.\n */\n- backBufferLonLat: null,\n+ opacity: 1,\n \n /**\n- * Property: backBufferTimerId\n- * {Number} The id of the back buffer timer. This timer is used to\n- * delay the removal of the back buffer, thereby preventing\n- * flash effects caused by tile animation.\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- backBufferTimerId: null,\n+ alwaysInRange: null,\n \n /**\n- * APIProperty: removeBackBufferDelay\n- * {Number} Delay for removing the backbuffer when all tiles have finished\n- * loading. Can be set to 0 when no css opacity transitions for the\n- * olTileImage class are used. Default is 0 for layers,\n- * 2500 for tiled layers. See for more information on\n- * tile animation.\n+ * Constant: RESOLUTION_PROPERTIES\n+ * {Array} The properties that are used for calculating resolutions\n+ * information.\n */\n- removeBackBufferDelay: null,\n+ RESOLUTION_PROPERTIES: [\n+ 'scales', 'resolutions',\n+ 'maxScale', 'minScale',\n+ 'maxResolution', 'minResolution',\n+ 'numZoomLevels', 'maxZoomLevel'\n+ ],\n \n /**\n- * APIProperty: className\n- * {String} Name of the class added to the layer div. If not set in the\n- * options passed to the constructor then className defaults to\n- * \"olLayerGridSingleTile\" for single tile layers (see ),\n- * and \"olLayerGrid\" for non single tile layers.\n- *\n- * Note:\n+ * APIProperty: events\n+ * {}\n *\n- * The displaying of tiles is not animated by default for single tile\n- * layers - OpenLayers' default theme (style.css) includes this:\n- * (code)\n- * .olLayerGrid .olTileImage {\n- * -webkit-transition: opacity 0.2s linear;\n- * -moz-transition: opacity 0.2s linear;\n- * -o-transition: opacity 0.2s linear;\n- * transition: opacity 0.2s linear;\n- * }\n- * (end)\n- * To animate tile displaying for any grid layer the following\n- * CSS rule can be used:\n- * (code)\n- * .olTileImage {\n- * -webkit-transition: opacity 0.2s linear;\n- * -moz-transition: opacity 0.2s linear;\n- * -o-transition: opacity 0.2s linear;\n- * transition: opacity 0.2s linear;\n- * }\n- * (end)\n- * In that case, to avoid flash effects, \n- * should not be zero.\n- */\n- className: null,\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 event types:\n- * addtile - Triggered when a tile is added to this layer. Listeners receive\n- * an object as first argument, which has a tile property that\n- * references the tile that has been added.\n- * tileloadstart - Triggered when a tile starts loading. Listeners receive\n- * an object as first argument, which has a tile property that\n- * references the tile that starts loading.\n- * tileloaded - Triggered when each new tile is\n- * loaded, as a means of progress update to listeners.\n- * listeners can access 'numLoadingTiles' if they wish to keep\n- * track of the loading progress. Listeners are called with an object\n- * with a 'tile' property as first argument, making the loaded tile\n- * available to the listener, and an 'aborted' property, which will be\n- * true when loading was aborted and no tile data is available.\n- * tileerror - Triggered before the tileloaded event (i.e. when the tile is\n- * still hidden) if a tile failed to load. Listeners receive an object\n- * as first argument, which has a tile property that references the\n- * tile that could not be loaded.\n- * retile - Triggered when the layer recreates its tile grid.\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- * Property: gridLayout\n- * {Object} Object containing properties tilelon, tilelat, startcol,\n- * startrow\n+ * APIProperty: map\n+ * {} This variable is set when the layer is added to \n+ * the map, via the accessor function setMap().\n */\n- gridLayout: null,\n+ map: null,\n \n /**\n- * Property: rowSign\n- * {Number} 1 for grids starting at the top, -1 for grids starting at the\n- * bottom. This is used for several grid index and offset calculations.\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- rowSign: null,\n+ isBaseLayer: false,\n \n /**\n- * Property: transitionendEvents\n- * {Array} Event names for transitionend\n+ * Property: alpha\n+ * {Boolean} The layer's images have an alpha channel. Default is false.\n */\n- transitionendEvents: [\n- 'transitionend', 'webkitTransitionEnd', 'otransitionend',\n- 'oTransitionEnd'\n- ],\n+ alpha: false,\n \n- /**\n- * Constructor: OpenLayers.Layer.Grid\n- * Create a new grid layer\n- *\n- * Parameters:\n- * name - {String}\n- * url - {String}\n- * params - {Object}\n- * options - {Object} Hashtable of extra options to tag onto the layer\n+ /** \n+ * APIProperty: displayInLayerSwitcher\n+ * {Boolean} Display the layer's name in the layer switcher. Default is\n+ * true.\n */\n- initialize: function(name, url, params, options) {\n- OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,\n- arguments);\n- this.grid = [];\n- this._removeBackBuffer = OpenLayers.Function.bind(this.removeBackBuffer, this);\n-\n- this.initProperties();\n-\n- this.rowSign = this.tileOriginCorner.substr(0, 1) === \"t\" ? 1 : -1;\n- },\n+ displayInLayerSwitcher: true,\n \n /**\n- * Method: initProperties\n- * Set any properties that depend on the value of singleTile.\n- * Currently sets removeBackBufferDelay and className\n+ * APIProperty: visibility\n+ * {Boolean} The layer should be displayed in the map. Default is true.\n */\n- initProperties: function() {\n- if (this.options.removeBackBufferDelay === undefined) {\n- this.removeBackBufferDelay = this.singleTile ? 0 : 2500;\n- }\n-\n- if (this.options.className === undefined) {\n- this.className = this.singleTile ? 'olLayerGridSingleTile' :\n- 'olLayerGrid';\n- }\n- },\n+ visibility: true,\n \n /**\n- * Method: setMap\n- *\n- * Parameters:\n- * map - {} The map.\n+ * APIProperty: attribution\n+ * {String} Attribution string, displayed when an \n+ * has been added to the map.\n */\n- setMap: function(map) {\n- OpenLayers.Layer.HTTPRequest.prototype.setMap.call(this, map);\n- OpenLayers.Element.addClass(this.div, this.className);\n- },\n+ attribution: null,\n \n- /**\n- * Method: removeMap\n- * Called when the layer is removed from the map.\n- *\n- * Parameters:\n- * map - {} The map.\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- removeMap: function(map) {\n- this.removeBackBuffer();\n- },\n+ inRange: false,\n \n /**\n- * APIMethod: destroy\n- * Deconstruct the layer and clear the grid.\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- destroy: function() {\n- this.removeBackBuffer();\n- this.clearGrid();\n+ imageSize: null,\n \n- this.grid = null;\n- this.tileSize = null;\n- OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);\n- },\n+ // OPTIONS\n \n- /**\n- * APIMethod: mergeNewParams\n- * Refetches tiles with new params merged, keeping a backbuffer. Each\n- * loading new tile will have a css class of '.olTileReplacing'. If a\n- * stylesheet applies a 'display: none' style to that class, any fade-in\n- * transition will not apply, and backbuffers for each tile will be removed\n- * as soon as the tile is loaded.\n- * \n- * Parameters:\n- * newParams - {Object}\n- *\n- * Returns:\n- * redrawn: {Boolean} whether the layer was actually redrawn.\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 /**\n- * Method: clearGrid\n- * Go through and remove all tiles from the grid, calling\n- * destroy() on each of them to kill circular references\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- clearGrid: function() {\n- if (this.grid) {\n- for (var iRow = 0, len = this.grid.length; iRow < len; iRow++) {\n- var row = this.grid[iRow];\n- for (var iCol = 0, clen = row.length; iCol < clen; iCol++) {\n- var tile = row[iCol];\n- this.destroyTile(tile);\n- }\n- }\n- this.grid = [];\n- this.gridResolution = null;\n- this.gridLayout = null;\n- }\n- },\n+ eventListeners: null,\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+ * 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- addOptions: function(newOptions, reinitialize) {\n- var singleTileChanged = newOptions.singleTile !== undefined &&\n- newOptions.singleTile !== this.singleTile;\n- OpenLayers.Layer.HTTPRequest.prototype.addOptions.apply(this, arguments);\n- if (this.map && singleTileChanged) {\n- this.initProperties();\n- this.clearGrid();\n- this.tileSize = this.options.tileSize;\n- this.setTileSize();\n- this.moveTo(null, true);\n- }\n- },\n+ gutter: 0,\n \n /**\n- * APIMethod: clone\n- * Create a clone of this layer\n- *\n- * Parameters:\n- * obj - {Object} Is this ever used?\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- * Returns:\n- * {} An exact clone of this OpenLayers.Layer.Grid\n */\n- clone: function(obj) {\n-\n- if (obj == null) {\n- obj = new OpenLayers.Layer.Grid(this.name,\n- this.url,\n- this.params,\n- this.getOptions());\n- }\n-\n- //get all additions from superclasses\n- obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);\n-\n- // copy/set any non-init, non-simple values here\n- if (this.tileSize != null) {\n- obj.tileSize = this.tileSize.clone();\n- }\n-\n- // we do not want to copy reference to grid, so we make a new array\n- obj.grid = [];\n- obj.gridResolution = null;\n- // same for backbuffer\n- obj.backBuffer = null;\n- obj.backBufferTimerId = null;\n- obj.loading = false;\n- obj.numLoadingTiles = 0;\n-\n- return obj;\n- },\n+ projection: null,\n \n /**\n- * Method: moveTo\n- * This function is called whenever the map is moved. All the moving\n- * of actual 'tiles' is done by the map, but moveTo's role is to accept\n- * a bounds and make sure the data that that bounds requires is pre-loaded.\n- *\n- * Parameters:\n- * bounds - {}\n- * zoomChanged - {Boolean}\n- * dragging - {Boolean}\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- moveTo: function(bounds, zoomChanged, dragging) {\n-\n- OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);\n-\n- bounds = bounds || this.map.getExtent();\n-\n- if (bounds != null) {\n-\n- // if grid is empty or zoom has changed, we *must* re-tile\n- var forceReTile = !this.grid.length || zoomChanged;\n-\n- // total bounds of the tiles\n- var tilesBounds = this.getTilesBounds();\n-\n- // the new map resolution\n- var resolution = this.map.getResolution();\n-\n- // the server-supported resolution for the new map resolution\n- var serverResolution = this.getServerResolution(resolution);\n-\n- if (this.singleTile) {\n-\n- // We want to redraw whenever even the slightest part of the \n- // current bounds is not contained by our tile.\n- // (thus, we do not specify partial -- its default is false)\n-\n- if (forceReTile ||\n- (!dragging && !tilesBounds.containsBounds(bounds))) {\n-\n- // In single tile mode with no transition effect, we insert\n- // a non-scaled backbuffer when the layer is moved. But if\n- // a zoom occurs right after a move, i.e. before the new\n- // image is received, we need to remove the backbuffer, or\n- // an ill-positioned image will be visible during the zoom\n- // transition.\n-\n- if (zoomChanged && this.transitionEffect !== 'resize') {\n- this.removeBackBuffer();\n- }\n-\n- if (!zoomChanged || this.transitionEffect === 'resize') {\n- this.applyBackBuffer(resolution);\n- }\n-\n- this.initSingleTile(bounds);\n- }\n- } else {\n-\n- // if the bounds have changed such that they are not even \n- // *partially* contained by our tiles (e.g. when user has \n- // programmatically panned to the other side of the earth on\n- // zoom level 18), then moveGriddedTiles could potentially have\n- // to run through thousands of cycles, so we want to reTile\n- // instead (thus, partial true). \n- forceReTile = forceReTile ||\n- !tilesBounds.intersectsBounds(bounds, {\n- worldBounds: this.map.baseLayer.wrapDateLine &&\n- this.map.getMaxExtent()\n- });\n-\n- if (forceReTile) {\n- if (zoomChanged && (this.transitionEffect === 'resize' ||\n- this.gridResolution === resolution)) {\n- this.applyBackBuffer(resolution);\n- }\n- this.initGriddedTiles(bounds);\n- } else {\n- this.moveGriddedTiles();\n- }\n- }\n- }\n- },\n+ units: null,\n \n /**\n- * Method: getTileData\n- * Given a map location, retrieve a tile and the pixel offset within that\n- * tile corresponding to the location. If there is not an existing \n- * tile in the grid that covers the given location, null will be \n- * returned.\n- *\n- * Parameters:\n- * loc - {} map location\n- *\n- * Returns:\n- * {Object} Object with the following properties: tile ({}),\n- * i ({Number} x-pixel offset from top left), and j ({Integer} y-pixel\n- * offset from top left).\n- */\n- getTileData: function(loc) {\n- var data = null,\n- x = loc.lon,\n- y = loc.lat,\n- numRows = this.grid.length;\n-\n- if (this.map && numRows) {\n- var res = this.map.getResolution(),\n- tileWidth = this.tileSize.w,\n- tileHeight = this.tileSize.h,\n- bounds = this.grid[0][0].bounds,\n- left = bounds.left,\n- top = bounds.top;\n-\n- if (x < left) {\n- // deal with multiple worlds\n- if (this.map.baseLayer.wrapDateLine) {\n- var worldWidth = this.map.getMaxExtent().getWidth();\n- var worldsAway = Math.ceil((left - x) / worldWidth);\n- x += worldWidth * worldsAway;\n- }\n- }\n- // tile distance to location (fractional number of tiles);\n- var dtx = (x - left) / (res * tileWidth);\n- var dty = (top - y) / (res * tileHeight);\n- // index of tile in grid\n- var col = Math.floor(dtx);\n- var row = Math.floor(dty);\n- if (row >= 0 && row < numRows) {\n- var tile = this.grid[row][col];\n- if (tile) {\n- data = {\n- tile: tile,\n- // pixel index within tile\n- i: Math.floor((dtx - col) * tileWidth),\n- j: Math.floor((dty - row) * tileHeight)\n- };\n- }\n- }\n- }\n- return data;\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- * Method: destroyTile\n- *\n- * Parameters:\n- * tile - {}\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- destroyTile: function(tile) {\n- this.removeTileMonitoringHooks(tile);\n- tile.destroy();\n- },\n+ resolutions: null,\n \n /**\n- * Method: getServerResolution\n- * Return the closest server-supported resolution.\n- *\n- * Parameters:\n- * resolution - {Number} The base resolution. If undefined the\n- * map resolution is used.\n- *\n- * Returns:\n- * {Number} The closest server resolution value.\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- getServerResolution: function(resolution) {\n- var distance = Number.POSITIVE_INFINITY;\n- resolution = resolution || this.map.getResolution();\n- if (this.serverResolutions &&\n- OpenLayers.Util.indexOf(this.serverResolutions, resolution) === -1) {\n- var i, newDistance, newResolution, serverResolution;\n- for (i = this.serverResolutions.length - 1; i >= 0; i--) {\n- newResolution = this.serverResolutions[i];\n- newDistance = Math.abs(newResolution - resolution);\n- if (newDistance > distance) {\n- break;\n- }\n- distance = newDistance;\n- serverResolution = newResolution;\n- }\n- resolution = serverResolution;\n- }\n- return resolution;\n- },\n+ maxExtent: null,\n \n /**\n- * Method: getServerZoom\n- * Return the zoom value corresponding to the best matching server\n- * resolution, taking into account and .\n- *\n- * Returns:\n- * {Number} The closest server supported zoom. This is not the map zoom\n- * level, but an index of the server's resolutions array.\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- getServerZoom: function() {\n- var resolution = this.getServerResolution();\n- return this.serverResolutions ?\n- OpenLayers.Util.indexOf(this.serverResolutions, resolution) :\n- this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);\n- },\n+ minExtent: null,\n \n /**\n- * Method: applyBackBuffer\n- * Create, insert, scale and position a back buffer for the layer.\n- *\n- * Parameters:\n- * resolution - {Number} The resolution to transition to.\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- applyBackBuffer: function(resolution) {\n- if (this.backBufferTimerId !== null) {\n- this.removeBackBuffer();\n- }\n- var backBuffer = this.backBuffer;\n- if (!backBuffer) {\n- backBuffer = this.createBackBuffer();\n- if (!backBuffer) {\n- return;\n- }\n- if (resolution === this.gridResolution) {\n- this.div.insertBefore(backBuffer, this.div.firstChild);\n- } else {\n- this.map.baseLayer.div.parentNode.insertBefore(backBuffer, this.map.baseLayer.div);\n- }\n- this.backBuffer = backBuffer;\n-\n- // set some information in the instance for subsequent\n- // calls to applyBackBuffer where the same back buffer\n- // is reused\n- var topLeftTileBounds = this.grid[0][0].bounds;\n- this.backBufferLonLat = {\n- lon: topLeftTileBounds.left,\n- lat: topLeftTileBounds.top\n- };\n- this.backBufferResolution = this.gridResolution;\n- }\n+ maxResolution: null,\n \n- var ratio = this.backBufferResolution / resolution;\n+ /**\n+ * APIProperty: minResolution\n+ * {Float}\n+ */\n+ minResolution: null,\n \n- // scale the tiles inside the back buffer\n- var tiles = backBuffer.childNodes,\n- tile;\n- for (var i = tiles.length - 1; i >= 0; --i) {\n- tile = tiles[i];\n- tile.style.top = ((ratio * tile._i * tile._h) | 0) + 'px';\n- tile.style.left = ((ratio * tile._j * tile._w) | 0) + 'px';\n- tile.style.width = Math.round(ratio * tile._w) + 'px';\n- tile.style.height = Math.round(ratio * tile._h) + 'px';\n- }\n+ /**\n+ * APIProperty: numZoomLevels\n+ * {Integer}\n+ */\n+ numZoomLevels: null,\n \n- // and position it (based on the grid's top-left corner)\n- var position = this.getViewPortPxFromLonLat(\n- this.backBufferLonLat, resolution);\n- var leftOffset = this.map.layerContainerOriginPx.x;\n- var topOffset = this.map.layerContainerOriginPx.y;\n- backBuffer.style.left = Math.round(position.x - leftOffset) + 'px';\n- backBuffer.style.top = Math.round(position.y - topOffset) + 'px';\n- },\n+ /**\n+ * APIProperty: minScale\n+ * {Float}\n+ */\n+ minScale: null,\n \n /**\n- * Method: createBackBuffer\n- * Create a back buffer.\n- *\n- * Returns:\n- * {DOMElement} The DOM element for the back buffer, undefined if the\n- * grid isn't initialized yet.\n+ * APIProperty: maxScale\n+ * {Float}\n */\n- createBackBuffer: function() {\n- var backBuffer;\n- if (this.grid.length > 0) {\n- backBuffer = document.createElement('div');\n- backBuffer.id = this.div.id + '_bb';\n- backBuffer.className = 'olBackBuffer';\n- backBuffer.style.position = 'absolute';\n- var map = this.map;\n- backBuffer.style.zIndex = this.transitionEffect === 'resize' ?\n- this.getZIndex() - 1 :\n- // 'map-resize':\n- map.Z_INDEX_BASE.BaseLayer -\n- (map.getNumLayers() - map.getLayerIndex(this));\n- for (var i = 0, lenI = this.grid.length; i < lenI; i++) {\n- for (var j = 0, lenJ = this.grid[i].length; j < lenJ; j++) {\n- var tile = this.grid[i][j],\n- markup = this.grid[i][j].createBackBuffer();\n- if (markup) {\n- markup._i = i;\n- markup._j = j;\n- markup._w = tile.size.w;\n- markup._h = tile.size.h;\n- markup.id = tile.id + '_bb';\n- backBuffer.appendChild(markup);\n- }\n- }\n- }\n- }\n- return backBuffer;\n- },\n+ maxScale: null,\n \n /**\n- * Method: removeBackBuffer\n- * Remove back buffer from DOM.\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- removeBackBuffer: function() {\n- if (this._transitionElement) {\n- for (var i = this.transitionendEvents.length - 1; i >= 0; --i) {\n- OpenLayers.Event.stopObserving(this._transitionElement,\n- this.transitionendEvents[i], this._removeBackBuffer);\n- }\n- delete this._transitionElement;\n- }\n- if (this.backBuffer) {\n- if (this.backBuffer.parentNode) {\n- this.backBuffer.parentNode.removeChild(this.backBuffer);\n- }\n- this.backBuffer = null;\n- this.backBufferResolution = null;\n- if (this.backBufferTimerId !== null) {\n- window.clearTimeout(this.backBufferTimerId);\n- this.backBufferTimerId = null;\n- }\n- }\n- },\n+ displayOutsideMaxExtent: false,\n \n /**\n- * Method: moveByPx\n- * Move the layer based on pixel vector.\n- *\n- * Parameters:\n- * dx - {Number}\n- * dy - {Number}\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- moveByPx: function(dx, dy) {\n- if (!this.singleTile) {\n- this.moveGriddedTiles();\n- }\n- },\n+ wrapDateLine: false,\n \n /**\n- * APIMethod: setTileSize\n- * Check if we are in singleTile mode and if so, set the size as a ratio\n- * of the map size (as specified by the layer's 'ratio' property).\n- * \n- * Parameters:\n- * size - {}\n+ * Property: metadata\n+ * {Object} This object can be used to store additional information on a\n+ * layer object.\n */\n- setTileSize: function(size) {\n- if (this.singleTile) {\n- size = this.map.getSize();\n- size.h = parseInt(size.h * this.ratio, 10);\n- size.w = parseInt(size.w * this.ratio, 10);\n- }\n- OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]);\n- },\n+ metadata: null,\n \n /**\n- * APIMethod: getTilesBounds\n- * Return the bounds of the tile grid.\n+ * Constructor: OpenLayers.Layer\n *\n- * Returns:\n- * {} A Bounds object representing the bounds of all the\n- * currently loaded tiles (including those partially or not at all seen \n- * onscreen).\n+ * Parameters:\n+ * name - {String} The layer name\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n */\n- getTilesBounds: function() {\n- var bounds = null;\n+ initialize: function(name, options) {\n \n- var length = this.grid.length;\n- if (length) {\n- var bottomLeftTileBounds = this.grid[length - 1][0].bounds,\n- width = this.grid[0].length * bottomLeftTileBounds.getWidth(),\n- height = this.grid.length * bottomLeftTileBounds.getHeight();\n+ this.metadata = {};\n \n- bounds = new OpenLayers.Bounds(bottomLeftTileBounds.left,\n- bottomLeftTileBounds.bottom,\n- bottomLeftTileBounds.left + width,\n- bottomLeftTileBounds.bottom + height);\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- return bounds;\n- },\n-\n- /**\n- * Method: initSingleTile\n- * \n- * Parameters: \n- * bounds - {}\n- */\n- initSingleTile: function(bounds) {\n- this.events.triggerEvent(\"retile\");\n+ this.addOptions(options);\n \n- //determine new tile bounds\n- var center = bounds.getCenterLonLat();\n- var tileWidth = bounds.getWidth() * this.ratio;\n- var tileHeight = bounds.getHeight() * this.ratio;\n+ this.name = name;\n \n- var tileBounds =\n- new OpenLayers.Bounds(center.lon - (tileWidth / 2),\n- center.lat - (tileHeight / 2),\n- center.lon + (tileWidth / 2),\n- center.lat + (tileHeight / 2));\n+ if (this.id == null) {\n \n- var px = this.map.getLayerPxFromLonLat({\n- lon: tileBounds.left,\n- lat: tileBounds.top\n- });\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n \n- if (!this.grid.length) {\n- this.grid[0] = [];\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- var tile = this.grid[0][0];\n- if (!tile) {\n- tile = this.addTile(tileBounds, px);\n+ this.events = new OpenLayers.Events(this, this.div);\n+ if (this.eventListeners instanceof Object) {\n+ this.events.on(this.eventListeners);\n+ }\n \n- this.addTileMonitoringHooks(tile);\n- tile.draw();\n- this.grid[0][0] = tile;\n- } else {\n- tile.moveTo(tileBounds, px);\n }\n+ },\n \n- //remove all but our single tile\n- this.removeExcessTiles(1, 1);\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+ 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- // store the resolution of the grid\n- this.gridResolution = this.getServerResolution();\n+ if (this.events) {\n+ if (this.eventListeners) {\n+ this.events.un(this.eventListeners);\n+ }\n+ this.events.destroy();\n+ }\n+ this.eventListeners = null;\n+ this.events = null;\n },\n \n- /** \n- * Method: calculateGridLayout\n- * Generate parameters for the grid layout.\n+ /**\n+ * Method: clone\n *\n * Parameters:\n- * bounds - {|Object} OpenLayers.Bounds or an\n- * object with a 'left' and 'top' properties.\n- * origin - {|Object} OpenLayers.LonLat or an\n- * object with a 'lon' and 'lat' properties.\n- * resolution - {Number}\n+ * obj - {} The layer to be cloned\n *\n * Returns:\n- * {Object} Object containing properties tilelon, tilelat, startcol,\n- * startrow\n+ * {} An exact clone of this \n */\n- calculateGridLayout: function(bounds, origin, resolution) {\n- var tilelon = resolution * this.tileSize.w;\n- var tilelat = resolution * this.tileSize.h;\n-\n- var offsetlon = bounds.left - origin.lon;\n- var tilecol = Math.floor(offsetlon / tilelon) - this.buffer;\n+ clone: function(obj) {\n \n- var rowSign = this.rowSign;\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer(this.name, this.getOptions());\n+ }\n \n- var offsetlat = rowSign * (origin.lat - bounds.top + tilelat);\n- var tilerow = Math[~rowSign ? 'floor' : 'ceil'](offsetlat / tilelat) - this.buffer * rowSign;\n+ // catch any randomly tagged-on properties\n+ OpenLayers.Util.applyDefaults(obj, this);\n \n- return {\n- tilelon: tilelon,\n- tilelat: tilelat,\n- startcol: tilecol,\n- startrow: tilerow\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: getTileOrigin\n- * Determine the origin for aligning the grid of tiles. If a \n- * property is supplied, that will be returned. Otherwise, the origin\n- * will be derived from the layer's property. In this case,\n- * the tile origin will be the corner of the given by the \n- * property.\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- * {} The tile origin.\n+ * {Object} the of the layer, representing the current state.\n */\n- getTileOrigin: function() {\n- var origin = this.tileOrigin;\n- if (!origin) {\n- var extent = this.getMaxExtent();\n- var edges = ({\n- \"tl\": [\"left\", \"top\"],\n- \"tr\": [\"right\", \"top\"],\n- \"bl\": [\"left\", \"bottom\"],\n- \"br\": [\"right\", \"bottom\"]\n- })[this.tileOriginCorner];\n- origin = new OpenLayers.LonLat(extent[edges[0]], extent[edges[1]]);\n+ getOptions: function() {\n+ var options = {};\n+ for (var o in this.options) {\n+ options[o] = this[o];\n }\n- return origin;\n+ return options;\n },\n \n- /**\n- * Method: getTileBoundsForGridIndex\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- * row - {Number} The row of the grid\n- * col - {Number} The column of the grid\n- *\n- * Returns:\n- * {} The bounds for the tile at (row, col)\n+ * newName - {String} The new name.\n */\n- getTileBoundsForGridIndex: function(row, col) {\n- var origin = this.getTileOrigin();\n- var tileLayout = this.gridLayout;\n- var tilelon = tileLayout.tilelon;\n- var tilelat = tileLayout.tilelat;\n- var startcol = tileLayout.startcol;\n- var startrow = tileLayout.startrow;\n- var rowSign = this.rowSign;\n- return new OpenLayers.Bounds(\n- origin.lon + (startcol + col) * tilelon,\n- origin.lat - (startrow + row * rowSign) * tilelat * rowSign,\n- origin.lon + (startcol + col + 1) * tilelon,\n- origin.lat - (startrow + (row - 1) * rowSign) * tilelat * rowSign\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- * Method: initGriddedTiles\n+ * APIMethod: addOptions\n * \n * Parameters:\n- * bounds - {}\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- initGriddedTiles: function(bounds) {\n- this.events.triggerEvent(\"retile\");\n-\n- // work out mininum number of rows and columns; this is the number of\n- // tiles required to cover the viewport plus at least one for panning\n-\n- var viewSize = this.map.getSize();\n-\n- var origin = this.getTileOrigin();\n- var resolution = this.map.getResolution(),\n- serverResolution = this.getServerResolution(),\n- ratio = resolution / serverResolution,\n- tileSize = {\n- w: this.tileSize.w / ratio,\n- h: this.tileSize.h / ratio\n- };\n-\n- var minRows = Math.ceil(viewSize.h / tileSize.h) +\n- 2 * this.buffer + 1;\n- var minCols = Math.ceil(viewSize.w / tileSize.w) +\n- 2 * this.buffer + 1;\n+ addOptions: function(newOptions, reinitialize) {\n \n- var tileLayout = this.calculateGridLayout(bounds, origin, serverResolution);\n- this.gridLayout = tileLayout;\n+ if (this.options == null) {\n+ this.options = {};\n+ }\n \n- var tilelon = tileLayout.tilelon;\n- var tilelat = tileLayout.tilelat;\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- var layerContainerDivLeft = this.map.layerContainerOriginPx.x;\n- var layerContainerDivTop = this.map.layerContainerOriginPx.y;\n+ // update our copy for clone\n+ OpenLayers.Util.extend(this.options, newOptions);\n \n- var tileBounds = this.getTileBoundsForGridIndex(0, 0);\n- var startPx = this.map.getViewPortPxFromLonLat(\n- new OpenLayers.LonLat(tileBounds.left, tileBounds.top)\n- );\n- startPx.x = Math.round(startPx.x) - layerContainerDivLeft;\n- startPx.y = Math.round(startPx.y) - layerContainerDivTop;\n+ // add new options to this\n+ OpenLayers.Util.extend(this, newOptions);\n \n- var tileData = [],\n- center = this.map.getCenter();\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- var rowidx = 0;\n- do {\n- var row = this.grid[rowidx];\n- if (!row) {\n- row = [];\n- this.grid.push(row);\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- var colidx = 0;\n- do {\n- tileBounds = this.getTileBoundsForGridIndex(rowidx, colidx);\n- var px = startPx.clone();\n- px.x = px.x + colidx * Math.round(tileSize.w);\n- px.y = px.y + rowidx * Math.round(tileSize.h);\n- var tile = row[colidx];\n- if (!tile) {\n- tile = this.addTile(tileBounds, px);\n- this.addTileMonitoringHooks(tile);\n- row.push(tile);\n- } else {\n- tile.moveTo(tileBounds, px, false);\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 }\n- var tileCenter = tileBounds.getCenterLonLat();\n- tileData.push({\n- tile: tile,\n- distance: Math.pow(tileCenter.lon - center.lon, 2) +\n- Math.pow(tileCenter.lat - center.lat, 2)\n- });\n+ }\n+ }\n+ },\n \n- colidx += 1;\n- } while ((tileBounds.right <= bounds.right + tilelon * this.buffer) ||\n- colidx < minCols);\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- rowidx += 1;\n- } while ((tileBounds.bottom >= bounds.bottom - tilelat * this.buffer) ||\n- rowidx < minRows);\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- //shave off exceess rows and colums\n- this.removeExcessTiles(rowidx, colidx);\n+ // min/max Range may have changed\n+ this.inRange = this.calculateInRange();\n \n- var resolution = this.getServerResolution();\n- // store the resolution of the grid\n- this.gridResolution = resolution;\n+ // map's center might not yet be set\n+ var extent = this.getExtent();\n \n- //now actually draw the tiles\n- tileData.sort(function(a, b) {\n- return a.distance - b.distance;\n- });\n- for (var i = 0, ii = tileData.length; i < ii; ++i) {\n- tileData[i].tile.draw();\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: getMaxExtent\n- * Get this layer's maximum extent. (Implemented as a getter for\n- * potential specific implementations in sub-classes.)\n- *\n- * Returns:\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- getMaxExtent: function() {\n- return this.maxExtent;\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: addTile\n- * Create a tile, initialize it, and add it to the layer div. \n- *\n- * Parameters\n- * bounds - {}\n- * position - {}\n+ * Method: moveByPx\n+ * Move the layer based on pixel vector. To be implemented by subclasses.\n *\n- * Returns:\n- * {} The added OpenLayers.Tile\n+ * Parameters:\n+ * dx - {Number} The x coord of the displacement vector.\n+ * dy - {Number} The y coord of the displacement vector.\n */\n- addTile: function(bounds, position) {\n- var tile = new this.tileClass(\n- this, position, bounds, null, this.tileSize, this.tileOptions\n- );\n- this.events.triggerEvent(\"addtile\", {\n- tile: tile\n- });\n- return tile;\n- },\n+ moveByPx: function(dx, dy) {},\n \n- /** \n- * Method: addTileMonitoringHooks\n- * This function takes a tile as input and adds the appropriate hooks to \n- * the tile so that the layer can keep track of the loading tiles.\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- * Parameters: \n- * tile - {}\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- addTileMonitoringHooks: function(tile) {\n+ setMap: function(map) {\n+ if (this.map == null) {\n \n- var replacingCls = 'olTileReplacing';\n+ this.map = map;\n \n- tile.onLoadStart = function() {\n- //if that was first tile then trigger a 'loadstart' on the layer\n- if (this.loading === false) {\n- this.loading = true;\n- this.events.triggerEvent(\"loadstart\");\n- }\n- this.events.triggerEvent(\"tileloadstart\", {\n- tile: tile\n- });\n- this.numLoadingTiles++;\n- if (!this.singleTile && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n- OpenLayers.Element.addClass(tile.getTile(), replacingCls);\n- }\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- tile.onLoadEnd = function(evt) {\n- this.numLoadingTiles--;\n- var aborted = evt.type === 'unload';\n- this.events.triggerEvent(\"tileloaded\", {\n- tile: tile,\n- aborted: aborted\n- });\n- if (!this.singleTile && !aborted && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n- var tileDiv = tile.getTile();\n- if (OpenLayers.Element.getStyle(tileDiv, 'display') === 'none') {\n- var bufferTile = document.getElementById(tile.id + '_bb');\n- if (bufferTile) {\n- bufferTile.parentNode.removeChild(bufferTile);\n- }\n- }\n- OpenLayers.Element.removeClass(tileDiv, replacingCls);\n- }\n- //if that was the last tile, then trigger a 'loadend' on the layer\n- if (this.numLoadingTiles === 0) {\n- if (this.backBuffer) {\n- if (this.backBuffer.childNodes.length === 0) {\n- // no tiles transitioning, remove immediately\n- this.removeBackBuffer();\n- } else {\n- // wait until transition has ended or delay has passed\n- this._transitionElement = aborted ?\n- this.div.lastChild : tile.imgDiv;\n- var transitionendEvents = this.transitionendEvents;\n- for (var i = transitionendEvents.length - 1; i >= 0; --i) {\n- OpenLayers.Event.observe(this._transitionElement,\n- transitionendEvents[i],\n- this._removeBackBuffer);\n- }\n- // the removal of the back buffer is delayed to prevent\n- // flash effects due to the animation of tile displaying\n- this.backBufferTimerId = window.setTimeout(\n- this._removeBackBuffer, this.removeBackBufferDelay\n- );\n- }\n- }\n- this.loading = false;\n- this.events.triggerEvent(\"loadend\");\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 \n- tile.onLoadError = function() {\n- this.events.triggerEvent(\"tileerror\", {\n- tile: tile\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- tile.events.on({\n- \"loadstart\": tile.onLoadStart,\n- \"loadend\": tile.onLoadEnd,\n- \"unload\": tile.onLoadEnd,\n- \"loaderror\": tile.onLoadError,\n- scope: this\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: removeTileMonitoringHooks\n- * This function takes a tile as input and removes the tile hooks \n- * that were added in addTileMonitoringHooks()\n- * \n- * Parameters: \n- * tile - {}\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- removeTileMonitoringHooks: function(tile) {\n- tile.unload();\n- tile.events.un({\n- \"loadstart\": tile.onLoadStart,\n- \"loadend\": tile.onLoadEnd,\n- \"unload\": tile.onLoadEnd,\n- \"loaderror\": tile.onLoadError,\n- scope: this\n- });\n- },\n+ afterAdd: function() {},\n \n /**\n- * Method: moveGriddedTiles\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- moveGriddedTiles: function() {\n- var buffer = this.buffer + 1;\n- while (true) {\n- var tlTile = this.grid[0][0];\n- var tlViewPort = {\n- x: tlTile.position.x +\n- this.map.layerContainerOriginPx.x,\n- y: tlTile.position.y +\n- this.map.layerContainerOriginPx.y\n- };\n- var ratio = this.getServerResolution() / this.map.getResolution();\n- var tileSize = {\n- w: Math.round(this.tileSize.w * ratio),\n- h: Math.round(this.tileSize.h * ratio)\n- };\n- if (tlViewPort.x > -tileSize.w * (buffer - 1)) {\n- this.shiftColumn(true, tileSize);\n- } else if (tlViewPort.x < -tileSize.w * buffer) {\n- this.shiftColumn(false, tileSize);\n- } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {\n- this.shiftRow(true, tileSize);\n- } else if (tlViewPort.y < -tileSize.h * buffer) {\n- this.shiftRow(false, tileSize);\n- } else {\n- break;\n- }\n- }\n+ removeMap: function(map) {\n+ //to be overridden by subclasses\n },\n \n /**\n- * Method: shiftRow\n- * Shifty grid work\n+ * APIMethod: getImageSize\n *\n * Parameters:\n- * prepend - {Boolean} if true, prepend to beginning.\n- * if false, then append to end\n- * tileSize - {Object} rendered tile size; object with w and h properties\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- shiftRow: function(prepend, tileSize) {\n- var grid = this.grid;\n- var rowIndex = prepend ? 0 : (grid.length - 1);\n- var sign = prepend ? -1 : 1;\n- var rowSign = this.rowSign;\n- var tileLayout = this.gridLayout;\n- tileLayout.startrow += sign * rowSign;\n-\n- var modelRow = grid[rowIndex];\n- var row = grid[prepend ? 'pop' : 'shift']();\n- for (var i = 0, len = row.length; i < len; i++) {\n- var tile = row[i];\n- var position = modelRow[i].position.clone();\n- position.y += tileSize.h * sign;\n- tile.moveTo(this.getTileBoundsForGridIndex(rowIndex, i), position);\n- }\n- grid[prepend ? 'unshift' : 'push'](row);\n+ getImageSize: function(bounds) {\n+ return (this.imageSize || this.tileSize);\n },\n \n /**\n- * Method: shiftColumn\n- * Shift grid work in the other dimension\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- * prepend - {Boolean} if true, prepend to beginning.\n- * if false, then append to end\n- * tileSize - {Object} rendered tile size; object with w and h properties\n+ * size - {}\n */\n- shiftColumn: function(prepend, tileSize) {\n- var grid = this.grid;\n- var colIndex = prepend ? 0 : (grid[0].length - 1);\n- var sign = prepend ? -1 : 1;\n- var tileLayout = this.gridLayout;\n- tileLayout.startcol += sign;\n-\n- for (var i = 0, len = grid.length; i < len; i++) {\n- var row = grid[i];\n- var position = row[colIndex].position.clone();\n- var tile = row[prepend ? 'pop' : 'shift']();\n- position.x += tileSize.w * sign;\n- tile.moveTo(this.getTileBoundsForGridIndex(i, colIndex), position);\n- row[prepend ? 'unshift' : 'push'](tile);\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- * Method: removeExcessTiles\n- * When the size of the map or the buffer changes, we may need to\n- * remove some excess rows and columns.\n+ * APIMethod: getVisibility\n * \n- * Parameters:\n- * rows - {Integer} Maximum number of rows we want our grid to have.\n- * columns - {Integer} Maximum number of columns we want our grid to have.\n+ * Returns:\n+ * {Boolean} The layer should be displayed (if in range).\n */\n- removeExcessTiles: function(rows, columns) {\n- var i, l;\n+ getVisibility: function() {\n+ return this.visibility;\n+ },\n \n- // remove extra rows\n- while (this.grid.length > rows) {\n- var row = this.grid.pop();\n- for (i = 0, l = row.length; i < l; i++) {\n- var tile = row[i];\n- this.destroyTile(tile);\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- // remove extra columns\n- for (i = 0, l = this.grid.length; i < l; i++) {\n- while (this.grid[i].length > columns) {\n- var row = this.grid[i];\n- var tile = row.pop();\n- this.destroyTile(tile);\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- * Method: onMapResize\n- * For singleTile layers, this will set a new tile size according to the\n- * dimensions of the map pane.\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- onMapResize: function() {\n- if (this.singleTile) {\n- this.clearGrid();\n- this.setTileSize();\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: getTileBounds\n- * Returns The tile bounds for a layer given a pixel location.\n- *\n+ /** \n+ * APIMethod: setIsBaseLayer\n+ * \n * Parameters:\n- * viewPortPx - {} The location in the viewport.\n- *\n- * Returns:\n- * {} Bounds of the tile at the given pixel location.\n+ * isBaseLayer - {Boolean}\n */\n- getTileBounds: function(viewPortPx) {\n- var maxExtent = this.maxExtent;\n- var resolution = this.getResolution();\n- var tileMapWidth = resolution * this.tileSize.w;\n- var tileMapHeight = resolution * this.tileSize.h;\n- var mapPoint = this.getLonLatFromViewPortPx(viewPortPx);\n- var tileLeft = maxExtent.left + (tileMapWidth *\n- Math.floor((mapPoint.lon -\n- maxExtent.left) /\n- tileMapWidth));\n- var tileBottom = maxExtent.bottom + (tileMapHeight *\n- Math.floor((mapPoint.lat -\n- maxExtent.bottom) /\n- tileMapHeight));\n- return new OpenLayers.Bounds(tileLeft, tileBottom,\n- tileLeft + tileMapWidth,\n- tileBottom + tileMapHeight);\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- CLASS_NAME: \"OpenLayers.Layer.Grid\"\n-});\n-/* ======================================================================\n- OpenLayers/TileManager.js\n- ====================================================================== */\n+ /********************************************************/\n+ /* */\n+ /* Baselayer Functions */\n+ /* */\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+ * 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-/**\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/BaseTypes.js\n- * @requires OpenLayers/BaseTypes/Element.js\n- * @requires OpenLayers/Layer/Grid.js\n- * @requires OpenLayers/Tile/Image.js\n- */\n+ var i, len, p;\n+ var props = {},\n+ alwaysInRange = true;\n \n-/**\n- * Class: OpenLayers.TileManager\n- * Provides queueing of image requests and caching of image elements.\n- *\n- * Queueing avoids unnecessary image requests while changing zoom levels\n- * quickly, and helps improve dragging performance on mobile devices that show\n- * a lag in dragging when loading of new images starts. and\n- * are the configuration options to control this behavior.\n- *\n- * Caching avoids setting the src on image elements for images that have already\n- * been used. Several maps can share a TileManager instance, in which case each\n- * map gets its own tile queue, but all maps share the same tile cache.\n- */\n-OpenLayers.TileManager = OpenLayers.Class({\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- * APIProperty: cacheSize\n- * {Number} Number of image elements to keep referenced in this instance's\n- * cache for fast reuse. Default is 256.\n- */\n- cacheSize: 256,\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- * APIProperty: tilesPerFrame\n- * {Number} Number of queued tiles to load per frame (see ).\n- * Default is 2.\n- */\n- tilesPerFrame: 2,\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: frameDelay\n- * {Number} Delay between tile loading frames (see ) in\n- * milliseconds. Default is 16.\n- */\n- frameDelay: 16,\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: moveDelay\n- * {Number} Delay in milliseconds after a map's move event before loading\n- * tiles. Default is 100.\n- */\n- moveDelay: 100,\n+ // ok, we new need to set properties in the instance\n \n- /**\n- * APIProperty: zoomDelay\n- * {Number} Delay in milliseconds after a map's zoomend event before loading\n- * tiles. Default is 200.\n- */\n- zoomDelay: 200,\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- /**\n- * Property: maps\n- * {Array()} The maps to manage tiles on.\n- */\n- maps: null,\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- /**\n- * Property: tileQueueId\n- * {Object} The ids of the loop, keyed by map id.\n- */\n- tileQueueId: null,\n+ if (props.resolutions) {\n \n- /**\n- * Property: tileQueue\n- * {Object(Array())} Tiles queued for drawing, keyed by\n- * map id.\n- */\n- tileQueue: null,\n+ //sort resolutions array descendingly\n+ props.resolutions.sort(function(a, b) {\n+ return (b - a);\n+ });\n \n- /**\n- * Property: tileCache\n- * {Object} Cached image elements, keyed by URL.\n- */\n- tileCache: null,\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- /**\n- * Property: tileCacheIndex\n- * {Array(String)} URLs of cached tiles. First entry is the least recently\n- * used.\n- */\n- tileCacheIndex: null,\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- /** \n- * Constructor: OpenLayers.TileManager\n- * Constructor for a new instance.\n- * \n- * Parameters:\n- * options - {Object} Configuration for this instance.\n- */\n- initialize: function(options) {\n- OpenLayers.Util.extend(this, options);\n- this.maps = [];\n- this.tileQueueId = {};\n- this.tileQueue = {};\n- this.tileCache = {};\n- this.tileCacheIndex = [];\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: addMap\n- * Binds this instance to a map\n+ * Method: resolutionsFromScales\n+ * Derive resolutions from scales.\n *\n * Parameters:\n- * map - {}\n+ * scales - {Array(Number)} Scales\n+ *\n+ * Returns\n+ * {Array(Number)} Resolutions\n */\n- addMap: function(map) {\n- if (this._destroyed || !OpenLayers.Layer.Grid) {\n+ resolutionsFromScales: function(scales) {\n+ if (scales == null) {\n return;\n }\n- this.maps.push(map);\n- this.tileQueue[map.id] = [];\n- for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n- this.addLayer({\n- layer: map.layers[i]\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- map.events.on({\n- move: this.move,\n- zoomend: this.zoomEnd,\n- changelayer: this.changeLayer,\n- addlayer: this.addLayer,\n- preremovelayer: this.removeLayer,\n- scope: this\n- });\n+ return resolutions;\n },\n \n /**\n- * Method: removeMap\n- * Unbinds this instance from a map\n+ * Method: calculateResolutions\n+ * Calculate resolutions based on the provided properties.\n *\n * Parameters:\n- * map - {}\n+ * props - {Object} Properties\n+ *\n+ * Returns:\n+ * {Array({Number})} Array of resolutions.\n */\n- removeMap: function(map) {\n- if (this._destroyed || !OpenLayers.Layer.Grid) {\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- window.clearTimeout(this.tileQueueId[map.id]);\n- if (map.layers) {\n- for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n- this.removeLayer({\n- layer: map.layers[i]\n- });\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- if (map.events) {\n- map.events.un({\n- move: this.move,\n- zoomend: this.zoomEnd,\n- changelayer: this.changeLayer,\n- addlayer: this.addLayer,\n- preremovelayer: this.removeLayer,\n- scope: this\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+ }\n+ } else {\n+ for (i = 0; i < numZoomLevels; i++) {\n+ resolutions[numZoomLevels - 1 - i] =\n+ minResolution * Math.pow(base, i);\n+ }\n }\n- delete this.tileQueue[map.id];\n- delete this.tileQueueId[map.id];\n- OpenLayers.Util.removeItem(this.maps, map);\n+\n+ return resolutions;\n },\n \n /**\n- * Method: move\n- * Handles the map's move event\n- *\n- * Parameters:\n- * evt - {Object} Listener argument\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- move: function(evt) {\n- this.updateTimeout(evt.object, this.moveDelay, true);\n+ getResolution: function() {\n+ var zoom = this.map.getZoom();\n+ return this.getResolutionForZoom(zoom);\n },\n \n- /**\n- * Method: zoomEnd\n- * Handles the map's zoomEnd event\n- *\n- * Parameters:\n- * evt - {Object} Listener argument\n+ /** \n+ * APIMethod: getExtent\n+ * \n+ * Returns:\n+ * {} A Bounds object which represents the lon/lat \n+ * bounds of the current viewPort.\n */\n- zoomEnd: function(evt) {\n- this.updateTimeout(evt.object, this.zoomDelay);\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- * Method: changeLayer\n- * Handles the map's changeLayer event\n- *\n+ * APIMethod: getZoomForExtent\n+ * \n * Parameters:\n- * evt - {Object} Listener argument\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- changeLayer: function(evt) {\n- if (evt.property === 'visibility' || evt.property === 'params') {\n- this.updateTimeout(evt.object, 0);\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- * Method: addLayer\n- * Handles the map's addlayer event\n- *\n+ * APIMethod: getResolutionForZoom\n+ * \n * Parameters:\n- * evt - {Object} The listener argument\n+ * zoom - {Float}\n+ * \n+ * Returns:\n+ * {Float} A suitable resolution for the specified zoom.\n */\n- addLayer: function(evt) {\n- var layer = evt.layer;\n- if (layer instanceof OpenLayers.Layer.Grid) {\n- layer.events.on({\n- addtile: this.addTile,\n- retile: this.clearTileQueue,\n- scope: this\n- });\n- var i, j, tile;\n- for (i = layer.grid.length - 1; i >= 0; --i) {\n- for (j = layer.grid[i].length - 1; j >= 0; --j) {\n- tile = layer.grid[i][j];\n- this.addTile({\n- tile: tile\n- });\n- if (tile.url && !tile.imgDiv) {\n- this.manageTileCache({\n- object: tile\n- });\n- }\n- }\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 }\n+ return resolution;\n },\n \n /**\n- * Method: removeLayer\n- * Handles the map's preremovelayer event\n- *\n+ * APIMethod: getZoomForResolution\n+ * \n * Parameters:\n- * evt - {Object} The listener argument\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+ * {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- removeLayer: function(evt) {\n- var layer = evt.layer;\n- if (layer instanceof OpenLayers.Layer.Grid) {\n- this.clearTileQueue({\n- object: layer\n- });\n- if (layer.events) {\n- layer.events.un({\n- addtile: this.addTile,\n- retile: this.clearTileQueue,\n- scope: this\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- if (layer.grid) {\n- var i, j, tile;\n- for (i = layer.grid.length - 1; i >= 0; --i) {\n- for (j = layer.grid[i].length - 1; j >= 0; --j) {\n- tile = layer.grid[i][j];\n- this.unloadTile({\n- object: tile\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 }\n+ return zoom;\n },\n \n /**\n- * Method: updateTimeout\n- * Applies the or to the loop,\n- * and schedules more queue processing after if there are still\n- * tiles in the queue.\n- *\n+ * APIMethod: getLonLatFromViewPortPx\n+ * \n * Parameters:\n- * map - {} The map to update the timeout for\n- * delay - {Number} The delay to apply\n- * nice - {Boolean} If true, the timeout function will only be created if\n- * the tilequeue is not empty. This is used by the move handler to\n- * avoid impacts on dragging performance. For other events, the tile\n- * queue may not be populated yet, so we need to set the timer\n- * regardless of the queue size.\n- */\n- updateTimeout: function(map, delay, nice) {\n- window.clearTimeout(this.tileQueueId[map.id]);\n- var tileQueue = this.tileQueue[map.id];\n- if (!nice || tileQueue.length) {\n- this.tileQueueId[map.id] = window.setTimeout(\n- OpenLayers.Function.bind(function() {\n- this.drawTilesFromQueue(map);\n- if (tileQueue.length) {\n- this.updateTimeout(map, this.frameDelay);\n- }\n- }, this), delay\n- );\n- }\n- },\n-\n- /**\n- * Method: addTile\n- * Listener for the layer's addtile event\n+ * viewPortPx - {|Object} An OpenLayers.Pixel or\n+ * an object with a 'x'\n+ * and 'y' properties.\n *\n- * Parameters:\n- * evt - {Object} The listener argument\n+ * Returns:\n+ * {} An OpenLayers.LonLat which is the passed-in \n+ * view port , translated into lon/lat by the layer.\n */\n- addTile: function(evt) {\n- if (evt.tile instanceof OpenLayers.Tile.Image) {\n- evt.tile.events.on({\n- beforedraw: this.queueTileDraw,\n- beforeload: this.manageTileCache,\n- loadend: this.addToCache,\n- unload: this.unloadTile,\n- scope: this\n- });\n- } else {\n- // Layer has the wrong tile type, so don't handle it any longer\n- this.removeLayer({\n- layer: evt.tile.layer\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- * Method: unloadTile\n- * Listener for the tile's unload event\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- * evt - {Object} The listener argument\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- unloadTile: function(evt) {\n- var tile = evt.object;\n- tile.events.un({\n- beforedraw: this.queueTileDraw,\n- beforeload: this.manageTileCache,\n- loadend: this.addToCache,\n- unload: this.unloadTile,\n- scope: this\n- });\n- OpenLayers.Util.removeItem(this.tileQueue[tile.layer.map.id], tile);\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+ return px;\n },\n \n /**\n- * Method: queueTileDraw\n- * Adds a tile to the queue that will draw it.\n- *\n+ * APIMethod: setOpacity\n+ * Sets the opacity for the entire layer (all images)\n+ * \n * Parameters:\n- * evt - {Object} Listener argument of the tile's beforedraw event\n+ * opacity - {Float}\n */\n- queueTileDraw: function(evt) {\n- var tile = evt.object;\n- var queued = false;\n- var layer = tile.layer;\n- var url = layer.getURL(tile.bounds);\n- var img = this.tileCache[url];\n- if (img && img.className !== 'olTileImage') {\n- // cached image no longer valid, e.g. because we're olTileReplacing\n- delete this.tileCache[url];\n- OpenLayers.Util.removeItem(this.tileCacheIndex, url);\n- img = null;\n- }\n- // queue only if image with same url not cached already\n- if (layer.url && (layer.async || !img)) {\n- // add to queue only if not in queue already\n- var tileQueue = this.tileQueue[layer.map.id];\n- if (!~OpenLayers.Util.indexOf(tileQueue, tile)) {\n- tileQueue.push(tile);\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+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"opacity\"\n+ });\n }\n- queued = true;\n }\n- return !queued;\n },\n \n /**\n- * Method: drawTilesFromQueue\n- * Draws tiles from the tileQueue, and unqueues the tiles\n+ * Method: getZIndex\n+ * \n+ * Returns: \n+ * {Integer} the z-index of this layer\n */\n- drawTilesFromQueue: function(map) {\n- var tileQueue = this.tileQueue[map.id];\n- var limit = this.tilesPerFrame;\n- var animating = map.zoomTween && map.zoomTween.playing;\n- while (!animating && tileQueue.length && limit) {\n- tileQueue.shift().draw(true);\n- --limit;\n- }\n+ getZIndex: function() {\n+ return this.div.style.zIndex;\n },\n \n /**\n- * Method: manageTileCache\n- * Adds, updates, removes and fetches cache entries.\n- *\n- * Parameters:\n- * evt - {Object} Listener argument of the tile's beforeload event\n+ * Method: setZIndex\n+ * \n+ * Parameters: \n+ * zIndex - {Integer}\n */\n- manageTileCache: function(evt) {\n- var tile = evt.object;\n- var img = this.tileCache[tile.url];\n- if (img) {\n- // if image is on its layer's backbuffer, remove it from backbuffer\n- if (img.parentNode &&\n- OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer')) {\n- img.parentNode.removeChild(img);\n- img.id = null;\n- }\n- // only use image from cache if it is not on a layer already\n- if (!img.parentNode) {\n- img.style.visibility = 'hidden';\n- img.style.opacity = 0;\n- tile.setImage(img);\n- // LRU - move tile to the end of the array to mark it as the most\n- // recently used\n- OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);\n- this.tileCacheIndex.push(tile.url);\n- }\n- }\n+ setZIndex: function(zIndex) {\n+ this.div.style.zIndex = zIndex;\n },\n \n /**\n- * Method: addToCache\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- * evt - {Object} Listener argument for the tile's loadend event\n+ * bounds - {}\n */\n- addToCache: function(evt) {\n- var tile = evt.object;\n- if (!this.tileCache[tile.url]) {\n- if (!OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError')) {\n- if (this.tileCacheIndex.length >= this.cacheSize) {\n- delete this.tileCache[this.tileCacheIndex[0]];\n- this.tileCacheIndex.shift();\n- }\n- this.tileCache[tile.url] = tile.imgDiv;\n- this.tileCacheIndex.push(tile.url);\n- }\n- }\n- },\n+ adjustBounds: function(bounds) {\n \n- /**\n- * Method: clearTileQueue\n- * Clears the tile queue from tiles of a specific layer\n- *\n- * Parameters:\n- * evt - {Object} Listener argument of the layer's retile event\n- */\n- clearTileQueue: function(evt) {\n- var layer = evt.object;\n- var tileQueue = this.tileQueue[layer.map.id];\n- for (var i = tileQueue.length - 1; i >= 0; --i) {\n- if (tileQueue[i].layer === layer) {\n- tileQueue.splice(i, 1);\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- },\n \n- /**\n- * Method: destroy\n- */\n- destroy: function() {\n- for (var i = this.maps.length - 1; i >= 0; --i) {\n- this.removeMap(this.maps[i]);\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- this.maps = null;\n- this.tileQueue = null;\n- this.tileQueueId = null;\n- this.tileCache = null;\n- this.tileCacheIndex = null;\n- this._destroyed = true;\n- }\n+ return bounds;\n+ },\n \n+ CLASS_NAME: \"OpenLayers.Layer\"\n });\n /* ======================================================================\n- OpenLayers/Spherical.js\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/SingleFile.js\n+ * @requires OpenLayers/BaseTypes/Class.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+ * Class: OpenLayers.Symbolizer\n+ * Base class representing a symbolizer used for feature rendering.\n */\n+OpenLayers.Symbolizer = OpenLayers.Class({\n \n-OpenLayers.Spherical = OpenLayers.Spherical || {};\n \n-OpenLayers.Spherical.DEFAULT_RADIUS = 6378137;\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- * 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+ * 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- * 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/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@@ -33365,20153 +27827,16483 @@\n }\n return new OpenLayers.Style2(config);\n },\n \n CLASS_NAME: \"OpenLayers.Style2\"\n });\n /* ======================================================================\n- OpenLayers/Marker.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 /**\n * @requires OpenLayers/BaseTypes/Class.js\n- * @requires OpenLayers/Events.js\n- * @requires OpenLayers/Icon.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+ * Class: OpenLayers.Renderer \n+ * This is the base class for all renderers.\n *\n- * (end)\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- * 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+OpenLayers.Renderer = OpenLayers.Class({\n \n /** \n- * Property: events \n- * {} the event handler.\n+ * Property: container\n+ * {DOMElement} \n */\n- events: null,\n+ container: null,\n \n- /** \n- * Property: map \n- * {} the map this marker is attached to\n+ /**\n+ * Property: root\n+ * {DOMElement}\n */\n- map: null,\n+ root: 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+ * Property: extent\n+ * {}\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+ extent: null,\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+ * 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- draw: function(px) {\n- return this.icon.draw(px);\n- },\n+ locked: false,\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+ * Property: size\n+ * {} \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+ size: null,\n \n /**\n- * APIMethod: isDrawn\n- * \n- * Returns:\n- * {Boolean} Whether or not the marker is drawn.\n+ * Property: resolution\n+ * {Float} cache of current map resolution\n */\n- isDrawn: function() {\n- var isDrawn = (this.icon && this.icon.isDrawn());\n- return isDrawn;\n- },\n+ resolution: null,\n \n /**\n- * Method: onScreen\n- *\n- * Returns:\n- * {Boolean} Whether or not the marker is currently visible on screen.\n+ * Property: map \n+ * {} Reference to the map -- this is set in Vector's setMap()\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+ map: null,\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+ * 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- setOpacity: function(opacity) {\n- this.icon.setOpacity(opacity);\n- },\n+ featureDx: 0,\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/Marker/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/Marker.js\n- */\n-\n-/**\n- * Class: OpenLayers.Marker.Box\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Marker.Box = OpenLayers.Class(OpenLayers.Marker, {\n-\n- /** \n- * Property: bounds \n- * {} \n- */\n- bounds: null,\n-\n- /** \n- * Property: div \n- * {DOMElement} \n- */\n- div: null,\n-\n- /** \n- * Constructor: OpenLayers.Marker.Box\n+ * Constructor: OpenLayers.Renderer \n *\n * Parameters:\n- * bounds - {} \n- * borderColor - {String} \n- * borderWidth - {int} \n+ * containerID - {} \n+ * options - {Object} options for this renderer. See sublcasses for\n+ * supported options.\n */\n- initialize: function(bounds, borderColor, borderWidth) {\n- this.bounds = bounds;\n- this.div = OpenLayers.Util.createDiv();\n- this.div.style.overflow = 'hidden';\n- this.events = new OpenLayers.Events(this, this.div);\n- this.setBorder(borderColor, borderWidth);\n+ initialize: function(containerID, options) {\n+ this.container = OpenLayers.Util.getElement(containerID);\n+ OpenLayers.Util.extend(this, options);\n },\n \n /**\n- * Method: destroy \n+ * APIMethod: destroy\n */\n destroy: function() {\n-\n- this.bounds = null;\n- this.div = null;\n-\n- OpenLayers.Marker.prototype.destroy.apply(this, arguments);\n- },\n-\n- /** \n- * Method: setBorder\n- * Allow the user to change the box's color and border width\n- * \n- * Parameters:\n- * color - {String} Default is \"red\"\n- * width - {int} Default is 2\n- */\n- setBorder: function(color, width) {\n- if (!color) {\n- color = \"red\";\n- }\n- if (!width) {\n- width = 2;\n- }\n- this.div.style.border = width + \"px solid \" + color;\n- },\n-\n- /** \n- * Method: draw\n- * \n- * Parameters:\n- * px - {} \n- * sz - {} \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, sz) {\n- OpenLayers.Util.modifyDOMElement(this.div, null, px, sz);\n- return this.div;\n- },\n-\n- /**\n- * Method: onScreen\n- * \n- * Rreturn:\n- * {Boolean} Whether or not the marker is currently visible on screen.\n- */\n- onScreen: function() {\n- var onScreen = false;\n- if (this.map) {\n- var screenBounds = this.map.getExtent();\n- onScreen = screenBounds.containsBounds(this.bounds, true, true);\n- }\n- return onScreen;\n- },\n-\n- /**\n- * Method: display\n- * Hide or show the icon\n- * \n- * Parameters:\n- * display - {Boolean} \n- */\n- display: function(display) {\n- this.div.style.display = (display) ? \"\" : \"none\";\n+ this.container = null;\n+ this.extent = null;\n+ this.size = null;\n+ this.resolution = null;\n+ this.map = null;\n },\n \n- CLASS_NAME: \"OpenLayers.Marker.Box\"\n-});\n-\n-/* ======================================================================\n- OpenLayers/Popup/Anchored.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/Popup.js\n- */\n-\n-/**\n- * Class: OpenLayers.Popup.Anchored\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Popup.Anchored =\n- OpenLayers.Class(OpenLayers.Popup, {\n-\n- /** \n- * Property: relativePosition\n- * {String} Relative position of the popup (\"br\", \"tr\", \"tl\" or \"bl\").\n- */\n- relativePosition: null,\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 set. If you are creating popups that are\n- * near map edges and not allowing pannning, and especially if you have\n- * a popup which has a fixedRelativePosition, setting this to false may\n- * be a smart thing to do.\n- * \n- * For anchored popups, default is true, since subclasses will\n- * usually want this functionality.\n- */\n- keepInMap: true,\n-\n- /**\n- * Property: anchor\n- * {Object} Object to which we'll anchor the popup. Must expose a \n- * 'size' () and 'offset' ().\n- */\n- anchor: null,\n-\n- /** \n- * Constructor: OpenLayers.Popup.Anchored\n- * \n- * Parameters:\n- * id - {String}\n- * lonlat - {}\n- * contentSize - {}\n- * contentHTML - {String}\n- * anchor - {Object} Object which must expose a 'size' \n- * and 'offset' (generally an ).\n- * closeBox - {Boolean}\n- * closeBoxCallback - {Function} Function to be called on closeBox click.\n- */\n- initialize: function(id, lonlat, contentSize, contentHTML, anchor, closeBox,\n- closeBoxCallback) {\n- var newArguments = [\n- id, lonlat, contentSize, contentHTML, closeBox, closeBoxCallback\n- ];\n- OpenLayers.Popup.prototype.initialize.apply(this, newArguments);\n-\n- this.anchor = (anchor != null) ? anchor :\n- {\n- size: new OpenLayers.Size(0, 0),\n- offset: new OpenLayers.Pixel(0, 0)\n- };\n- },\n-\n- /**\n- * APIMethod: destroy\n- */\n- destroy: function() {\n- this.anchor = null;\n- this.relativePosition = null;\n-\n- OpenLayers.Popup.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * APIMethod: show\n- * Overridden from Popup since user might hide popup and then show() it \n- * in a new location (meaning we might want to update the relative\n- * position on the show)\n- */\n- show: function() {\n- this.updatePosition();\n- OpenLayers.Popup.prototype.show.apply(this, arguments);\n- },\n-\n- /**\n- * Method: moveTo\n- * Since the popup is moving to a new px, it might need also to be moved\n- * relative to where the marker is. We first calculate the new \n- * relativePosition, and then we calculate the new px where we will \n- * put the popup, based on the new relative position. \n- * \n- * If the relativePosition has changed, we must also call \n- * updateRelativePosition() to make any visual changes to the popup \n- * which are associated with putting it in a new relativePosition.\n- * \n- * Parameters:\n- * px - {}\n- */\n- moveTo: function(px) {\n- var oldRelativePosition = this.relativePosition;\n- this.relativePosition = this.calculateRelativePosition(px);\n-\n- OpenLayers.Popup.prototype.moveTo.call(this, this.calculateNewPx(px));\n-\n- //if this move has caused the popup to change its relative position, \n- // we need to make the appropriate cosmetic changes.\n- if (this.relativePosition != oldRelativePosition) {\n- this.updateRelativePosition();\n- }\n- },\n-\n- /**\n- * APIMethod: setSize\n- * \n- * Parameters:\n- * contentSize - {} the new size for the popup's \n- * contents div (in pixels).\n- */\n- setSize: function(contentSize) {\n- OpenLayers.Popup.prototype.setSize.apply(this, arguments);\n-\n- if ((this.lonlat) && (this.map)) {\n- var px = this.map.getLayerPxFromLonLat(this.lonlat);\n- this.moveTo(px);\n- }\n- },\n-\n- /** \n- * Method: calculateRelativePosition\n- * \n- * Parameters:\n- * px - {}\n- * \n- * Returns:\n- * {String} The relative position (\"br\" \"tr\" \"tl\" \"bl\") at which the popup\n- * should be placed.\n- */\n- calculateRelativePosition: function(px) {\n- var lonlat = this.map.getLonLatFromLayerPx(px);\n-\n- var extent = this.map.getExtent();\n- var quadrant = extent.determineQuadrant(lonlat);\n-\n- return OpenLayers.Bounds.oppositeQuadrant(quadrant);\n- },\n-\n- /**\n- * Method: updateRelativePosition\n- * The popup has been moved to a new relative location, so we may want to \n- * make some cosmetic adjustments to it. \n- * \n- * Note that in the classic Anchored popup, there is nothing to do \n- * here, since the popup looks exactly the same in all four positions.\n- * Subclasses such as Framed, however, will want to do something\n- * special here.\n- */\n- updateRelativePosition: function() {\n- //to be overridden by subclasses\n- },\n-\n- /** \n- * Method: calculateNewPx\n- * \n- * Parameters:\n- * px - {}\n- * \n- * Returns:\n- * {} The the new px position of the popup on the screen\n- * relative to the passed-in px.\n- */\n- calculateNewPx: function(px) {\n- var newPx = px.offset(this.anchor.offset);\n-\n- //use contentSize if size is not already set\n- var size = this.size || this.contentSize;\n-\n- var top = (this.relativePosition.charAt(0) == 't');\n- newPx.y += (top) ? -size.h : this.anchor.size.h;\n-\n- var left = (this.relativePosition.charAt(1) == 'l');\n- newPx.x += (left) ? -size.w : this.anchor.size.w;\n-\n- return newPx;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Popup.Anchored\"\n- });\n-/* ======================================================================\n- OpenLayers/Popup/Framed.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/Popup/Anchored.js\n- */\n-\n-/**\n- * Class: OpenLayers.Popup.Framed\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Popup.Framed =\n- OpenLayers.Class(OpenLayers.Popup.Anchored, {\n-\n- /**\n- * Property: imageSrc\n- * {String} location of the image to be used as the popup frame\n- */\n- imageSrc: null,\n-\n- /**\n- * Property: imageSize\n- * {} Size (measured in pixels) of the image located\n- * by the 'imageSrc' property.\n- */\n- imageSize: null,\n-\n- /**\n- * APIProperty: isAlphaImage\n- * {Boolean} The image has some alpha and thus needs to use the alpha \n- * image hack. Note that setting this to true will have no noticeable\n- * effect in FF or IE7 browsers, but will all but crush the ie6 \n- * browser. \n- * Default is false.\n- */\n- isAlphaImage: false,\n-\n- /**\n- * Property: positionBlocks\n- * {Object} Hash of different position blocks (Object/Hashs). Each block \n- * will be keyed by a two-character 'relativePosition' \n- * code string (ie \"tl\", \"tr\", \"bl\", \"br\"). Block properties are \n- * 'offset', 'padding' (self-explanatory), and finally the 'blocks'\n- * parameter, which is an array of the block objects. \n- * \n- * Each block object must have 'size', 'anchor', and 'position' \n- * properties.\n- * \n- * Note that positionBlocks should never be modified at runtime.\n- */\n- positionBlocks: null,\n-\n- /**\n- * Property: blocks\n- * {Array[Object]} Array of objects, each of which is one \"block\" of the \n- * popup. Each block has a 'div' and an 'image' property, both of \n- * which are DOMElements, and the latter of which is appended to the \n- * former. These are reused as the popup goes changing positions for\n- * great economy and elegance.\n- */\n- blocks: null,\n-\n- /** \n- * APIProperty: fixedRelativePosition\n- * {Boolean} We want the framed popup to work dynamically placed relative\n- * to its anchor but also in just one fixed position. A well designed\n- * framed popup will have the pixels and logic to display itself in \n- * any of the four relative positions, but (understandably), this will\n- * not be the case for all of them. By setting this property to 'true', \n- * framed popup will not recalculate for the best placement each time\n- * it's open, but will always open the same way. \n- * Note that if this is set to true, it is generally advisable to also\n- * set the 'panIntoView' property to true so that the popup can be \n- * scrolled into view (since it will often be offscreen on open)\n- * Default is false.\n- */\n- fixedRelativePosition: false,\n-\n- /** \n- * Constructor: OpenLayers.Popup.Framed\n- * \n- * Parameters:\n- * id - {String}\n- * lonlat - {}\n- * contentSize - {}\n- * contentHTML - {String}\n- * anchor - {Object} Object to which we'll anchor the popup. Must expose \n- * a 'size' () and 'offset' () \n- * (Note that this is generally an ).\n- * closeBox - {Boolean}\n- * closeBoxCallback - {Function} Function to be called on closeBox click.\n- */\n- initialize: function(id, lonlat, contentSize, contentHTML, anchor, closeBox,\n- closeBoxCallback) {\n-\n- OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);\n-\n- if (this.fixedRelativePosition) {\n- //based on our decided relativePostion, set the current padding\n- // this keeps us from getting into trouble \n- this.updateRelativePosition();\n-\n- //make calculateRelativePosition always return the specified\n- // fixed position.\n- this.calculateRelativePosition = function(px) {\n- return this.relativePosition;\n- };\n- }\n-\n- this.contentDiv.style.position = \"absolute\";\n- this.contentDiv.style.zIndex = 1;\n-\n- if (closeBox) {\n- this.closeDiv.style.zIndex = 1;\n- }\n-\n- this.groupDiv.style.position = \"absolute\";\n- this.groupDiv.style.top = \"0px\";\n- this.groupDiv.style.left = \"0px\";\n- this.groupDiv.style.height = \"100%\";\n- this.groupDiv.style.width = \"100%\";\n- },\n-\n- /** \n- * APIMethod: destroy\n- */\n- destroy: function() {\n- this.imageSrc = null;\n- this.imageSize = null;\n- this.isAlphaImage = null;\n-\n- this.fixedRelativePosition = false;\n- this.positionBlocks = null;\n-\n- //remove our blocks\n- for (var i = 0; i < this.blocks.length; i++) {\n- var block = this.blocks[i];\n-\n- if (block.image) {\n- block.div.removeChild(block.image);\n- }\n- block.image = null;\n-\n- if (block.div) {\n- this.groupDiv.removeChild(block.div);\n- }\n- block.div = null;\n- }\n- this.blocks = null;\n-\n- OpenLayers.Popup.Anchored.prototype.destroy.apply(this, arguments);\n- },\n-\n- /**\n- * APIMethod: setBackgroundColor\n- */\n- setBackgroundColor: function(color) {\n- //does nothing since the framed popup's entire scheme is based on a \n- // an image -- changing the background color makes no sense. \n- },\n-\n- /**\n- * APIMethod: setBorder\n- */\n- setBorder: function() {\n- //does nothing since the framed popup's entire scheme is based on a \n- // an image -- changing the popup's border makes no sense. \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- //does nothing since we suppose that we'll never apply an opacity\n- // to a framed popup\n- },\n-\n- /**\n- * APIMethod: setSize\n- * Overridden here, because we need to update the blocks whenever the size\n- * of the popup has changed.\n- * \n- * Parameters:\n- * contentSize - {} the new size for the popup's \n- * contents div (in pixels).\n- */\n- setSize: function(contentSize) {\n- OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments);\n-\n- this.updateBlocks();\n- },\n-\n- /**\n- * Method: updateRelativePosition\n- * When the relative position changes, we need to set the new padding \n- * BBOX on the popup, reposition the close div, and update the blocks.\n- */\n- updateRelativePosition: function() {\n-\n- //update the padding\n- this.padding = this.positionBlocks[this.relativePosition].padding;\n-\n- //update the position of our close box to new padding\n- if (this.closeDiv) {\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 +\n- this.padding.right + \"px\";\n- this.closeDiv.style.top = contentDivPadding.top +\n- this.padding.top + \"px\";\n- }\n-\n- this.updateBlocks();\n- },\n-\n- /** \n- * Method: calculateNewPx\n- * Besides the standard offset as determined by the Anchored class, our \n- * Framed popups have a special 'offset' property for each of their \n- * positions, which is used to offset the popup relative to its anchor.\n- * \n- * Parameters:\n- * px - {}\n- * \n- * Returns:\n- * {} The the new px position of the popup on the screen\n- * relative to the passed-in px.\n- */\n- calculateNewPx: function(px) {\n- var newPx = OpenLayers.Popup.Anchored.prototype.calculateNewPx.apply(\n- this, arguments\n- );\n-\n- newPx = newPx.offset(this.positionBlocks[this.relativePosition].offset);\n-\n- return newPx;\n- },\n-\n- /**\n- * Method: createBlocks\n- */\n- createBlocks: function() {\n- this.blocks = [];\n-\n- //since all positions contain the same number of blocks, we can \n- // just pick the first position and use its blocks array to create\n- // our blocks array\n- var firstPosition = null;\n- for (var key in this.positionBlocks) {\n- firstPosition = key;\n- break;\n- }\n-\n- var position = this.positionBlocks[firstPosition];\n- for (var i = 0; i < position.blocks.length; i++) {\n-\n- var block = {};\n- this.blocks.push(block);\n-\n- var divId = this.id + '_FrameDecorationDiv_' + i;\n- block.div = OpenLayers.Util.createDiv(divId,\n- null, null, null, \"absolute\", null, \"hidden\", null\n- );\n-\n- var imgId = this.id + '_FrameDecorationImg_' + i;\n- var imageCreator =\n- (this.isAlphaImage) ? OpenLayers.Util.createAlphaImageDiv :\n- OpenLayers.Util.createImage;\n-\n- block.image = imageCreator(imgId,\n- null, this.imageSize, this.imageSrc,\n- \"absolute\", null, null, null\n- );\n-\n- block.div.appendChild(block.image);\n- this.groupDiv.appendChild(block.div);\n- }\n- },\n-\n- /**\n- * Method: updateBlocks\n- * Internal method, called on initialize and when the popup's relative\n- * position has changed. This function takes care of re-positioning\n- * the popup's blocks in their appropropriate places.\n- */\n- updateBlocks: function() {\n- if (!this.blocks) {\n- this.createBlocks();\n- }\n-\n- if (this.size && this.relativePosition) {\n- var position = this.positionBlocks[this.relativePosition];\n- for (var i = 0; i < position.blocks.length; i++) {\n-\n- var positionBlock = position.blocks[i];\n- var block = this.blocks[i];\n-\n- // adjust sizes\n- var l = positionBlock.anchor.left;\n- var b = positionBlock.anchor.bottom;\n- var r = positionBlock.anchor.right;\n- var t = positionBlock.anchor.top;\n-\n- //note that we use the isNaN() test here because if the \n- // size object is initialized with a \"auto\" parameter, the \n- // size constructor calls parseFloat() on the string, \n- // which will turn it into NaN\n- //\n- var w = (isNaN(positionBlock.size.w)) ? this.size.w - (r + l) :\n- positionBlock.size.w;\n-\n- var h = (isNaN(positionBlock.size.h)) ? this.size.h - (b + t) :\n- positionBlock.size.h;\n-\n- block.div.style.width = (w < 0 ? 0 : w) + 'px';\n- block.div.style.height = (h < 0 ? 0 : h) + 'px';\n-\n- block.div.style.left = (l != null) ? l + 'px' : '';\n- block.div.style.bottom = (b != null) ? b + 'px' : '';\n- block.div.style.right = (r != null) ? r + 'px' : '';\n- block.div.style.top = (t != null) ? t + 'px' : '';\n-\n- block.image.style.left = positionBlock.position.x + 'px';\n- block.image.style.top = positionBlock.position.y + 'px';\n- }\n-\n- this.contentDiv.style.left = this.padding.left + \"px\";\n- this.contentDiv.style.top = this.padding.top + \"px\";\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Popup.Framed\"\n- });\n-/* ======================================================================\n- OpenLayers/Popup/FramedCloud.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/Popup/Framed.js\n- * @requires OpenLayers/Util.js\n- * @requires OpenLayers/BaseTypes/Bounds.js\n- * @requires OpenLayers/BaseTypes/Pixel.js\n- * @requires OpenLayers/BaseTypes/Size.js\n- */\n-\n-/**\n- * Class: OpenLayers.Popup.FramedCloud\n- * \n- * Inherits from: \n- * - \n- */\n-OpenLayers.Popup.FramedCloud =\n- OpenLayers.Class(OpenLayers.Popup.Framed, {\n-\n- /** \n- * Property: contentDisplayClass\n- * {String} The CSS class of the popup content div.\n- */\n- contentDisplayClass: \"olFramedCloudPopupContent\",\n-\n- /**\n- * APIProperty: autoSize\n- * {Boolean} Framed Cloud is autosizing by default.\n- */\n- autoSize: true,\n-\n- /**\n- * APIProperty: panMapIfOutOfView\n- * {Boolean} Framed Cloud does pan into view by default.\n- */\n- panMapIfOutOfView: true,\n-\n- /**\n- * APIProperty: imageSize\n- * {}\n- */\n- imageSize: new OpenLayers.Size(1276, 736),\n-\n- /**\n- * APIProperty: isAlphaImage\n- * {Boolean} The FramedCloud does not use an alpha image (in honor of the \n- * good ie6 folk out there)\n- */\n- isAlphaImage: false,\n-\n- /** \n- * APIProperty: fixedRelativePosition\n- * {Boolean} The Framed Cloud popup works in just one fixed position.\n- */\n- fixedRelativePosition: false,\n-\n- /**\n- * Property: positionBlocks\n- * {Object} Hash of differen position blocks, keyed by relativePosition\n- * two-character code string (ie \"tl\", \"tr\", \"bl\", \"br\")\n- */\n- positionBlocks: {\n- \"tl\": {\n- 'offset': new OpenLayers.Pixel(44, 0),\n- 'padding': new OpenLayers.Bounds(8, 40, 8, 9),\n- 'blocks': [{ // top-left\n- size: new OpenLayers.Size('auto', 'auto'),\n- anchor: new OpenLayers.Bounds(0, 51, 22, 0),\n- position: new OpenLayers.Pixel(0, 0)\n- }, { //top-right\n- size: new OpenLayers.Size(22, 'auto'),\n- anchor: new OpenLayers.Bounds(null, 50, 0, 0),\n- position: new OpenLayers.Pixel(-1238, 0)\n- }, { //bottom-left\n- size: new OpenLayers.Size('auto', 19),\n- anchor: new OpenLayers.Bounds(0, 32, 22, null),\n- position: new OpenLayers.Pixel(0, -631)\n- }, { //bottom-right\n- size: new OpenLayers.Size(22, 18),\n- anchor: new OpenLayers.Bounds(null, 32, 0, null),\n- position: new OpenLayers.Pixel(-1238, -632)\n- }, { // stem\n- size: new OpenLayers.Size(81, 35),\n- anchor: new OpenLayers.Bounds(null, 0, 0, null),\n- position: new OpenLayers.Pixel(0, -688)\n- }]\n- },\n- \"tr\": {\n- 'offset': new OpenLayers.Pixel(-45, 0),\n- 'padding': new OpenLayers.Bounds(8, 40, 8, 9),\n- 'blocks': [{ // top-left\n- size: new OpenLayers.Size('auto', 'auto'),\n- anchor: new OpenLayers.Bounds(0, 51, 22, 0),\n- position: new OpenLayers.Pixel(0, 0)\n- }, { //top-right\n- size: new OpenLayers.Size(22, 'auto'),\n- anchor: new OpenLayers.Bounds(null, 50, 0, 0),\n- position: new OpenLayers.Pixel(-1238, 0)\n- }, { //bottom-left\n- size: new OpenLayers.Size('auto', 19),\n- anchor: new OpenLayers.Bounds(0, 32, 22, null),\n- position: new OpenLayers.Pixel(0, -631)\n- }, { //bottom-right\n- size: new OpenLayers.Size(22, 19),\n- anchor: new OpenLayers.Bounds(null, 32, 0, null),\n- position: new OpenLayers.Pixel(-1238, -631)\n- }, { // stem\n- size: new OpenLayers.Size(81, 35),\n- anchor: new OpenLayers.Bounds(0, 0, null, null),\n- position: new OpenLayers.Pixel(-215, -687)\n- }]\n- },\n- \"bl\": {\n- 'offset': new OpenLayers.Pixel(45, 0),\n- 'padding': new OpenLayers.Bounds(8, 9, 8, 40),\n- 'blocks': [{ // top-left\n- size: new OpenLayers.Size('auto', 'auto'),\n- anchor: new OpenLayers.Bounds(0, 21, 22, 32),\n- position: new OpenLayers.Pixel(0, 0)\n- }, { //top-right\n- size: new OpenLayers.Size(22, 'auto'),\n- anchor: new OpenLayers.Bounds(null, 21, 0, 32),\n- position: new OpenLayers.Pixel(-1238, 0)\n- }, { //bottom-left\n- size: new OpenLayers.Size('auto', 21),\n- anchor: new OpenLayers.Bounds(0, 0, 22, null),\n- position: new OpenLayers.Pixel(0, -629)\n- }, { //bottom-right\n- size: new OpenLayers.Size(22, 21),\n- anchor: new OpenLayers.Bounds(null, 0, 0, null),\n- position: new OpenLayers.Pixel(-1238, -629)\n- }, { // stem\n- size: new OpenLayers.Size(81, 33),\n- anchor: new OpenLayers.Bounds(null, null, 0, 0),\n- position: new OpenLayers.Pixel(-101, -674)\n- }]\n- },\n- \"br\": {\n- 'offset': new OpenLayers.Pixel(-44, 0),\n- 'padding': new OpenLayers.Bounds(8, 9, 8, 40),\n- 'blocks': [{ // top-left\n- size: new OpenLayers.Size('auto', 'auto'),\n- anchor: new OpenLayers.Bounds(0, 21, 22, 32),\n- position: new OpenLayers.Pixel(0, 0)\n- }, { //top-right\n- size: new OpenLayers.Size(22, 'auto'),\n- anchor: new OpenLayers.Bounds(null, 21, 0, 32),\n- position: new OpenLayers.Pixel(-1238, 0)\n- }, { //bottom-left\n- size: new OpenLayers.Size('auto', 21),\n- anchor: new OpenLayers.Bounds(0, 0, 22, null),\n- position: new OpenLayers.Pixel(0, -629)\n- }, { //bottom-right\n- size: new OpenLayers.Size(22, 21),\n- anchor: new OpenLayers.Bounds(null, 0, 0, null),\n- position: new OpenLayers.Pixel(-1238, -629)\n- }, { // stem\n- size: new OpenLayers.Size(81, 33),\n- anchor: new OpenLayers.Bounds(0, null, null, 0),\n- position: new OpenLayers.Pixel(-311, -674)\n- }]\n- }\n- },\n-\n- /**\n- * APIProperty: minSize\n- * {}\n- */\n- minSize: new OpenLayers.Size(105, 10),\n-\n- /**\n- * APIProperty: maxSize\n- * {}\n- */\n- maxSize: new OpenLayers.Size(1200, 660),\n-\n- /** \n- * Constructor: OpenLayers.Popup.FramedCloud\n- * \n- * Parameters:\n- * id - {String}\n- * lonlat - {}\n- * contentSize - {}\n- * contentHTML - {String}\n- * anchor - {Object} Object to which we'll anchor the popup. Must expose \n- * a 'size' () and 'offset' () \n- * (Note that this is generally an ).\n- * closeBox - {Boolean}\n- * closeBoxCallback - {Function} Function to be called on closeBox click.\n- */\n- initialize: function(id, lonlat, contentSize, contentHTML, anchor, closeBox,\n- closeBoxCallback) {\n-\n- this.imageSrc = OpenLayers.Util.getImageLocation('cloud-popup-relative.png');\n- OpenLayers.Popup.Framed.prototype.initialize.apply(this, arguments);\n- this.contentDiv.className = this.contentDisplayClass;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Popup.FramedCloud\"\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+ * APIMethod: supported\n+ * This should be overridden by specific subclasses\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+ * {Boolean} Whether or not the browser supports the renderer class\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+ supported: function() {\n+ return false;\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+ * Method: setExtent\n+ * Set the visible part of the layer.\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+ * 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 * Parameters:\n- * evt - {Event} The event\n+ * extent - {}\n+ * resolutionChanged - {Boolean}\n *\n * Returns:\n- * {Boolean} Let the event propagate.\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- 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+ 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- * 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+ * 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- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * size - {} \n */\n- touchstart: function(evt) {\n- this.startTouch();\n- return this.dragstart(evt);\n+ setSize: function(size) {\n+ this.size = size.clone();\n+ this.resolution = null;\n },\n \n- /**\n- * Method: mousemove\n- * Handle mousemove events\n- *\n- * Parameters:\n- * evt - {Event}\n- *\n+ /** \n+ * Method: getResolution\n+ * Uses cached copy of resolution if available to minimize computing\n+ * \n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {Float} The current map's resolution\n */\n- mousemove: function(evt) {\n- return this.dragmove(evt);\n+ getResolution: function() {\n+ this.resolution = this.resolution || this.map.getResolution();\n+ return this.resolution;\n },\n \n /**\n- * Method: touchmove\n- * Handle touchmove events\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- * evt - {Event}\n- *\n+ * feature - {} \n+ * style - {}\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+ * {Boolean} true if the feature has been drawn completely, false if not,\n+ * undefined if the feature had no geometry\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+ drawFeature: function(feature, style) {\n+ if (style == null) {\n+ style = feature.style;\n }\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- /**\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+ 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 },\n \n /**\n- * Method: touchend\n- * Handle touchend events\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- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * bounds - {} Bounds of the feature\n+ * worldBounds - {} Bounds of the world\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+ 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: mouseout\n- * Handle mouseout events\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- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * geometry - {} \n+ * style - {Object} \n+ * featureId - {} \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+ drawGeometry: function(geometry, style, featureId) {},\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+ * Method: drawText\n+ * Function for drawing text labels.\n+ * This method is only called by the renderer itself.\n * \n * Parameters: \n- * evt - {Event} \n- * \n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * featureId - {String}\n+ * style -\n+ * location - {}\n */\n- click: function(evt) {\n- // let the click event propagate only if the mouse moved\n- return (this.start == this.last);\n- },\n+ drawText: function(featureId, style, location) {},\n \n /**\n- * Method: activate\n- * Activate the handler.\n+ * Method: removeText\n+ * Function for removing text labels.\n+ * This method is only called by the renderer itself.\n * \n- * Returns:\n- * {Boolean} The handler was successfully activated.\n+ * Parameters: \n+ * featureId - {String}\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+ removeText: function(featureId) {},\n \n /**\n- * Method: deactivate \n- * Deactivate the handler.\n- * \n- * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * Method: clear\n+ * Clear all vectors from the renderer.\n+ * virtual function.\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+ clear: function() {},\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+ * 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 - {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/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- * @requires OpenLayers/Handler.js\n- * @requires OpenLayers/Handler/Drag.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- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {\n-\n- /** \n- * Property: dragHandler \n- * {} \n- */\n- dragHandler: null,\n-\n- /**\n- * APIProperty: boxDivClassName\n- * {String} The CSS class to use for drawing the box. Default is\n- * olHandlerBoxZoomBox\n- */\n- boxDivClassName: 'olHandlerBoxZoomBox',\n-\n- /**\n- * Property: boxOffsets\n- * {Object} Caches box offsets from css. This is used by the getBoxOffsets\n- * method.\n- */\n- boxOffsets: null,\n-\n- /**\n- * Constructor: OpenLayers.Handler.Box\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- */\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- },\n-\n- /**\n- * Method: destroy\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- },\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+ * evt - {} \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- return true;\n- } else {\n- return false;\n- }\n- },\n-\n- /**\n- * Method: deactivate\n- */\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: 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- */\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 this.boxOffsets;\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler.Box\"\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+ * {String} A feature id or undefined.\n */\n- observeElement: null,\n+ getFeatureIdFromEvent: function(evt) {},\n \n /**\n- * Constructor: OpenLayers.Handler.Keyboard\n- * Returns a new keyboard handler.\n+ * Method: eraseFeatures \n+ * This is called by the layer to erase features\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+ * features - {Array()} \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+ 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 /**\n- * Method: destroy\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- destroy: function() {\n- this.deactivate();\n- this.eventListener = null;\n- OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- },\n+ eraseGeometry: function(geometry, featureId) {},\n \n /**\n- * Method: activate\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- 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+ moveRoot: function(renderer) {},\n \n /**\n- * Method: deactivate\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- 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+ getRenderLayerId: function() {\n+ return this.container.id;\n },\n \n /**\n- * Method: handleKeyEvent \n+ * Method: applyDefaultSymbolizer\n+ * \n+ * Parameters:\n+ * symbolizer - {Object}\n+ * \n+ * Returns:\n+ * {Object}\n */\n- handleKeyEvent: function(evt) {\n- if (this.checkModifiers(evt)) {\n- this.callback(evt.type, [evt]);\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.Handler.Keyboard\"\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/Handler/Point.js\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 * full text of the license. */\n \n-\n /**\n- * @requires OpenLayers/Handler.js\n- * @requires OpenLayers/Geometry/Point.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Point\n- * Handler to draw a point on the map. Point is displayed on activation,\n- * moves on mouse move, and is finished on mouse up. The handler triggers\n- * callbacks for 'done', 'cancel', and 'modify'. The modify callback is\n- * called with each change in the sketch and will receive the latest point\n- * drawn. Create a new instance with the \n- * constructor.\n+ * Class: OpenLayers.Icon\n+ * \n+ * The icon represents a graphical icon on the screen. Typically used in\n+ * conjunction with a to represent markers on a screen.\n+ *\n+ * An icon has a url, size and position. It also contains an offset which \n+ * allows the center point to be represented correctly. This can be\n+ * provided either as a fixed offset or a function provided to calculate\n+ * the desired offset. \n * \n- * Inherits from:\n- * - \n */\n-OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {\n-\n- /**\n- * Property: point\n- * {} The currently drawn point\n- */\n- point: null,\n-\n- /**\n- * Property: layer\n- * {} The temporary drawing layer\n- */\n- layer: null,\n+OpenLayers.Icon = OpenLayers.Class({\n \n- /**\n- * APIProperty: multi\n- * {Boolean} Cast features to multi-part geometries before passing to the\n- * layer. Default is false.\n+ /** \n+ * Property: url \n+ * {String} image url\n */\n- multi: false,\n+ url: null,\n \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+ * Property: size \n+ * {|Object} An OpenLayers.Size or\n+ * an object with a 'w' and 'h' properties.\n */\n- citeCompliant: false,\n+ size: null,\n \n- /**\n- * Property: mouseDown\n- * {Boolean} The mouse is down\n+ /** \n+ * Property: offset \n+ * {|Object} distance in pixels to offset the\n+ * image when being rendered. An OpenLayers.Pixel or an object\n+ * with a 'x' and 'y' properties.\n */\n- mouseDown: false,\n+ offset: null,\n \n- /**\n- * Property: stoppedDown\n- * {Boolean} Indicate whether the last mousedown stopped the event\n- * propagation.\n+ /** \n+ * Property: calculateOffset \n+ * {Function} Function to calculate the offset (based on the size)\n */\n- stoppedDown: null,\n+ calculateOffset: null,\n \n- /**\n- * Property: lastDown\n- * {} Location of the last mouse down\n+ /** \n+ * Property: imageDiv \n+ * {DOMElement} \n */\n- lastDown: null,\n+ imageDiv: null,\n \n- /**\n- * Property: lastUp\n- * {}\n+ /** \n+ * Property: px \n+ * {|Object} An OpenLayers.Pixel or an object\n+ * with a 'x' and 'y' properties.\n */\n- lastUp: null,\n+ px: null,\n \n- /**\n- * APIProperty: persist\n- * {Boolean} Leave the feature rendered until destroyFeature is called.\n- * Default is false. If set to true, the feature remains rendered until\n- * destroyFeature is called, typically by deactivating the handler or\n- * starting another drawing.\n+ /** \n+ * Constructor: OpenLayers.Icon\n+ * Creates an icon, which is an image tag in a div. \n+ *\n+ * url - {String} \n+ * size - {|Object} An OpenLayers.Size or an\n+ * object with a 'w' and 'h'\n+ * properties.\n+ * offset - {|Object} An OpenLayers.Pixel or an\n+ * object with a 'x' and 'y'\n+ * properties.\n+ * calculateOffset - {Function} \n */\n- persist: false,\n+ initialize: function(url, size, offset, calculateOffset) {\n+ this.url = url;\n+ this.size = size || {\n+ w: 20,\n+ h: 20\n+ };\n+ this.offset = offset || {\n+ x: -(this.size.w / 2),\n+ y: -(this.size.h / 2)\n+ };\n+ this.calculateOffset = calculateOffset;\n \n- /**\n- * APIProperty: stopDown\n- * {Boolean} Stop event propagation on mousedown. Must be false to\n- * allow \"pan while drawing\". Defaults to false.\n- */\n- stopDown: false,\n+ var id = OpenLayers.Util.createUniqueID(\"OL_Icon_\");\n+ this.imageDiv = OpenLayers.Util.createAlphaImageDiv(id);\n+ },\n \n- /**\n- * APIPropery: stopUp\n- * {Boolean} Stop event propagation on mouse. Must be false to\n- * allow \"pan while dragging\". Defaults to fase.\n+ /** \n+ * Method: destroy\n+ * Nullify references and remove event listeners to prevent circular \n+ * references and memory leaks\n */\n- stopUp: false,\n+ destroy: function() {\n+ // erase any drawn elements\n+ this.erase();\n \n- /**\n- * Property: layerOptions\n- * {Object} Any optional properties to be set on the sketch layer.\n- */\n- layerOptions: null,\n+ OpenLayers.Event.stopObservingElement(this.imageDiv.firstChild);\n+ this.imageDiv.innerHTML = \"\";\n+ this.imageDiv = null;\n+ },\n \n- /**\n- * APIProperty: pixelTolerance\n- * {Number} Maximum number of pixels between down and up (mousedown\n- * and mouseup, or touchstart and touchend) for the handler to\n- * add a new point. If set to an integer value, if the\n- * displacement between down and up is great to this value\n- * no point will be added. Default value is 5.\n+ /** \n+ * Method: clone\n+ * \n+ * Returns:\n+ * {} A fresh copy of the icon.\n */\n- pixelTolerance: 5,\n+ clone: function() {\n+ return new OpenLayers.Icon(this.url,\n+ this.size,\n+ this.offset,\n+ this.calculateOffset);\n+ },\n \n /**\n- * Property: lastTouchPx\n- * {} The last pixel used to know the distance between\n- * two touches (for double touch).\n+ * Method: setSize\n+ * \n+ * Parameters:\n+ * size - {|Object} An OpenLayers.Size or\n+ * an object with a 'w' and 'h' properties.\n */\n- lastTouchPx: null,\n+ setSize: function(size) {\n+ if (size != null) {\n+ this.size = size;\n+ }\n+ this.draw();\n+ },\n \n /**\n- * Constructor: OpenLayers.Handler.Point\n- * Create a new point handler.\n- *\n+ * Method: setUrl\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- * done - Called when the point drawing is finished. The callback will\n- * recieve a single argument, the point geometry.\n- * cancel - Called when the handler is deactivated while drawing. The\n- * cancel callback will receive a geometry.\n+ * url - {String} \n */\n- initialize: function(control, callbacks, options) {\n- if (!(options && options.layerOptions && options.layerOptions.styleMap)) {\n- this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {});\n+ setUrl: function(url) {\n+ if (url != null) {\n+ this.url = url;\n }\n+ this.draw();\n+ },\n \n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n+ /** \n+ * Method: draw\n+ * Move the div to the given pixel.\n+ * \n+ * Parameters:\n+ * px - {|Object} An OpenLayers.Pixel or an\n+ * object with a 'x' and 'y' properties.\n+ * \n+ * Returns:\n+ * {DOMElement} A new DOM Image of this icon set at the location passed-in\n+ */\n+ draw: function(px) {\n+ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,\n+ null,\n+ null,\n+ this.size,\n+ this.url,\n+ \"absolute\");\n+ this.moveTo(px);\n+ return this.imageDiv;\n },\n \n- /**\n- * APIMethod: activate\n- * turn on the handler\n+ /** \n+ * Method: erase\n+ * Erase the underlying image element.\n */\n- activate: function() {\n- if (!OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- return false;\n+ erase: function() {\n+ if (this.imageDiv != null && this.imageDiv.parentNode != null) {\n+ OpenLayers.Element.remove(this.imageDiv);\n }\n- // create temporary vector layer for rendering geometry sketch\n- // TBD: this could be moved to initialize/destroy - setting visibility here\n- var options = OpenLayers.Util.extend({\n- displayInLayerSwitcher: false,\n- // indicate that the temp vector layer will never be out of range\n- // without this, resolution properties must be specified at the\n- // map-level for this temporary layer to init its resolutions\n- // correctly\n- calculateInRange: OpenLayers.Function.True,\n- wrapDateLine: this.citeCompliant\n- }, this.layerOptions);\n- this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);\n- this.map.addLayer(this.layer);\n- return true;\n },\n \n- /**\n- * Method: createFeature\n- * Add temporary features\n+ /** \n+ * Method: setOpacity\n+ * Change the icon's opacity\n *\n * Parameters:\n- * pixel - {} A pixel location on the map.\n+ * opacity - {float} \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.callback(\"create\", [this.point.geometry, this.point]);\n- this.point.geometry.clearBounds();\n- this.layer.addFeatures([this.point], {\n- silent: true\n- });\n+ setOpacity: function(opacity) {\n+ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, null, null,\n+ null, null, null, null, opacity);\n+\n },\n \n /**\n- * APIMethod: deactivate\n- * turn off the handler\n+ * Method: moveTo\n+ * move icon to passed in px.\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- deactivate: function() {\n- if (!OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- return false;\n+ moveTo: function(px) {\n+ //if no px passed in, use stored location\n+ if (px != null) {\n+ this.px = px;\n }\n- this.cancel();\n- // If a layer's map property is set to null, it means that that layer\n- // isn't added to the map. Since we ourself added the layer to the map\n- // in activate(), we can assume that if this.layer.map is null it means\n- // that the layer has been destroyed (as a result of map.destroy() for\n- // example.\n- if (this.layer.map != null) {\n- this.destroyFeature(true);\n- this.layer.destroy(false);\n+\n+ if (this.imageDiv != null) {\n+ if (this.px == null) {\n+ this.display(false);\n+ } else {\n+ if (this.calculateOffset) {\n+ this.offset = this.calculateOffset(this.size);\n+ }\n+ OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, {\n+ x: this.px.x + this.offset.x,\n+ y: this.px.y + this.offset.y\n+ });\n+ }\n }\n- this.layer = null;\n- return true;\n },\n \n- /**\n- * Method: destroyFeature\n- * Destroy the temporary geometries\n+ /** \n+ * Method: display\n+ * Hide or show the icon\n *\n * Parameters:\n- * force - {Boolean} Destroy even if persist is true.\n+ * display - {Boolean} \n */\n- destroyFeature: function(force) {\n- if (this.layer && (force || !this.persist)) {\n- this.layer.destroyFeatures();\n- }\n- this.point = null;\n+ display: function(display) {\n+ this.imageDiv.style.display = (display) ? \"\" : \"none\";\n },\n \n+\n /**\n- * Method: destroyPersistedFeature\n- * Destroy the persisted feature.\n+ * APIMethod: isDrawn\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the icon is drawn.\n */\n- destroyPersistedFeature: function() {\n- var layer = this.layer;\n- if (layer && layer.features.length > 1) {\n- this.layer.features[0].destroy();\n- }\n+ isDrawn: function() {\n+ // nodeType 11 for ie, whose nodes *always* have a parentNode\n+ // (of type document fragment)\n+ var isDrawn = (this.imageDiv && this.imageDiv.parentNode &&\n+ (this.imageDiv.parentNode.nodeType != 11));\n+\n+ return isDrawn;\n },\n \n- /**\n- * Method: finalize\n- * Finish the geometry and call the \"done\" callback.\n+ CLASS_NAME: \"OpenLayers.Icon\"\n+});\n+/* ======================================================================\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.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- * cancel - {Boolean} Call cancel instead of done callback. Default\n- * is false.\n+ * lonlat - {} the position of this marker\n+ * icon - {} the icon for this marker\n */\n- finalize: function(cancel) {\n- var key = cancel ? \"cancel\" : \"done\";\n- this.mouseDown = false;\n- this.lastDown = null;\n- this.lastUp = null;\n- this.lastTouchPx = null;\n- this.callback(key, [this.geometryClone()]);\n- this.destroyFeature(cancel);\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: cancel\n- * Finish the geometry and call the \"cancel\" callback.\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- cancel: function() {\n- this.finalize(true);\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: click\n- * Handle clicks. Clicks are stopped from propagating to other listeners\n- * on map.events or other dom elements.\n+ /** \n+ * Method: draw\n+ * Calls draw on the icon, and returns that output.\n * \n * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\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- click: function(evt) {\n- OpenLayers.Event.stop(evt);\n- return false;\n+ draw: function(px) {\n+ return this.icon.draw(px);\n },\n \n- /**\n- * Method: dblclick\n- * Handle double-clicks. Double-clicks are stopped from propagating to other\n- * listeners on map.events or other dom elements.\n- * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ /** \n+ * Method: erase\n+ * Erases any drawn elements for this marker.\n */\n- dblclick: function(evt) {\n- OpenLayers.Event.stop(evt);\n- return false;\n+ erase: function() {\n+ if (this.icon != null) {\n+ this.icon.erase();\n+ }\n },\n \n /**\n- * Method: modifyFeature\n- * Modify the existing geometry given a pixel location.\n+ * Method: moveTo\n+ * Move the marker to the new location.\n *\n * Parameters:\n- * pixel - {} A pixel location on the map.\n+ * px - {|Object} the pixel position to move to.\n+ * An OpenLayers.Pixel or an object with a 'x' and 'y' properties.\n */\n- modifyFeature: function(pixel) {\n- if (!this.point) {\n- this.createFeature(pixel);\n+ moveTo: function(px) {\n+ if ((px != null) && (this.icon != null)) {\n+ this.icon.moveTo(px);\n }\n- var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n- this.point.geometry.x = lonlat.lon;\n- this.point.geometry.y = lonlat.lat;\n- this.callback(\"modify\", [this.point.geometry, this.point, false]);\n- this.point.geometry.clearBounds();\n- this.drawFeature();\n+ this.lonlat = this.map.getLonLatFromLayerPx(px);\n },\n \n /**\n- * Method: drawFeature\n- * Render features on the temporary layer.\n+ * APIMethod: isDrawn\n+ * \n+ * Returns:\n+ * {Boolean} Whether or not the marker is drawn.\n */\n- drawFeature: function() {\n- this.layer.drawFeature(this.point, this.style);\n+ isDrawn: function() {\n+ var isDrawn = (this.icon && this.icon.isDrawn());\n+ return isDrawn;\n },\n \n /**\n- * Method: getGeometry\n- * Return the sketch geometry. If is true, this will return\n- * a multi-part geometry.\n+ * Method: onScreen\n *\n * Returns:\n- * {}\n+ * {Boolean} Whether or not the marker is currently visible on screen.\n */\n- getGeometry: function() {\n- var geometry = this.point && this.point.geometry;\n- if (geometry && this.multi) {\n- geometry = new OpenLayers.Geometry.MultiPoint([geometry]);\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 geometry;\n+ return onScreen;\n },\n \n /**\n- * Method: geometryClone\n- * Return a clone of the relevant geometry.\n+ * Method: inflate\n+ * Englarges the markers icon by the specified ratio.\n *\n- * Returns:\n- * {}\n+ * Parameters:\n+ * inflate - {float} the ratio to enlarge the marker by (passing 2\n+ * will double the size).\n */\n- geometryClone: function() {\n- var geom = this.getGeometry();\n- return geom && geom.clone();\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: mousedown\n- * Handle mousedown.\n+ /** \n+ * Method: setOpacity\n+ * Change the opacity of the marker by changin the opacity of \n+ * its icon\n * \n * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * opacity - {float} Specified as fraction (0.4, etc)\n */\n- mousedown: function(evt) {\n- return this.down(evt);\n+ setOpacity: function(opacity) {\n+ this.icon.setOpacity(opacity);\n },\n \n /**\n- * Method: touchstart\n- * Handle touchstart.\n+ * Method: setUrl\n+ * Change URL of the Icon Image.\n * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * url - {String} \n */\n- touchstart: function(evt) {\n- this.startTouch();\n- this.lastTouchPx = evt.xy;\n- return this.down(evt);\n+ setUrl: function(url) {\n+ this.icon.setUrl(url);\n },\n \n- /**\n- * Method: mousemove\n- * Handle mousemove.\n+ /** \n+ * Method: display\n+ * Hide or show the icon\n * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * display - {Boolean} \n */\n- mousemove: function(evt) {\n- return this.move(evt);\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/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+ * full text of the license. */\n+\n+\n+/**\n+ * @requires OpenLayers/Layer.js\n+ */\n+\n+/**\n+ * Class: OpenLayers.Layer.HTTPRequest\n+ * \n+ * Inherits from: \n+ * - \n+ */\n+OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {\n+\n+ /** \n+ * Constant: URL_HASH_FACTOR\n+ * {Float} Used to hash URL param strings for multi-WMS server selection.\n+ * Set to the Golden Ratio per Knuth's recommendation.\n+ */\n+ URL_HASH_FACTOR: (Math.sqrt(5) - 1) / 2,\n+\n+ /** \n+ * Property: url\n+ * {Array(String) or String} This is either an array of url strings or \n+ * a single url string. \n+ */\n+ url: null,\n+\n+ /** \n+ * Property: params\n+ * {Object} Hashtable of key/value parameters\n+ */\n+ params: null,\n+\n+ /** \n+ * APIProperty: reproject\n+ * *Deprecated*. See http://docs.openlayers.org/library/spherical_mercator.html\n+ * for information on the replacement for this functionality. \n+ * {Boolean} Whether layer should reproject itself based on base layer \n+ * locations. This allows reprojection onto commercial layers. \n+ * Default is false: Most layers can't reproject, but layers \n+ * which can create non-square geographic pixels can, like WMS.\n+ * \n+ */\n+ reproject: false,\n+\n /**\n- * Method: touchmove\n- * Handle touchmove.\n+ * Constructor: OpenLayers.Layer.HTTPRequest\n * \n * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * name - {String}\n+ * url - {Array(String) or String}\n+ * params - {Object}\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n */\n- touchmove: function(evt) {\n- this.lastTouchPx = evt.xy;\n- return this.move(evt);\n+ initialize: function(name, url, params, options) {\n+ OpenLayers.Layer.prototype.initialize.apply(this, [name, options]);\n+ this.url = url;\n+ if (!this.params) {\n+ this.params = OpenLayers.Util.extend({}, params);\n+ }\n },\n \n /**\n- * Method: mouseup\n- * Handle mouseup.\n- * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * APIMethod: destroy\n */\n- mouseup: function(evt) {\n- return this.up(evt);\n+ destroy: function() {\n+ this.url = null;\n+ this.params = null;\n+ OpenLayers.Layer.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: touchend\n- * Handle touchend.\n+ * APIMethod: clone\n * \n * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * obj - {Object}\n+ * \n+ * Returns:\n+ * {} An exact clone of this \n+ * \n */\n- touchend: function(evt) {\n- evt.xy = this.lastTouchPx;\n- return this.up(evt);\n+ clone: function(obj) {\n+\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer.HTTPRequest(this.name,\n+ this.url,\n+ this.params,\n+ 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+\n+ return obj;\n },\n \n- /**\n- * Method: down\n- * Handle mousedown and touchstart. Adjust the geometry and redraw.\n- * Return determines whether to propagate the event on the map.\n+ /** \n+ * APIMethod: setUrl\n * \n * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * newUrl - {String}\n */\n- down: function(evt) {\n- this.mouseDown = true;\n- this.lastDown = evt.xy;\n- if (!this.touch) { // no point displayed until up on touch devices\n- this.modifyFeature(evt.xy);\n- }\n- this.stoppedDown = this.stopDown;\n- return !this.stopDown;\n+ setUrl: function(newUrl) {\n+ this.url = newUrl;\n },\n \n /**\n- * Method: move\n- * Handle mousemove and touchmove. Adjust the geometry and redraw.\n- * Return determines whether to propagate the event on the map.\n+ * APIMethod: mergeNewParams\n * \n * Parameters:\n- * evt - {Event} The browser event\n+ * newParams - {Object}\n *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * Returns:\n+ * redrawn: {Boolean} whether the layer was actually redrawn.\n */\n- move: function(evt) {\n- if (!this.touch // no point displayed until up on touch devices\n- &&\n- (!this.mouseDown || this.stoppedDown)) {\n- this.modifyFeature(evt.xy);\n+ mergeNewParams: function(newParams) {\n+ this.params = OpenLayers.Util.extend(this.params, newParams);\n+ var ret = this.redraw();\n+ if (this.map != null) {\n+ this.map.events.triggerEvent(\"changelayer\", {\n+ layer: this,\n+ property: \"params\"\n+ });\n }\n- return true;\n+ return ret;\n },\n \n /**\n- * Method: up\n- * Handle mouseup and touchend. Send the latest point in the geometry to the control.\n- * Return determines whether to propagate the event on the map.\n+ * APIMethod: redraw\n+ * Redraws the layer. Returns true if the layer was redrawn, false if not.\n *\n * Parameters:\n- * evt - {Event} The browser event\n+ * force - {Boolean} Force redraw by adding random parameter.\n *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * Returns:\n+ * {Boolean} The layer was redrawn.\n */\n- up: function(evt) {\n- this.mouseDown = false;\n- this.stoppedDown = this.stopDown;\n-\n- // check keyboard modifiers\n- if (!this.checkModifiers(evt)) {\n- return true;\n- }\n- // ignore double-clicks\n- if (this.lastUp && this.lastUp.equals(evt.xy)) {\n- return true;\n- }\n- if (this.lastDown && this.passesTolerance(this.lastDown, evt.xy,\n- this.pixelTolerance)) {\n- if (this.touch) {\n- this.modifyFeature(evt.xy);\n- }\n- if (this.persist) {\n- this.destroyPersistedFeature();\n- }\n- this.lastUp = evt.xy;\n- this.finalize();\n- return !this.stopUp;\n+ redraw: function(force) {\n+ if (force) {\n+ return this.mergeNewParams({\n+ \"_olSalt\": Math.random()\n+ });\n } else {\n- return true;\n+ return OpenLayers.Layer.prototype.redraw.apply(this, []);\n }\n },\n \n /**\n- * Method: mouseout\n- * Handle mouse out. For better user experience reset mouseDown\n- * and stoppedDown when the mouse leaves the map viewport.\n+ * Method: selectUrl\n+ * selectUrl() implements the standard floating-point multiplicative\n+ * hash function described by Knuth, and hashes the contents of the \n+ * given param string into a float between 0 and 1. This float is then\n+ * scaled to the size of the provided urls array, and used to select\n+ * a URL.\n *\n * Parameters:\n- * evt - {Event} The browser event\n+ * paramString - {String}\n+ * urls - {Array(String)}\n+ * \n+ * Returns:\n+ * {String} An entry from the urls array, deterministically selected based\n+ * on the paramString.\n */\n- mouseout: function(evt) {\n- if (OpenLayers.Util.mouseLeft(evt, this.map.viewPortDiv)) {\n- this.stoppedDown = this.stopDown;\n- this.mouseDown = false;\n+ selectUrl: function(paramString, urls) {\n+ var product = 1;\n+ for (var i = 0, len = paramString.length; i < len; i++) {\n+ product *= paramString.charCodeAt(i) * this.URL_HASH_FACTOR;\n+ product -= Math.floor(product);\n }\n+ return urls[Math.floor(product * urls.length)];\n },\n \n- /**\n- * Method: passesTolerance\n- * Determine whether the event is within the optional pixel tolerance.\n+ /** \n+ * Method: getFullRequestString\n+ * Combine url with layer's params and these newParams. \n+ * \n+ * does checking on the serverPath variable, allowing for cases when it \n+ * is supplied with trailing ? or &, as well as cases where not. \n *\n- * Returns:\n- * {Boolean} The event is within the pixel tolerance (if specified).\n+ * return in formatted string like this:\n+ * \"server?key1=value1&key2=value2&key3=value3\"\n+ * \n+ * WARNING: The altUrl parameter is deprecated and will be removed in 3.0.\n+ *\n+ * Parameters:\n+ * newParams - {Object}\n+ * altUrl - {String} Use this as the url instead of the layer's url\n+ * \n+ * Returns: \n+ * {String}\n */\n- passesTolerance: function(pixel1, pixel2, tolerance) {\n- var passes = true;\n+ getFullRequestString: function(newParams, altUrl) {\n \n- if (tolerance != null && pixel1 && pixel2) {\n- var dist = pixel1.distanceTo(pixel2);\n- if (dist > tolerance) {\n- passes = false;\n+ // if not altUrl passed in, use layer's url\n+ var url = altUrl || this.url;\n+\n+ // create a new params hashtable with all the layer params and the \n+ // new params together. then convert to string\n+ var allParams = OpenLayers.Util.extend({}, this.params);\n+ allParams = OpenLayers.Util.extend(allParams, newParams);\n+ var paramsString = OpenLayers.Util.getParameterString(allParams);\n+\n+ // if url is not a string, it should be an array of strings, \n+ // in which case we will deterministically select one of them in \n+ // order to evenly distribute requests to different urls.\n+ //\n+ if (OpenLayers.Util.isArray(url)) {\n+ url = this.selectUrl(paramsString, url);\n+ }\n+\n+ // ignore parameters that are already in the url search string\n+ var urlParams =\n+ OpenLayers.Util.upperCaseObject(OpenLayers.Util.getParameters(url));\n+ for (var key in allParams) {\n+ if (key.toUpperCase() in urlParams) {\n+ delete allParams[key];\n }\n }\n- return passes;\n+ paramsString = OpenLayers.Util.getParameterString(allParams);\n+\n+ return OpenLayers.Util.urlAppend(url, paramsString);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Point\"\n+ CLASS_NAME: \"OpenLayers.Layer.HTTPRequest\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Path.js\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 \n \n /**\n- * @requires OpenLayers/Handler/Point.js\n- * @requires OpenLayers/Geometry/Point.js\n- * @requires OpenLayers/Geometry/LineString.js\n+ * @requires OpenLayers/Tile.js\n+ * @requires OpenLayers/Animation.js\n+ * @requires OpenLayers/Util.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Path\n- * Handler to draw a path on the map. Path is displayed on mouse down,\n- * moves on mouse move, and is finished on mouse up.\n+ * Class: OpenLayers.Tile.Image\n+ * Instances of OpenLayers.Tile.Image are used to manage the image tiles\n+ * used by various layers. Create a new image tile with the\n+ * constructor.\n *\n * Inherits from:\n- * - \n+ * - \n */\n-OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {\n+OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {\n \n /**\n- * Property: line\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 (in addition to the events):\n+ * beforeload - Triggered before an image is prepared for loading, when the\n+ * url for the image is known already. Listeners may call on\n+ * the tile instance. If they do so, that image will be used and no new\n+ * one will be created.\n */\n- line: null,\n \n- /**\n- * APIProperty: maxVertices\n- * {Number} The maximum number of vertices which can be drawn by this\n- * handler. When the number of vertices reaches maxVertices, the\n- * geometry is automatically finalized. Default is null.\n+ /** \n+ * APIProperty: url\n+ * {String} The URL of the image being requested. No default. Filled in by\n+ * layer.getURL() function. May be modified by loadstart listeners.\n */\n- maxVertices: null,\n+ url: null,\n \n- /**\n- * Property: doubleTouchTolerance\n- * {Number} Maximum number of pixels between two touches for\n- * the gesture to be considered a \"finalize feature\" action.\n- * Default is 20.\n+ /** \n+ * Property: imgDiv\n+ * {HTMLImageElement} The image for this tile.\n */\n- doubleTouchTolerance: 20,\n+ imgDiv: null,\n \n /**\n- * Property: freehand\n- * {Boolean} In freehand mode, the handler starts the path on mouse down,\n- * adds a point for every mouse move, and finishes the path on mouse up.\n- * Outside of freehand mode, a point is added to the path on every mouse\n- * click and double-click finishes the path.\n+ * Property: frame\n+ * {DOMElement} The image element is appended to the frame. Any gutter on\n+ * the image will be hidden behind the frame. If no gutter is set,\n+ * this will be null.\n */\n- freehand: false,\n+ frame: null,\n \n- /**\n- * Property: freehandToggle\n- * {String} If set, freehandToggle is checked on mouse events and will set\n- * the freehand mode to the opposite of this.freehand. To disallow\n- * toggling between freehand and non-freehand mode, set freehandToggle to\n- * null. Acceptable toggle values are 'shiftKey', 'ctrlKey', and 'altKey'.\n+ /** \n+ * Property: imageReloadAttempts\n+ * {Integer} Attempts to load the image.\n */\n- freehandToggle: 'shiftKey',\n+ imageReloadAttempts: null,\n \n /**\n- * Property: timerId\n- * {Integer} The timer used to test the double touch.\n+ * Property: layerAlphaHack\n+ * {Boolean} True if the png alpha hack needs to be applied on the layer's div.\n */\n- timerId: null,\n+ layerAlphaHack: null,\n \n /**\n- * Property: redoStack\n- * {Array} Stack containing points removed with .\n+ * Property: asyncRequestId\n+ * {Integer} ID of an request to see if request is still valid. This is a\n+ * number which increments by 1 for each asynchronous request.\n */\n- redoStack: null,\n+ asyncRequestId: null,\n \n /**\n- * Constructor: OpenLayers.Handler.Path\n- * Create a new path hander\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+ * APIProperty: maxGetUrlLength\n+ * {Number} If set, requests that would result in GET urls with more\n+ * characters than the number provided will be made using form-encoded\n+ * HTTP POST. It is good practice to avoid urls that are longer than 2048\n+ * characters.\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 linestring geometry.\n- * cancel - Called when the handler is deactivated while drawing. The\n- * cancel callback will receive a geometry.\n+ * Caution:\n+ * Older versions of Gecko based browsers (e.g. Firefox < 3.5) and most\n+ * Opera versions do not fully support this option. On all browsers,\n+ * transition effects are not supported if POST requests are used.\n */\n+ maxGetUrlLength: null,\n \n /**\n- * Method: createFeature\n- * Add temporary geometries\n- *\n- * Parameters:\n- * pixel - {} The initial pixel location for the new\n- * feature.\n+ * Property: canvasContext\n+ * {CanvasRenderingContext2D} A canvas context associated with\n+ * the tile image.\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.LineString([this.point.geometry])\n- );\n- this.callback(\"create\", [this.point.geometry, this.getSketch()]);\n- this.point.geometry.clearBounds();\n- this.layer.addFeatures([this.line, this.point], {\n- silent: true\n- });\n- },\n+ canvasContext: null,\n \n /**\n- * Method: destroyFeature\n- * Destroy temporary geometries\n- *\n- * Parameters:\n- * force - {Boolean} Destroy even if persist is true.\n+ * APIProperty: crossOriginKeyword\n+ * The value of the crossorigin keyword to use when loading images. This is\n+ * only relevant when using for tiles from remote\n+ * origins and should be set to either 'anonymous' or 'use-credentials'\n+ * for servers that send Access-Control-Allow-Origin headers with their\n+ * tiles.\n */\n- destroyFeature: function(force) {\n- OpenLayers.Handler.Point.prototype.destroyFeature.call(\n- this, force);\n- this.line = null;\n- },\n+ crossOriginKeyword: null,\n \n- /**\n- * Method: destroyPersistedFeature\n- * Destroy the persisted feature.\n+ /** TBD 3.0 - reorder the parameters to the init function to remove \n+ * URL. the getUrl() function on the layer gets called on \n+ * each draw(), so no need to specify it here.\n */\n- destroyPersistedFeature: function() {\n- var layer = this.layer;\n- if (layer && layer.features.length > 2) {\n- this.layer.features[0].destroy();\n- }\n- },\n \n- /**\n- * Method: removePoint\n- * Destroy the temporary point.\n+ /** \n+ * Constructor: OpenLayers.Tile.Image\n+ * Constructor for a new instance.\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- removePoint: function() {\n- if (this.point) {\n- this.layer.removeFeatures([this.point]);\n+ initialize: function(layer, position, bounds, url, size, options) {\n+ OpenLayers.Tile.prototype.initialize.apply(this, arguments);\n+\n+ this.url = url; //deprecated remove me\n+\n+ this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();\n+\n+ if (this.maxGetUrlLength != null || this.layer.gutter || this.layerAlphaHack) {\n+ // only create frame if it's needed\n+ this.frame = document.createElement(\"div\");\n+ this.frame.style.position = \"absolute\";\n+ this.frame.style.overflow = \"hidden\";\n+ }\n+ if (this.maxGetUrlLength != null) {\n+ OpenLayers.Util.extend(this, OpenLayers.Tile.Image.IFrame);\n }\n },\n \n- /**\n- * Method: addPoint\n- * Add point to geometry. Send the point index to override\n- * the behavior of LinearRing that disregards adding duplicate points.\n- *\n- * Parameters:\n- * pixel - {} The pixel location for the new point.\n+ /** \n+ * APIMethod: destroy\n+ * nullify references to prevent circular references and memory leaks\n */\n- addPoint: function(pixel) {\n- this.layer.removeFeatures([this.point]);\n- var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n- this.point = new OpenLayers.Feature.Vector(\n- new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)\n- );\n- this.line.geometry.addComponent(\n- this.point.geometry, this.line.geometry.components.length\n- );\n- this.layer.addFeatures([this.point]);\n- this.callback(\"point\", [this.point.geometry, this.getGeometry()]);\n- this.callback(\"modify\", [this.point.geometry, this.getSketch()]);\n- this.drawFeature();\n- delete this.redoStack;\n+ destroy: function() {\n+ if (this.imgDiv) {\n+ this.clear();\n+ this.imgDiv = null;\n+ this.frame = null;\n+ }\n+ // don't handle async requests any more\n+ this.asyncRequestId = null;\n+ OpenLayers.Tile.prototype.destroy.apply(this, arguments);\n },\n \n /**\n- * Method: insertXY\n- * Insert a point in the current sketch given x & y coordinates. The new\n- * point is inserted immediately before the most recently drawn point.\n- *\n- * Parameters:\n- * x - {Number} The x-coordinate of the point.\n- * y - {Number} The y-coordinate of the point.\n+ * Method: draw\n+ * Check that a tile should be drawn, and draw it.\n+ * \n+ * Returns:\n+ * {Boolean} Was a tile drawn? Or null if a beforedraw listener returned\n+ * false.\n */\n- insertXY: function(x, y) {\n- this.line.geometry.addComponent(\n- new OpenLayers.Geometry.Point(x, y),\n- this.getCurrentPointIndex()\n- );\n- this.drawFeature();\n- delete this.redoStack;\n+ draw: function() {\n+ var shouldDraw = OpenLayers.Tile.prototype.draw.apply(this, arguments);\n+ if (shouldDraw) {\n+ // The layer's reproject option is deprecated.\n+ if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {\n+ // getBoundsFromBaseLayer is defined in deprecated.js.\n+ this.bounds = this.getBoundsFromBaseLayer(this.position);\n+ }\n+ if (this.isLoading) {\n+ //if we're already loading, send 'reload' instead of 'loadstart'.\n+ this._loadEvent = \"reload\";\n+ } else {\n+ this.isLoading = true;\n+ this._loadEvent = \"loadstart\";\n+ }\n+ this.renderTile();\n+ this.positionTile();\n+ } else if (shouldDraw === false) {\n+ this.unload();\n+ }\n+ return shouldDraw;\n },\n \n /**\n- * Method: 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+ * Method: renderTile\n+ * Internal function to actually initialize the image tile,\n+ * position it correctly, and set its url.\n */\n- insertDeltaXY: function(dx, dy) {\n- var previousIndex = this.getCurrentPointIndex() - 1;\n- var p0 = this.line.geometry.components[previousIndex];\n- if (p0 && !isNaN(p0.x) && !isNaN(p0.y)) {\n- this.insertXY(p0.x + dx, p0.y + dy);\n+ renderTile: function() {\n+ if (this.layer.async) {\n+ // Asynchronous image requests call the asynchronous getURL method\n+ // on the layer to fetch an image that covers 'this.bounds'.\n+ var id = this.asyncRequestId = (this.asyncRequestId || 0) + 1;\n+ this.layer.getURLasync(this.bounds, function(url) {\n+ if (id == this.asyncRequestId) {\n+ this.url = url;\n+ this.initImage();\n+ }\n+ }, this);\n+ } else {\n+ // synchronous image requests get the url immediately.\n+ this.url = this.layer.getURL(this.bounds);\n+ this.initImage();\n }\n },\n \n /**\n- * Method: 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+ * Method: positionTile\n+ * Using the properties currenty set on the layer, position the tile correctly.\n+ * This method is used both by the async and non-async versions of the Tile.Image\n+ * code.\n */\n- insertDirectionLength: function(direction, length) {\n- direction *= Math.PI / 180;\n- var dx = length * Math.cos(direction);\n- var dy = length * Math.sin(direction);\n- this.insertDeltaXY(dx, dy);\n+ positionTile: function() {\n+ var style = this.getTile().style,\n+ size = this.frame ? this.size :\n+ this.layer.getImageSize(this.bounds),\n+ ratio = 1;\n+ if (this.layer instanceof OpenLayers.Layer.Grid) {\n+ ratio = this.layer.getServerResolution() / this.layer.map.getResolution();\n+ }\n+ style.left = this.position.x + \"px\";\n+ style.top = this.position.y + \"px\";\n+ style.width = Math.round(ratio * size.w) + \"px\";\n+ style.height = Math.round(ratio * size.h) + \"px\";\n },\n \n- /**\n- * Method: 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+ * Method: clear\n+ * Remove the tile from the DOM, clear it of any image related data so that\n+ * it can be reused in a new location.\n */\n- insertDeflectionLength: function(deflection, length) {\n- var previousIndex = this.getCurrentPointIndex() - 1;\n- if (previousIndex > 0) {\n- var p1 = this.line.geometry.components[previousIndex];\n- var p0 = this.line.geometry.components[previousIndex - 1];\n- var theta = Math.atan2(p1.y - p0.y, p1.x - p0.x);\n- this.insertDirectionLength(\n- (theta * 180 / Math.PI) + deflection, length\n- );\n+ clear: function() {\n+ OpenLayers.Tile.prototype.clear.apply(this, arguments);\n+ var img = this.imgDiv;\n+ if (img) {\n+ var tile = this.getTile();\n+ if (tile.parentNode === this.layer.div) {\n+ this.layer.div.removeChild(tile);\n+ }\n+ this.setImgSrc();\n+ if (this.layerAlphaHack === true) {\n+ img.style.filter = \"\";\n+ }\n+ OpenLayers.Element.removeClass(img, \"olImageLoadError\");\n }\n+ this.canvasContext = null;\n },\n \n /**\n- * Method: getCurrentPointIndex\n- * \n- * Returns:\n- * {Number} The index of the most recently drawn point.\n+ * Method: getImage\n+ * Returns or creates and returns the tile image.\n */\n- getCurrentPointIndex: function() {\n- return this.line.geometry.components.length - 1;\n- },\n-\n+ getImage: function() {\n+ if (!this.imgDiv) {\n+ this.imgDiv = OpenLayers.Tile.Image.IMAGE.cloneNode(false);\n \n- /**\n- * Method: undo\n- * Remove the most recently added point in the sketch geometry.\n- *\n- * Returns: \n- * {Boolean} A point was removed.\n- */\n- undo: function() {\n- var geometry = this.line.geometry;\n- var components = geometry.components;\n- var index = this.getCurrentPointIndex() - 1;\n- var target = components[index];\n- var undone = geometry.removeComponent(target);\n- if (undone) {\n- // On touch devices, set the current (\"mouse location\") point to\n- // match the last digitized point.\n- if (this.touch && index > 0) {\n- components = geometry.components; // safety\n- var lastpt = components[index - 1];\n- var curptidx = this.getCurrentPointIndex();\n- var curpt = components[curptidx];\n- curpt.x = lastpt.x;\n- curpt.y = lastpt.y;\n+ var style = this.imgDiv.style;\n+ if (this.frame) {\n+ var left = 0,\n+ top = 0;\n+ if (this.layer.gutter) {\n+ left = this.layer.gutter / this.layer.tileSize.w * 100;\n+ top = this.layer.gutter / this.layer.tileSize.h * 100;\n+ }\n+ style.left = -left + \"%\";\n+ style.top = -top + \"%\";\n+ style.width = (2 * left + 100) + \"%\";\n+ style.height = (2 * top + 100) + \"%\";\n }\n- if (!this.redoStack) {\n- this.redoStack = [];\n+ style.visibility = \"hidden\";\n+ style.opacity = 0;\n+ if (this.layer.opacity < 1) {\n+ style.filter = 'alpha(opacity=' +\n+ (this.layer.opacity * 100) +\n+ ')';\n+ }\n+ style.position = \"absolute\";\n+ if (this.layerAlphaHack) {\n+ // move the image out of sight\n+ style.paddingTop = style.height;\n+ style.height = \"0\";\n+ style.width = \"100%\";\n+ }\n+ if (this.frame) {\n+ this.frame.appendChild(this.imgDiv);\n }\n- this.redoStack.push(target);\n- this.drawFeature();\n }\n- return undone;\n+\n+ return this.imgDiv;\n },\n \n /**\n- * Method: 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+ * APIMethod: setImage\n+ * Sets the image element for this tile. This method should only be called\n+ * from beforeload listeners.\n *\n- * Returns: \n- * {Boolean} A point was added.\n+ * Parameters\n+ * img - {HTMLImageElement} The image to use for this tile.\n */\n- redo: function() {\n- var target = this.redoStack && this.redoStack.pop();\n- if (target) {\n- this.line.geometry.addComponent(target, this.getCurrentPointIndex());\n- this.drawFeature();\n- }\n- return !!target;\n+ setImage: function(img) {\n+ this.imgDiv = img;\n },\n \n /**\n- * Method: freehandMode\n- * Determine whether to behave in freehand mode or not.\n- *\n- * Returns:\n- * {Boolean}\n+ * Method: initImage\n+ * Creates the content for the frame on the tile.\n */\n- freehandMode: function(evt) {\n- return (this.freehandToggle && evt[this.freehandToggle]) ?\n- !this.freehand : this.freehand;\n+ initImage: function() {\n+ if (!this.url && !this.imgDiv) {\n+ // fast path out - if there is no tile url and no previous image\n+ this.isLoading = false;\n+ return;\n+ }\n+ this.events.triggerEvent('beforeload');\n+ this.layer.div.appendChild(this.getTile());\n+ this.events.triggerEvent(this._loadEvent);\n+ var img = this.getImage();\n+ var src = img.getAttribute('src') || '';\n+ if (this.url && OpenLayers.Util.isEquivalentUrl(src, this.url)) {\n+ this._loadTimeout = window.setTimeout(\n+ OpenLayers.Function.bind(this.onImageLoad, this), 0\n+ );\n+ } else {\n+ this.stopLoading();\n+ if (this.crossOriginKeyword) {\n+ img.removeAttribute(\"crossorigin\");\n+ }\n+ OpenLayers.Event.observe(img, \"load\",\n+ OpenLayers.Function.bind(this.onImageLoad, this)\n+ );\n+ OpenLayers.Event.observe(img, \"error\",\n+ OpenLayers.Function.bind(this.onImageError, this)\n+ );\n+ this.imageReloadAttempts = 0;\n+ this.setImgSrc(this.url);\n+ }\n },\n \n /**\n- * Method: modifyFeature\n- * Modify the existing geometry given the new point\n+ * Method: setImgSrc\n+ * Sets the source for the tile image\n *\n * Parameters:\n- * pixel - {} The updated pixel location for the latest\n- * point.\n- * drawing - {Boolean} Indicate if we're currently drawing.\n+ * url - {String} or undefined to hide the image\n */\n- modifyFeature: function(pixel, drawing) {\n- if (!this.line) {\n- this.createFeature(pixel);\n+ setImgSrc: function(url) {\n+ var img = this.imgDiv;\n+ if (url) {\n+ img.style.visibility = 'hidden';\n+ img.style.opacity = 0;\n+ // don't set crossOrigin if the url is a data URL\n+ if (this.crossOriginKeyword) {\n+ if (url.substr(0, 5) !== 'data:') {\n+ img.setAttribute(\"crossorigin\", this.crossOriginKeyword);\n+ } else {\n+ img.removeAttribute(\"crossorigin\");\n+ }\n+ }\n+ img.src = url;\n+ } else {\n+ // Remove reference to the image, and leave it to the browser's\n+ // caching and garbage collection.\n+ this.stopLoading();\n+ this.imgDiv = null;\n+ if (img.parentNode) {\n+ img.parentNode.removeChild(img);\n+ }\n }\n- var lonlat = this.layer.getLonLatFromViewPortPx(pixel);\n- this.point.geometry.x = lonlat.lon;\n- this.point.geometry.y = lonlat.lat;\n- this.callback(\"modify\", [this.point.geometry, this.getSketch(), drawing]);\n- this.point.geometry.clearBounds();\n- this.drawFeature();\n },\n \n /**\n- * Method: drawFeature\n- * Render geometries on the temporary layer.\n- */\n- drawFeature: function() {\n- this.layer.drawFeature(this.line, this.style);\n- this.layer.drawFeature(this.point, this.style);\n- },\n-\n- /**\n- * Method: getSketch\n- * Return the sketch feature.\n+ * Method: getTile\n+ * Get the tile's markup.\n *\n * Returns:\n- * {}\n+ * {DOMElement} The tile's markup\n */\n- getSketch: function() {\n- return this.line;\n+ getTile: function() {\n+ return this.frame ? this.frame : this.getImage();\n },\n \n /**\n- * Method: getGeometry\n- * Return the sketch geometry. If is true, this will return\n- * a multi-part geometry.\n+ * Method: createBackBuffer\n+ * Create a backbuffer for this tile. A backbuffer isn't exactly a clone\n+ * of the tile's markup, because we want to avoid the reloading of the\n+ * image. So we clone the frame, and steal the image from the tile.\n *\n * Returns:\n- * {}\n+ * {DOMElement} The markup, or undefined if the tile has no image\n+ * or if it's currently loading.\n */\n- getGeometry: function() {\n- var geometry = this.line && this.line.geometry;\n- if (geometry && this.multi) {\n- geometry = new OpenLayers.Geometry.MultiLineString([geometry]);\n+ createBackBuffer: function() {\n+ if (!this.imgDiv || this.isLoading) {\n+ return;\n }\n- return geometry;\n- },\n-\n- /**\n- * method: touchstart\n- * handle touchstart.\n- *\n- * parameters:\n- * evt - {event} the browser event\n- *\n- * returns:\n- * {boolean} allow event propagation\n- */\n- touchstart: function(evt) {\n- if (this.timerId &&\n- this.passesTolerance(this.lastTouchPx, evt.xy,\n- this.doubleTouchTolerance)) {\n- // double-tap, finalize the geometry\n- this.finishGeometry();\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n- return false;\n+ var backBuffer;\n+ if (this.frame) {\n+ backBuffer = this.frame.cloneNode(false);\n+ backBuffer.appendChild(this.imgDiv);\n } else {\n- if (this.timerId) {\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n- }\n- this.timerId = window.setTimeout(\n- OpenLayers.Function.bind(function() {\n- this.timerId = null;\n- }, this), 300);\n- return OpenLayers.Handler.Point.prototype.touchstart.call(this, evt);\n+ backBuffer = this.imgDiv;\n }\n+ this.imgDiv = null;\n+ return backBuffer;\n },\n \n /**\n- * Method: down\n- * Handle mousedown and touchstart. Add a new point to the geometry and\n- * render it. Return determines whether to propagate the event on the map.\n- * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * Method: onImageLoad\n+ * Handler for the image onload event\n */\n- down: function(evt) {\n- var stopDown = this.stopDown;\n- if (this.freehandMode(evt)) {\n- stopDown = true;\n- if (this.touch) {\n- this.modifyFeature(evt.xy, !!this.lastUp);\n- OpenLayers.Event.stop(evt);\n- }\n- }\n- if (!this.touch && (!this.lastDown ||\n- !this.passesTolerance(this.lastDown, evt.xy,\n- this.pixelTolerance))) {\n- this.modifyFeature(evt.xy, !!this.lastUp);\n- }\n- this.mouseDown = true;\n- this.lastDown = evt.xy;\n- this.stoppedDown = stopDown;\n- return !stopDown;\n- },\n+ onImageLoad: function() {\n+ var img = this.imgDiv;\n+ this.stopLoading();\n+ img.style.visibility = 'inherit';\n+ img.style.opacity = this.layer.opacity;\n+ this.isLoading = false;\n+ this.canvasContext = null;\n+ this.events.triggerEvent(\"loadend\");\n \n- /**\n- * Method: move\n- * Handle mousemove and touchmove. Adjust the geometry and redraw.\n- * Return determines whether to propagate the event on the map.\n- * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n- */\n- move: function(evt) {\n- if (this.stoppedDown && this.freehandMode(evt)) {\n- if (this.persist) {\n- this.destroyPersistedFeature();\n- }\n- if (this.maxVertices && this.line &&\n- this.line.geometry.components.length === this.maxVertices) {\n- this.removePoint();\n- this.finalize();\n- } else {\n- this.addPoint(evt.xy);\n- }\n- return false;\n- }\n- if (!this.touch && (!this.mouseDown || this.stoppedDown)) {\n- this.modifyFeature(evt.xy, !!this.lastUp);\n+ if (this.layerAlphaHack === true) {\n+ img.style.filter =\n+ \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='\" +\n+ img.src + \"', sizingMethod='scale')\";\n }\n- return true;\n },\n \n /**\n- * Method: up\n- * Handle mouseup and touchend. Send the latest point in the geometry to\n- * the control. Return determines whether to propagate the event on the map.\n- * \n- * Parameters:\n- * evt - {Event} The browser event\n- *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * Method: onImageError\n+ * Handler for the image onerror event\n */\n- up: function(evt) {\n- if (this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {\n- if (this.stoppedDown && this.freehandMode(evt)) {\n- if (this.persist) {\n- this.destroyPersistedFeature();\n- }\n- this.removePoint();\n- this.finalize();\n+ onImageError: function() {\n+ var img = this.imgDiv;\n+ if (img.src != null) {\n+ this.imageReloadAttempts++;\n+ if (this.imageReloadAttempts <= OpenLayers.IMAGE_RELOAD_ATTEMPTS) {\n+ this.setImgSrc(this.layer.getURL(this.bounds));\n } else {\n- if (this.passesTolerance(this.lastDown, evt.xy,\n- this.pixelTolerance)) {\n- if (this.touch) {\n- this.modifyFeature(evt.xy);\n- }\n- if (this.lastUp == null && this.persist) {\n- this.destroyPersistedFeature();\n- }\n- this.addPoint(evt.xy);\n- this.lastUp = evt.xy;\n- if (this.line.geometry.components.length === this.maxVertices + 1) {\n- this.finishGeometry();\n- }\n- }\n+ OpenLayers.Element.addClass(img, \"olImageLoadError\");\n+ this.events.triggerEvent(\"loaderror\");\n+ this.onImageLoad();\n }\n }\n- this.stoppedDown = this.stopDown;\n- this.mouseDown = false;\n- return !this.stopUp;\n },\n \n /**\n- * APIMethod: finishGeometry\n- * Finish the geometry and send it back to the control.\n+ * Method: stopLoading\n+ * Stops a loading sequence so won't be executed.\n */\n- finishGeometry: function() {\n- var index = this.line.geometry.components.length - 1;\n- this.line.geometry.removeComponent(this.line.geometry.components[index]);\n- this.removePoint();\n- this.finalize();\n+ stopLoading: function() {\n+ OpenLayers.Event.stopObservingElement(this.imgDiv);\n+ window.clearTimeout(this._loadTimeout);\n+ delete this._loadTimeout;\n },\n \n /**\n- * Method: dblclick \n- * Handle double-clicks.\n- * \n- * Parameters:\n- * evt - {Event} The browser event\n+ * APIMethod: getCanvasContext\n+ * Returns a canvas context associated with the tile image (with\n+ * the image drawn on it).\n+ * Returns undefined if the browser does not support canvas, if\n+ * the tile has no image or if it's currently loading.\n *\n- * Returns: \n- * {Boolean} Allow event propagation\n+ * The function returns a canvas context instance but the\n+ * underlying canvas is still available in the 'canvas' property:\n+ * (code)\n+ * var context = tile.getCanvasContext();\n+ * if (context) {\n+ * var data = context.canvas.toDataURL('image/jpeg');\n+ * }\n+ * (end)\n+ *\n+ * Returns:\n+ * {Boolean}\n */\n- dblclick: function(evt) {\n- if (!this.freehandMode(evt)) {\n- this.finishGeometry();\n+ getCanvasContext: function() {\n+ if (OpenLayers.CANVAS_SUPPORTED && this.imgDiv && !this.isLoading) {\n+ if (!this.canvasContext) {\n+ var canvas = document.createElement(\"canvas\");\n+ canvas.width = this.size.w;\n+ canvas.height = this.size.h;\n+ this.canvasContext = canvas.getContext(\"2d\");\n+ this.canvasContext.drawImage(this.imgDiv, 0, 0);\n+ }\n+ return this.canvasContext;\n }\n- return false;\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.Path\"\n+ CLASS_NAME: \"OpenLayers.Tile.Image\"\n+\n });\n+\n+/** \n+ * Constant: OpenLayers.Tile.Image.IMAGE\n+ * {HTMLImageElement} The image for a tile.\n+ */\n+OpenLayers.Tile.Image.IMAGE = (function() {\n+ var img = new Image();\n+ img.className = \"olTileImage\";\n+ // avoid image gallery menu in IE6\n+ img.galleryImg = \"no\";\n+ return img;\n+}());\n+\n /* ======================================================================\n- OpenLayers/Handler/Polygon.js\n+ OpenLayers/Layer/Grid.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/Layer/HTTPRequest.js\n+ * @requires OpenLayers/Tile/Image.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.Layer.Grid\n+ * Base class for layers that use a lattice of tiles. Create a new grid\n+ * layer with the constructor.\n *\n * Inherits from:\n- * - \n- * - \n+ * - \n */\n-OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {\n+OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {\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+ * APIProperty: tileSize\n+ * {}\n */\n- holeModifier: null,\n+ tileSize: null,\n \n /**\n- * Property: drawingHole\n- * {Boolean} Currently drawing an interior ring.\n+ * Property: tileOriginCorner\n+ * {String} If the property is not provided, the tile origin \n+ * will be derived from the layer's . The corner of the \n+ * used is determined by this property. Acceptable values\n+ * are \"tl\" (top left), \"tr\" (top right), \"bl\" (bottom left), and \"br\"\n+ * (bottom right). Default is \"bl\".\n */\n- drawingHole: false,\n+ tileOriginCorner: \"bl\",\n \n /**\n- * Property: polygon\n- * {}\n+ * APIProperty: tileOrigin\n+ * {} Optional origin for aligning the grid of tiles.\n+ * If provided, requests for tiles at all resolutions will be aligned\n+ * with this location (no tiles shall overlap this location). If\n+ * not provided, the grid of tiles will be aligned with the layer's\n+ * . Default is ``null``.\n */\n- polygon: null,\n+ tileOrigin: 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+ /** APIProperty: tileOptions\n+ * {Object} optional configuration options for instances\n+ * created by this Layer, if supported by the tile class.\n */\n+ tileOptions: null,\n \n /**\n- * Method: createFeature\n- * Add temporary geometries\n- *\n- * Parameters:\n- * pixel - {} The initial pixel location for the new\n- * feature.\n+ * APIProperty: tileClass\n+ * {} The tile class to use for this layer.\n+ * Defaults is OpenLayers.Tile.Image.\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+ tileClass: OpenLayers.Tile.Image,\n \n /**\n- * Method: addPoint\n- * Add point to geometry.\n- *\n- * Parameters:\n- * pixel - {} The pixel location for the new point.\n+ * Property: grid\n+ * {Array(Array())} This is an array of rows, each row is \n+ * an array of tiles.\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+ grid: null,\n \n /**\n- * Method: getCurrentPointIndex\n- * \n- * Returns:\n- * {Number} The index of the most recently drawn point.\n+ * APIProperty: singleTile\n+ * {Boolean} Moves the layer into single-tile mode, meaning that one tile \n+ * will be loaded. The tile's size will be determined by the 'ratio'\n+ * property. When the tile is dragged such that it does not cover the \n+ * entire viewport, it is reloaded.\n */\n- getCurrentPointIndex: function() {\n- return this.line.geometry.components.length - 2;\n- },\n+ singleTile: false,\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+ /** APIProperty: ratio\n+ * {Float} Used only when in single-tile mode, this specifies the \n+ * ratio of the size of the single tile to the size of the map.\n+ * Default value is 1.5.\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+ ratio: 1.5,\n \n /**\n- * Method: finishGeometry\n- * Finish the geometry and send it back to the control.\n+ * APIProperty: buffer\n+ * {Integer} Used only when in gridded mode, this specifies the number of \n+ * extra rows and colums of tiles on each side which will\n+ * surround the minimum grid tiles to cover the map.\n+ * For very slow loading layers, a larger value may increase\n+ * performance somewhat when dragging, but will increase bandwidth\n+ * use significantly. \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+ buffer: 0,\n \n /**\n- * Method: finalizeInteriorRing\n- * Enforces that new ring has some area and doesn't contain vertices of any\n- * other rings.\n+ * APIProperty: transitionEffect\n+ * {String} The transition effect to use when the map is zoomed.\n+ * Two posible values:\n+ *\n+ * \"resize\" - Existing tiles are resized on zoom to provide a visual\n+ * effect of the zoom having taken place immediately. As the\n+ * new tiles become available, they are drawn on top of the\n+ * resized tiles (this is the default setting).\n+ * \"map-resize\" - Existing tiles are resized on zoom and placed below the\n+ * base layer. New tiles for the base layer will cover existing tiles.\n+ * This setting is recommended when having an overlay duplicated during\n+ * the transition is undesirable (e.g. street labels or big transparent\n+ * fills). \n+ * null - No transition effect.\n+ *\n+ * Using \"resize\" on non-opaque layers can cause undesired visual\n+ * effects. Set transitionEffect to null in this case.\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+ transitionEffect: \"resize\",\n \n /**\n- * APIMethod: cancel\n- * Finish the geometry and call the \"cancel\" callback.\n+ * APIProperty: numLoadingTiles\n+ * {Integer} How many tiles are still loading?\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+ numLoadingTiles: 0,\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+ * Property: serverResolutions\n+ * {Array(Number}} This property is documented in subclasses as\n+ * an API property.\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+ serverResolutions: null,\n \n /**\n- * Method: destroyFeature\n- * Destroy temporary geometries\n- *\n- * Parameters:\n- * force - {Boolean} Destroy even if persist is true.\n+ * Property: loading\n+ * {Boolean} Indicates if tiles are being loaded.\n */\n- destroyFeature: function(force) {\n- OpenLayers.Handler.Path.prototype.destroyFeature.call(\n- this, force);\n- this.polygon = null;\n- },\n+ loading: false,\n \n /**\n- * Method: drawFeature\n- * Render geometries on the temporary layer.\n+ * Property: backBuffer\n+ * {DOMElement} The back buffer.\n */\n- drawFeature: function() {\n- this.layer.drawFeature(this.polygon, this.style);\n- this.layer.drawFeature(this.point, this.style);\n- },\n+ backBuffer: null,\n \n /**\n- * Method: getSketch\n- * Return the sketch feature.\n- *\n- * Returns:\n- * {}\n+ * Property: gridResolution\n+ * {Number} The resolution of the current grid. Used for backbuffer and\n+ * client zoom. This property is updated every time the grid is\n+ * initialized.\n */\n- getSketch: function() {\n- return this.polygon;\n- },\n+ gridResolution: null,\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+ * Property: backBufferResolution\n+ * {Number} The resolution of the current back buffer. This property is\n+ * updated each time a back buffer is created.\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/Hover.js\n- ====================================================================== */\n+ backBufferResolution: null,\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+ * Property: backBufferLonLat\n+ * {Object} The top-left corner of the current back buffer. Includes lon\n+ * and lat properties. This object is updated each time a back buffer\n+ * is created.\n+ */\n+ backBufferLonLat: null,\n \n-/**\n- * @requires OpenLayers/Handler.js\n- */\n+ /**\n+ * Property: backBufferTimerId\n+ * {Number} The id of the back buffer timer. This timer is used to\n+ * delay the removal of the back buffer, thereby preventing\n+ * flash effects caused by tile animation.\n+ */\n+ backBufferTimerId: null,\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- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Hover = OpenLayers.Class(OpenLayers.Handler, {\n+ /**\n+ * APIProperty: removeBackBufferDelay\n+ * {Number} Delay for removing the backbuffer when all tiles have finished\n+ * loading. Can be set to 0 when no css opacity transitions for the\n+ * olTileImage class are used. Default is 0 for layers,\n+ * 2500 for tiled layers. See for more information on\n+ * tile animation.\n+ */\n+ removeBackBufferDelay: null,\n \n /**\n- * APIProperty: delay\n- * {Integer} - Number of milliseconds between mousemoves before\n- * the event is considered a hover. Default is 500.\n+ * APIProperty: className\n+ * {String} Name of the class added to the layer div. If not set in the\n+ * options passed to the constructor then className defaults to\n+ * \"olLayerGridSingleTile\" for single tile layers (see ),\n+ * and \"olLayerGrid\" for non single tile layers.\n+ *\n+ * Note:\n+ *\n+ * The displaying of tiles is not animated by default for single tile\n+ * layers - OpenLayers' default theme (style.css) includes this:\n+ * (code)\n+ * .olLayerGrid .olTileImage {\n+ * -webkit-transition: opacity 0.2s linear;\n+ * -moz-transition: opacity 0.2s linear;\n+ * -o-transition: opacity 0.2s linear;\n+ * transition: opacity 0.2s linear;\n+ * }\n+ * (end)\n+ * To animate tile displaying for any grid layer the following\n+ * CSS rule can be used:\n+ * (code)\n+ * .olTileImage {\n+ * -webkit-transition: opacity 0.2s linear;\n+ * -moz-transition: opacity 0.2s linear;\n+ * -o-transition: opacity 0.2s linear;\n+ * transition: opacity 0.2s linear;\n+ * }\n+ * (end)\n+ * In that case, to avoid flash effects, \n+ * should not be zero.\n */\n- delay: 500,\n+ className: null,\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+ * 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 event types:\n+ * addtile - Triggered when a tile is added to this layer. Listeners receive\n+ * an object as first argument, which has a tile property that\n+ * references the tile that has been added.\n+ * tileloadstart - Triggered when a tile starts loading. Listeners receive\n+ * an object as first argument, which has a tile property that\n+ * references the tile that starts loading.\n+ * tileloaded - Triggered when each new tile is\n+ * loaded, as a means of progress update to listeners.\n+ * listeners can access 'numLoadingTiles' if they wish to keep\n+ * track of the loading progress. Listeners are called with an object\n+ * with a 'tile' property as first argument, making the loaded tile\n+ * available to the listener, and an 'aborted' property, which will be\n+ * true when loading was aborted and no tile data is available.\n+ * tileerror - Triggered before the tileloaded event (i.e. when the tile is\n+ * still hidden) if a tile failed to load. Listeners receive an object\n+ * as first argument, which has a tile property that references the\n+ * tile that could not be loaded.\n+ * retile - Triggered when the layer recreates its tile grid.\n */\n- pixelTolerance: null,\n \n /**\n- * APIProperty: stopMove\n- * {Boolean} - Stop other listeners from being notified on mousemoves.\n- * Default is false.\n+ * Property: gridLayout\n+ * {Object} Object containing properties tilelon, tilelat, startcol,\n+ * startrow\n */\n- stopMove: false,\n+ gridLayout: null,\n \n /**\n- * Property: px\n- * {} - The location of the last mousemove, expressed\n- * in pixels.\n+ * Property: rowSign\n+ * {Number} 1 for grids starting at the top, -1 for grids starting at the\n+ * bottom. This is used for several grid index and offset calculations.\n */\n- px: null,\n+ rowSign: null,\n \n /**\n- * Property: timerId\n- * {Number} - The id of the timer.\n+ * Property: transitionendEvents\n+ * {Array} Event names for transitionend\n */\n- timerId: null,\n+ transitionendEvents: [\n+ 'transitionend', 'webkitTransitionEnd', 'otransitionend',\n+ 'oTransitionEnd'\n+ ],\n \n /**\n- * Constructor: OpenLayers.Handler.Hover\n- * Construct a hover handler.\n+ * Constructor: OpenLayers.Layer.Grid\n+ * Create a new grid layer\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+ * name - {String}\n+ * url - {String}\n+ * params - {Object}\n+ * options - {Object} Hashtable of extra options to tag onto the layer\n */\n+ initialize: function(name, url, params, options) {\n+ OpenLayers.Layer.HTTPRequest.prototype.initialize.apply(this,\n+ arguments);\n+ this.grid = [];\n+ this._removeBackBuffer = OpenLayers.Function.bind(this.removeBackBuffer, this);\n+\n+ this.initProperties();\n+\n+ this.rowSign = this.tileOriginCorner.substr(0, 1) === \"t\" ? 1 : -1;\n+ },\n \n /**\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+ * Method: initProperties\n+ * Set any properties that depend on the value of singleTile.\n+ * Currently sets removeBackBufferDelay and className\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+ initProperties: function() {\n+ if (this.options.removeBackBufferDelay === undefined) {\n+ this.removeBackBufferDelay = this.singleTile ? 0 : 2500;\n+ }\n+\n+ if (this.options.className === undefined) {\n+ this.className = this.singleTile ? 'olLayerGridSingleTile' :\n+ 'olLayerGrid';\n }\n- return !this.stopMove;\n },\n \n /**\n- * Method: mouseout\n- * Called when the mouse goes out of the map.\n+ * Method: setMap\n *\n * Parameters:\n- * evt - {}\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ * map - {} The map.\n */\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+ setMap: function(map) {\n+ OpenLayers.Layer.HTTPRequest.prototype.setMap.call(this, map);\n+ OpenLayers.Element.addClass(this.div, this.className);\n },\n \n /**\n- * Method: passesTolerance\n- * Determine whether the mouse move is within the optional pixel tolerance.\n+ * Method: removeMap\n+ * Called when the layer is removed from the map.\n *\n * Parameters:\n- * px - {}\n+ * map - {} The map.\n+ */\n+ removeMap: function(map) {\n+ this.removeBackBuffer();\n+ },\n+\n+ /**\n+ * APIMethod: destroy\n+ * Deconstruct the layer and clear the grid.\n+ */\n+ destroy: function() {\n+ this.removeBackBuffer();\n+ this.clearGrid();\n+\n+ this.grid = null;\n+ this.tileSize = null;\n+ OpenLayers.Layer.HTTPRequest.prototype.destroy.apply(this, arguments);\n+ },\n+\n+ /**\n+ * APIMethod: mergeNewParams\n+ * Refetches tiles with new params merged, keeping a backbuffer. Each\n+ * loading new tile will have a css class of '.olTileReplacing'. If a\n+ * stylesheet applies a 'display: none' style to that class, any fade-in\n+ * transition will not apply, and backbuffers for each tile will be removed\n+ * as soon as the tile is loaded.\n+ * \n+ * Parameters:\n+ * newParams - {Object}\n *\n * Returns:\n- * {Boolean} The mouse move is within the pixel tolerance.\n+ * redrawn: {Boolean} whether the layer was actually redrawn.\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+ * Method: clearGrid\n+ * Go through and remove all tiles from the grid, calling\n+ * destroy() on each of them to kill circular references\n */\n- clearTimer: function() {\n- if (this.timerId != null) {\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n+ clearGrid: function() {\n+ if (this.grid) {\n+ for (var iRow = 0, len = this.grid.length; iRow < len; iRow++) {\n+ var row = this.grid[iRow];\n+ for (var iCol = 0, clen = row.length; iCol < clen; iCol++) {\n+ var tile = row[iCol];\n+ this.destroyTile(tile);\n+ }\n+ }\n+ this.grid = [];\n+ this.gridResolution = null;\n+ this.gridLayout = null;\n }\n },\n \n /**\n- * Method: delayedCall\n- * Triggers pause callback.\n- *\n+ * APIMethod: addOptions\n+ * \n * Parameters:\n- * evt - {}\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- delayedCall: function(evt) {\n- this.callback('pause', [evt]);\n+ addOptions: function(newOptions, reinitialize) {\n+ var singleTileChanged = newOptions.singleTile !== undefined &&\n+ newOptions.singleTile !== this.singleTile;\n+ OpenLayers.Layer.HTTPRequest.prototype.addOptions.apply(this, arguments);\n+ if (this.map && singleTileChanged) {\n+ this.initProperties();\n+ this.clearGrid();\n+ this.tileSize = this.options.tileSize;\n+ this.setTileSize();\n+ this.moveTo(null, true);\n+ }\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the handler.\n+ * APIMethod: clone\n+ * Create a clone of this layer\n *\n+ * Parameters:\n+ * obj - {Object} Is this ever used?\n+ * \n * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * {} An exact clone of this OpenLayers.Layer.Grid\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+ clone: function(obj) {\n \n- CLASS_NAME: \"OpenLayers.Handler.Hover\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler/RegularPolygon.js\n- ====================================================================== */\n+ if (obj == null) {\n+ obj = new OpenLayers.Layer.Grid(this.name,\n+ this.url,\n+ this.params,\n+ this.getOptions());\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+ //get all additions from superclasses\n+ obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);\n \n+ // copy/set any non-init, non-simple values here\n+ if (this.tileSize != null) {\n+ obj.tileSize = this.tileSize.clone();\n+ }\n \n-/**\n- * @requires OpenLayers/Handler/Drag.js\n- */\n+ // we do not want to copy reference to grid, so we make a new array\n+ obj.grid = [];\n+ obj.gridResolution = null;\n+ // same for backbuffer\n+ obj.backBuffer = null;\n+ obj.backBufferTimerId = null;\n+ obj.loading = false;\n+ obj.numLoadingTiles = 0;\n \n-/**\n- * Class: OpenLayers.Handler.RegularPolygon\n- * Handler to draw a regular polygon on the map. Polygon is displayed on mouse\n- * down, moves or is modified on mouse move, and is finished on mouse up.\n- * The handler triggers callbacks for 'done' and 'cancel'. Create a new\n- * instance with the constructor.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, {\n+ return obj;\n+ },\n \n /**\n- * APIProperty: sides\n- * {Integer} Number of sides for the regular polygon. Needs to be greater\n- * than 2. Defaults to 4.\n+ * Method: moveTo\n+ * This function is called whenever the map is moved. All the moving\n+ * of actual 'tiles' is done by the map, but moveTo's role is to accept\n+ * a bounds and make sure the data that that bounds requires is pre-loaded.\n+ *\n+ * Parameters:\n+ * bounds - {}\n+ * zoomChanged - {Boolean}\n+ * dragging - {Boolean}\n */\n- sides: 4,\n+ moveTo: function(bounds, zoomChanged, dragging) {\n \n- /**\n- * APIProperty: radius\n- * {Float} Optional radius in map units of the regular polygon. If this is\n- * set to some non-zero value, a polygon with a fixed radius will be\n- * drawn and dragged with mose movements. If this property is not\n- * set, dragging changes the radius of the polygon. Set to null by\n- * default.\n- */\n- radius: null,\n+ OpenLayers.Layer.HTTPRequest.prototype.moveTo.apply(this, arguments);\n \n- /**\n- * APIProperty: snapAngle\n- * {Float} If set to a non-zero value, the handler will snap the polygon\n- * rotation to multiples of the snapAngle. Value is an angle measured\n- * in degrees counterclockwise from the positive x-axis. \n- */\n- snapAngle: null,\n+ bounds = bounds || this.map.getExtent();\n \n- /**\n- * APIProperty: snapToggle\n- * {String} If set, snapToggle is checked on mouse events and will set\n- * the snap mode to the opposite of what it currently is. To disallow\n- * toggling between snap and non-snap mode, set freehandToggle to\n- * null. Acceptable toggle values are 'shiftKey', 'ctrlKey', and\n- * 'altKey'. Snap mode is only possible if this.snapAngle is set to a\n- * non-zero value.\n- */\n- snapToggle: 'shiftKey',\n+ if (bounds != null) {\n \n- /**\n- * Property: layerOptions\n- * {Object} Any optional properties to be set on the sketch layer.\n- */\n- layerOptions: null,\n+ // if grid is empty or zoom has changed, we *must* re-tile\n+ var forceReTile = !this.grid.length || zoomChanged;\n \n- /**\n- * APIProperty: persist\n- * {Boolean} Leave the feature rendered until clear is called. Default\n- * is false. If set to true, the feature remains rendered until\n- * clear is called, typically by deactivating the handler or starting\n- * another drawing.\n- */\n- persist: false,\n+ // total bounds of the tiles\n+ var tilesBounds = this.getTilesBounds();\n \n- /**\n- * APIProperty: irregular\n- * {Boolean} Draw an irregular polygon instead of a regular polygon.\n- * Default is false. If true, the initial mouse down will represent\n- * one corner of the polygon bounds and with each mouse movement, the\n- * polygon will be stretched so the opposite corner of its bounds\n- * follows the mouse position. This property takes precedence over\n- * the radius property. If set to true, the radius property will\n- * be ignored.\n- */\n- irregular: false,\n+ // the new map resolution\n+ var resolution = this.map.getResolution();\n \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+ // the server-supported resolution for the new map resolution\n+ var serverResolution = this.getServerResolution(resolution);\n \n- /**\n- * Property: angle\n- * {Float} The angle from the origin (mouse down) to the current mouse\n- * position, in radians. This is measured counterclockwise from the\n- * positive x-axis.\n- */\n- angle: null,\n+ if (this.singleTile) {\n \n- /**\n- * Property: fixedRadius\n- * {Boolean} The polygon has a fixed radius. True if a radius is set before\n- * drawing begins. False otherwise.\n- */\n- fixedRadius: false,\n+ // We want to redraw whenever even the slightest part of the \n+ // current bounds is not contained by our tile.\n+ // (thus, we do not specify partial -- its default is false)\n \n- /**\n- * Property: feature\n- * {} The currently drawn polygon feature\n- */\n- feature: null,\n+ if (forceReTile ||\n+ (!dragging && !tilesBounds.containsBounds(bounds))) {\n \n- /**\n- * Property: layer\n- * {} The temporary drawing layer\n- */\n- layer: null,\n+ // In single tile mode with no transition effect, we insert\n+ // a non-scaled backbuffer when the layer is moved. But if\n+ // a zoom occurs right after a move, i.e. before the new\n+ // image is received, we need to remove the backbuffer, or\n+ // an ill-positioned image will be visible during the zoom\n+ // transition.\n \n- /**\n- * Property: origin\n- * {} Location of the first mouse down\n- */\n- origin: null,\n+ if (zoomChanged && this.transitionEffect !== 'resize') {\n+ this.removeBackBuffer();\n+ }\n \n- /**\n- * Constructor: OpenLayers.Handler.RegularPolygon\n- * Create a new regular 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 object with properties to be set on the handler.\n- * If the options.sides property is not specified, the number of sides\n- * will default to 4.\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- * done - Called when the sketch drawing is finished. The callback will\n- * recieve a single argument, the sketch geometry.\n- * cancel - Called when the handler is deactivated while drawing. The\n- * cancel callback will receive a geometry.\n- */\n- initialize: function(control, callbacks, options) {\n- if (!(options && options.layerOptions && options.layerOptions.styleMap)) {\n- this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {});\n- }\n+ if (!zoomChanged || this.transitionEffect === 'resize') {\n+ this.applyBackBuffer(resolution);\n+ }\n \n- OpenLayers.Handler.Drag.prototype.initialize.apply(this,\n- [control, callbacks, options]);\n- this.options = (options) ? options : {};\n- },\n+ this.initSingleTile(bounds);\n+ }\n+ } else {\n \n- /**\n- * APIMethod: setOptions\n- * \n- * Parameters:\n- * newOptions - {Object} \n- */\n- setOptions: function(newOptions) {\n- OpenLayers.Util.extend(this.options, newOptions);\n- OpenLayers.Util.extend(this, newOptions);\n- },\n+ // if the bounds have changed such that they are not even \n+ // *partially* contained by our tiles (e.g. when user has \n+ // programmatically panned to the other side of the earth on\n+ // zoom level 18), then moveGriddedTiles could potentially have\n+ // to run through thousands of cycles, so we want to reTile\n+ // instead (thus, partial true). \n+ forceReTile = forceReTile ||\n+ !tilesBounds.intersectsBounds(bounds, {\n+ worldBounds: this.map.baseLayer.wrapDateLine &&\n+ this.map.getMaxExtent()\n+ });\n \n- /**\n- * APIMethod: activate\n- * Turn on the handler.\n- *\n- * Returns:\n- * {Boolean} The handler was successfully activated\n- */\n- activate: function() {\n- var activated = false;\n- if (OpenLayers.Handler.Drag.prototype.activate.apply(this, arguments)) {\n- // create temporary vector layer for rendering geometry sketch\n- var options = OpenLayers.Util.extend({\n- displayInLayerSwitcher: false,\n- // indicate that the temp vector layer will never be out of range\n- // without this, resolution properties must be specified at the\n- // map-level for this temporary layer to init its resolutions\n- // correctly\n- calculateInRange: OpenLayers.Function.True,\n- wrapDateLine: this.citeCompliant\n- }, this.layerOptions);\n- this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options);\n- this.map.addLayer(this.layer);\n- activated = true;\n+ if (forceReTile) {\n+ if (zoomChanged && (this.transitionEffect === 'resize' ||\n+ this.gridResolution === resolution)) {\n+ this.applyBackBuffer(resolution);\n+ }\n+ this.initGriddedTiles(bounds);\n+ } else {\n+ this.moveGriddedTiles();\n+ }\n+ }\n }\n- return activated;\n },\n \n /**\n- * APIMethod: deactivate\n- * Turn off the handler.\n+ * Method: getTileData\n+ * Given a map location, retrieve a tile and the pixel offset within that\n+ * tile corresponding to the location. If there is not an existing \n+ * tile in the grid that covers the given location, null will be \n+ * returned.\n+ *\n+ * Parameters:\n+ * loc - {} map location\n *\n * Returns:\n- * {Boolean} The handler was successfully deactivated\n+ * {Object} Object with the following properties: tile ({}),\n+ * i ({Number} x-pixel offset from top left), and j ({Integer} y-pixel\n+ * offset from top left).\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.Drag.prototype.deactivate.apply(this, arguments)) {\n- // call the cancel callback if mid-drawing\n- if (this.dragging) {\n- this.cancel();\n+ getTileData: function(loc) {\n+ var data = null,\n+ x = loc.lon,\n+ y = loc.lat,\n+ numRows = this.grid.length;\n+\n+ if (this.map && numRows) {\n+ var res = this.map.getResolution(),\n+ tileWidth = this.tileSize.w,\n+ tileHeight = this.tileSize.h,\n+ bounds = this.grid[0][0].bounds,\n+ left = bounds.left,\n+ top = bounds.top;\n+\n+ if (x < left) {\n+ // deal with multiple worlds\n+ if (this.map.baseLayer.wrapDateLine) {\n+ var worldWidth = this.map.getMaxExtent().getWidth();\n+ var worldsAway = Math.ceil((left - x) / worldWidth);\n+ x += worldWidth * worldsAway;\n+ }\n }\n- // If a layer's map property is set to null, it means that that\n- // layer isn't added to the map. Since we ourself added the layer\n- // to the map in activate(), we can assume that if this.layer.map\n- // is null it means that the layer has been destroyed (as a result\n- // of map.destroy() for example.\n- if (this.layer.map != null) {\n- this.layer.destroy(false);\n- if (this.feature) {\n- this.feature.destroy();\n+ // tile distance to location (fractional number of tiles);\n+ var dtx = (x - left) / (res * tileWidth);\n+ var dty = (top - y) / (res * tileHeight);\n+ // index of tile in grid\n+ var col = Math.floor(dtx);\n+ var row = Math.floor(dty);\n+ if (row >= 0 && row < numRows) {\n+ var tile = this.grid[row][col];\n+ if (tile) {\n+ data = {\n+ tile: tile,\n+ // pixel index within tile\n+ i: Math.floor((dtx - col) * tileWidth),\n+ j: Math.floor((dty - row) * tileHeight)\n+ };\n }\n }\n- this.layer = null;\n- this.feature = null;\n- deactivated = true;\n }\n- return deactivated;\n+ return data;\n },\n \n /**\n- * Method: down\n- * Start drawing a new feature\n+ * Method: destroyTile\n *\n * Parameters:\n- * evt - {Event} The drag start event\n+ * tile - {}\n */\n- down: function(evt) {\n- this.fixedRadius = !!(this.radius);\n- var maploc = this.layer.getLonLatFromViewPortPx(evt.xy);\n- this.origin = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat);\n- // create the new polygon\n- if (!this.fixedRadius || this.irregular) {\n- // smallest radius should not be less one pixel in map units\n- // VML doesn't behave well with smaller\n- this.radius = this.map.getResolution();\n- }\n- if (this.persist) {\n- this.clear();\n- }\n- this.feature = new OpenLayers.Feature.Vector();\n- this.createGeometry();\n- this.callback(\"create\", [this.origin, this.feature]);\n- this.layer.addFeatures([this.feature], {\n- silent: true\n- });\n- this.layer.drawFeature(this.feature, this.style);\n+ destroyTile: function(tile) {\n+ this.removeTileMonitoringHooks(tile);\n+ tile.destroy();\n },\n \n /**\n- * Method: move\n- * Respond to drag move events\n+ * Method: getServerResolution\n+ * Return the closest server-supported resolution.\n *\n * Parameters:\n- * evt - {Evt} The move event\n+ * resolution - {Number} The base resolution. If undefined the\n+ * map resolution is used.\n+ *\n+ * Returns:\n+ * {Number} The closest server resolution value.\n */\n- move: function(evt) {\n- var maploc = this.layer.getLonLatFromViewPortPx(evt.xy);\n- var point = new OpenLayers.Geometry.Point(maploc.lon, maploc.lat);\n- if (this.irregular) {\n- var ry = Math.sqrt(2) * Math.abs(point.y - this.origin.y) / 2;\n- this.radius = Math.max(this.map.getResolution() / 2, ry);\n- } else if (this.fixedRadius) {\n- this.origin = point;\n- } else {\n- this.calculateAngle(point, evt);\n- this.radius = Math.max(this.map.getResolution() / 2,\n- point.distanceTo(this.origin));\n- }\n- this.modifyGeometry();\n- if (this.irregular) {\n- var dx = point.x - this.origin.x;\n- var dy = point.y - this.origin.y;\n- var ratio;\n- if (dy == 0) {\n- ratio = dx / (this.radius * Math.sqrt(2));\n- } else {\n- ratio = dx / dy;\n+ getServerResolution: function(resolution) {\n+ var distance = Number.POSITIVE_INFINITY;\n+ resolution = resolution || this.map.getResolution();\n+ if (this.serverResolutions &&\n+ OpenLayers.Util.indexOf(this.serverResolutions, resolution) === -1) {\n+ var i, newDistance, newResolution, serverResolution;\n+ for (i = this.serverResolutions.length - 1; i >= 0; i--) {\n+ newResolution = this.serverResolutions[i];\n+ newDistance = Math.abs(newResolution - resolution);\n+ if (newDistance > distance) {\n+ break;\n+ }\n+ distance = newDistance;\n+ serverResolution = newResolution;\n }\n- this.feature.geometry.resize(1, this.origin, ratio);\n- this.feature.geometry.move(dx / 2, dy / 2);\n+ resolution = serverResolution;\n }\n- this.layer.drawFeature(this.feature, this.style);\n+ return resolution;\n },\n \n /**\n- * Method: up\n- * Finish drawing the feature\n+ * Method: getServerZoom\n+ * Return the zoom value corresponding to the best matching server\n+ * resolution, taking into account and .\n *\n- * Parameters:\n- * evt - {Event} The mouse up event\n+ * Returns:\n+ * {Number} The closest server supported zoom. This is not the map zoom\n+ * level, but an index of the server's resolutions array.\n */\n- up: function(evt) {\n- this.finalize();\n- // the mouseup method of superclass doesn't call the\n- // \"done\" callback if there's been no move between\n- // down and up\n- if (this.start == this.last) {\n- this.callback(\"done\", [evt.xy]);\n- }\n+ getServerZoom: function() {\n+ var resolution = this.getServerResolution();\n+ return this.serverResolutions ?\n+ OpenLayers.Util.indexOf(this.serverResolutions, resolution) :\n+ this.map.getZoomForResolution(resolution) + (this.zoomOffset || 0);\n },\n \n /**\n- * Method: out\n- * Finish drawing the feature.\n+ * Method: applyBackBuffer\n+ * Create, insert, scale and position a back buffer for the layer.\n *\n * Parameters:\n- * evt - {Event} The mouse out event\n- */\n- out: function(evt) {\n- this.finalize();\n- },\n-\n- /**\n- * Method: createGeometry\n- * Create the new polygon geometry. This is called at the start of the\n- * drag and at any point during the drag if the number of sides\n- * changes.\n+ * resolution - {Number} The resolution to transition to.\n */\n- createGeometry: function() {\n- this.angle = Math.PI * ((1 / this.sides) - (1 / 2));\n- if (this.snapAngle) {\n- this.angle += this.snapAngle * (Math.PI / 180);\n+ applyBackBuffer: function(resolution) {\n+ if (this.backBufferTimerId !== null) {\n+ this.removeBackBuffer();\n }\n- this.feature.geometry = OpenLayers.Geometry.Polygon.createRegularPolygon(\n- this.origin, this.radius, this.sides, this.snapAngle\n- );\n- },\n+ var backBuffer = this.backBuffer;\n+ if (!backBuffer) {\n+ backBuffer = this.createBackBuffer();\n+ if (!backBuffer) {\n+ return;\n+ }\n+ if (resolution === this.gridResolution) {\n+ this.div.insertBefore(backBuffer, this.div.firstChild);\n+ } else {\n+ this.map.baseLayer.div.parentNode.insertBefore(backBuffer, this.map.baseLayer.div);\n+ }\n+ this.backBuffer = backBuffer;\n \n- /**\n- * Method: modifyGeometry\n- * Modify the polygon geometry in place.\n- */\n- modifyGeometry: function() {\n- var angle, point;\n- var ring = this.feature.geometry.components[0];\n- // if the number of sides ever changes, create a new geometry\n- if (ring.components.length != (this.sides + 1)) {\n- this.createGeometry();\n- ring = this.feature.geometry.components[0];\n+ // set some information in the instance for subsequent\n+ // calls to applyBackBuffer where the same back buffer\n+ // is reused\n+ var topLeftTileBounds = this.grid[0][0].bounds;\n+ this.backBufferLonLat = {\n+ lon: topLeftTileBounds.left,\n+ lat: topLeftTileBounds.top\n+ };\n+ this.backBufferResolution = this.gridResolution;\n }\n- for (var i = 0; i < this.sides; ++i) {\n- point = ring.components[i];\n- angle = this.angle + (i * 2 * Math.PI / this.sides);\n- point.x = this.origin.x + (this.radius * Math.cos(angle));\n- point.y = this.origin.y + (this.radius * Math.sin(angle));\n- point.clearBounds();\n+\n+ var ratio = this.backBufferResolution / resolution;\n+\n+ // scale the tiles inside the back buffer\n+ var tiles = backBuffer.childNodes,\n+ tile;\n+ for (var i = tiles.length - 1; i >= 0; --i) {\n+ tile = tiles[i];\n+ tile.style.top = ((ratio * tile._i * tile._h) | 0) + 'px';\n+ tile.style.left = ((ratio * tile._j * tile._w) | 0) + 'px';\n+ tile.style.width = Math.round(ratio * tile._w) + 'px';\n+ tile.style.height = Math.round(ratio * tile._h) + 'px';\n }\n+\n+ // and position it (based on the grid's top-left corner)\n+ var position = this.getViewPortPxFromLonLat(\n+ this.backBufferLonLat, resolution);\n+ var leftOffset = this.map.layerContainerOriginPx.x;\n+ var topOffset = this.map.layerContainerOriginPx.y;\n+ backBuffer.style.left = Math.round(position.x - leftOffset) + 'px';\n+ backBuffer.style.top = Math.round(position.y - topOffset) + 'px';\n },\n \n /**\n- * Method: calculateAngle\n- * Calculate the angle based on settings.\n+ * Method: createBackBuffer\n+ * Create a back buffer.\n *\n- * Parameters:\n- * point - {}\n- * evt - {Event}\n+ * Returns:\n+ * {DOMElement} The DOM element for the back buffer, undefined if the\n+ * grid isn't initialized yet.\n */\n- calculateAngle: function(point, evt) {\n- var alpha = Math.atan2(point.y - this.origin.y,\n- point.x - this.origin.x);\n- if (this.snapAngle && (this.snapToggle && !evt[this.snapToggle])) {\n- var snapAngleRad = (Math.PI / 180) * this.snapAngle;\n- this.angle = Math.round(alpha / snapAngleRad) * snapAngleRad;\n- } else {\n- this.angle = alpha;\n+ createBackBuffer: function() {\n+ var backBuffer;\n+ if (this.grid.length > 0) {\n+ backBuffer = document.createElement('div');\n+ backBuffer.id = this.div.id + '_bb';\n+ backBuffer.className = 'olBackBuffer';\n+ backBuffer.style.position = 'absolute';\n+ var map = this.map;\n+ backBuffer.style.zIndex = this.transitionEffect === 'resize' ?\n+ this.getZIndex() - 1 :\n+ // 'map-resize':\n+ map.Z_INDEX_BASE.BaseLayer -\n+ (map.getNumLayers() - map.getLayerIndex(this));\n+ for (var i = 0, lenI = this.grid.length; i < lenI; i++) {\n+ for (var j = 0, lenJ = this.grid[i].length; j < lenJ; j++) {\n+ var tile = this.grid[i][j],\n+ markup = this.grid[i][j].createBackBuffer();\n+ if (markup) {\n+ markup._i = i;\n+ markup._j = j;\n+ markup._w = tile.size.w;\n+ markup._h = tile.size.h;\n+ markup.id = tile.id + '_bb';\n+ backBuffer.appendChild(markup);\n+ }\n+ }\n+ }\n }\n+ return backBuffer;\n },\n \n /**\n- * APIMethod: cancel\n- * Finish the geometry and call the \"cancel\" callback.\n+ * Method: removeBackBuffer\n+ * Remove back buffer from DOM.\n */\n- cancel: function() {\n- // the polygon geometry gets cloned in the callback method\n- this.callback(\"cancel\", null);\n- this.finalize();\n+ removeBackBuffer: function() {\n+ if (this._transitionElement) {\n+ for (var i = this.transitionendEvents.length - 1; i >= 0; --i) {\n+ OpenLayers.Event.stopObserving(this._transitionElement,\n+ this.transitionendEvents[i], this._removeBackBuffer);\n+ }\n+ delete this._transitionElement;\n+ }\n+ if (this.backBuffer) {\n+ if (this.backBuffer.parentNode) {\n+ this.backBuffer.parentNode.removeChild(this.backBuffer);\n+ }\n+ this.backBuffer = null;\n+ this.backBufferResolution = null;\n+ if (this.backBufferTimerId !== null) {\n+ window.clearTimeout(this.backBufferTimerId);\n+ this.backBufferTimerId = null;\n+ }\n+ }\n },\n \n /**\n- * Method: finalize\n- * Finish the geometry and call the \"done\" callback.\n+ * Method: moveByPx\n+ * Move the layer based on pixel vector.\n+ *\n+ * Parameters:\n+ * dx - {Number}\n+ * dy - {Number}\n */\n- finalize: function() {\n- this.origin = null;\n- this.radius = this.options.radius;\n+ moveByPx: function(dx, dy) {\n+ if (!this.singleTile) {\n+ this.moveGriddedTiles();\n+ }\n },\n \n /**\n- * APIMethod: clear\n- * Clear any rendered features on the temporary layer. This is called\n- * when the handler is deactivated, canceled, or done (unless persist\n- * is true).\n+ * APIMethod: setTileSize\n+ * Check if we are in singleTile mode and if so, set the size as a ratio\n+ * of the map size (as specified by the layer's 'ratio' property).\n+ * \n+ * Parameters:\n+ * size - {}\n */\n- clear: function() {\n- if (this.layer) {\n- this.layer.renderer.clear();\n- this.layer.destroyFeatures();\n+ setTileSize: function(size) {\n+ if (this.singleTile) {\n+ size = this.map.getSize();\n+ size.h = parseInt(size.h * this.ratio, 10);\n+ size.w = parseInt(size.w * this.ratio, 10);\n }\n+ OpenLayers.Layer.HTTPRequest.prototype.setTileSize.apply(this, [size]);\n },\n \n /**\n- * Method: callback\n- * Trigger the control's named callback with the given arguments\n+ * APIMethod: getTilesBounds\n+ * Return the bounds of the tile grid.\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 with which to call the callback\n- * (defined by the control).\n+ * Returns:\n+ * {} A Bounds object representing the bounds of all the\n+ * currently loaded tiles (including those partially or not at all seen \n+ * onscreen).\n */\n- callback: function(name, args) {\n- // override the callback method to always send the polygon geometry\n- if (this.callbacks[name]) {\n- this.callbacks[name].apply(this.control,\n- [this.feature.geometry.clone()]);\n- }\n- // since sketch features are added to the temporary layer\n- // they must be cleared here if done or cancel\n- if (!this.persist && (name == \"done\" || name == \"cancel\")) {\n- this.clear();\n- }\n- },\n-\n- CLASS_NAME: \"OpenLayers.Handler.RegularPolygon\"\n-});\n-/* ======================================================================\n- OpenLayers/Handler/Pinch.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+ getTilesBounds: function() {\n+ var bounds = null;\n \n-/**\n- * @requires OpenLayers/Handler.js\n- */\n+ var length = this.grid.length;\n+ if (length) {\n+ var bottomLeftTileBounds = this.grid[length - 1][0].bounds,\n+ width = this.grid[0].length * bottomLeftTileBounds.getWidth(),\n+ height = this.grid.length * bottomLeftTileBounds.getHeight();\n \n-/**\n- * Class: OpenLayers.Handler.Pinch\n- * The pinch handler is used to deal with sequences of browser events related\n- * to pinch gestures. The handler is used by controls that want to know\n- * when a pinch sequence begins, when a pinch is happening, and when it has\n- * finished.\n- *\n- * Controls that use the pinch handler typically construct it with callbacks\n- * for 'start', 'move', and 'done'. Callbacks for these keys are\n- * called when the pinch begins, with each change, and when the pinch is\n- * done.\n- *\n- * Create a new pinch handler with the constructor.\n- *\n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {\n+ bounds = new OpenLayers.Bounds(bottomLeftTileBounds.left,\n+ bottomLeftTileBounds.bottom,\n+ bottomLeftTileBounds.left + width,\n+ bottomLeftTileBounds.bottom + height);\n+ }\n+ return bounds;\n+ },\n \n /**\n- * Property: started\n- * {Boolean} When a touchstart event is received, we want to record it,\n- * but not set 'pinching' until the touchmove get started after\n- * starting.\n+ * Method: initSingleTile\n+ * \n+ * Parameters: \n+ * bounds - {}\n */\n- started: false,\n+ initSingleTile: function(bounds) {\n+ this.events.triggerEvent(\"retile\");\n \n- /**\n- * Property: stopDown\n- * {Boolean} Stop propagation of touchstart events from getting to\n- * listeners on the same element. Default is false.\n- */\n- stopDown: false,\n+ //determine new tile bounds\n+ var center = bounds.getCenterLonLat();\n+ var tileWidth = bounds.getWidth() * this.ratio;\n+ var tileHeight = bounds.getHeight() * this.ratio;\n \n- /**\n- * Property: pinching\n- * {Boolean}\n- */\n- pinching: false,\n+ var tileBounds =\n+ new OpenLayers.Bounds(center.lon - (tileWidth / 2),\n+ center.lat - (tileHeight / 2),\n+ center.lon + (tileWidth / 2),\n+ center.lat + (tileHeight / 2));\n \n- /**\n- * Property: last\n- * {Object} Object that store informations related to pinch last touch.\n- */\n- last: null,\n+ var px = this.map.getLayerPxFromLonLat({\n+ lon: tileBounds.left,\n+ lat: tileBounds.top\n+ });\n \n- /**\n- * Property: start\n- * {Object} Object that store informations related to pinch touchstart.\n- */\n- start: null,\n+ if (!this.grid.length) {\n+ this.grid[0] = [];\n+ }\n \n- /**\n- * Constructor: OpenLayers.Handler.Pinch\n- * Returns OpenLayers.Handler.Pinch\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 functions to be called when\n- * the pinch operation start, change, or is finished. The callbacks\n- * should expect to receive an object argument, which contains\n- * information about scale, distance, and position of touch points.\n- * options - {Object}\n- */\n+ var tile = this.grid[0][0];\n+ if (!tile) {\n+ tile = this.addTile(tileBounds, px);\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- var propagate = true;\n- this.pinching = false;\n- if (OpenLayers.Event.isMultiTouch(evt)) {\n- this.started = true;\n- this.last = this.start = {\n- distance: this.getDistance(evt.touches),\n- delta: 0,\n- scale: 1\n- };\n- this.callback(\"start\", [evt, this.start]);\n- propagate = !this.stopDown;\n- } else if (this.started) {\n- // Some webkit versions send fake single-touch events during\n- // multitouch, which cause the drag handler to trigger\n- return false;\n+ this.addTileMonitoringHooks(tile);\n+ tile.draw();\n+ this.grid[0][0] = tile;\n } else {\n- this.started = false;\n- this.start = null;\n- this.last = null;\n+ tile.moveTo(tileBounds, px);\n }\n- // prevent document dragging\n- OpenLayers.Event.preventDefault(evt);\n- return propagate;\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- if (this.started && OpenLayers.Event.isMultiTouch(evt)) {\n- this.pinching = true;\n- var current = this.getPinchData(evt);\n- this.callback(\"move\", [evt, current]);\n- this.last = current;\n- // prevent document dragging\n- OpenLayers.Event.stop(evt);\n- } else if (this.started) {\n- // Some webkit versions send fake single-touch events during\n- // multitouch, which cause the drag handler to trigger\n- return false;\n- }\n- return true;\n+ //remove all but our single tile\n+ this.removeExcessTiles(1, 1);\n+\n+ // store the resolution of the grid\n+ this.gridResolution = this.getServerResolution();\n },\n \n- /**\n- * Method: touchend\n- * Handle touchend events\n+ /** \n+ * Method: calculateGridLayout\n+ * Generate parameters for the grid layout.\n *\n * Parameters:\n- * evt - {Event}\n+ * bounds - {|Object} OpenLayers.Bounds or an\n+ * object with a 'left' and 'top' properties.\n+ * origin - {|Object} OpenLayers.LonLat or an\n+ * object with a 'lon' and 'lat' properties.\n+ * resolution - {Number}\n *\n * Returns:\n- * {Boolean} Let the event propagate.\n+ * {Object} Object containing properties tilelon, tilelat, startcol,\n+ * startrow\n */\n- touchend: function(evt) {\n- if (this.started && !OpenLayers.Event.isMultiTouch(evt)) {\n- this.started = false;\n- this.pinching = false;\n- this.callback(\"done\", [evt, this.start, this.last]);\n- this.start = null;\n- this.last = null;\n- return false;\n- }\n- return true;\n- },\n+ calculateGridLayout: function(bounds, origin, resolution) {\n+ var tilelon = resolution * this.tileSize.w;\n+ var tilelat = resolution * this.tileSize.h;\n+\n+ var offsetlon = bounds.left - origin.lon;\n+ var tilecol = Math.floor(offsetlon / tilelon) - this.buffer;\n+\n+ var rowSign = this.rowSign;\n+\n+ var offsetlat = rowSign * (origin.lat - bounds.top + tilelat);\n+ var tilerow = Math[~rowSign ? 'floor' : 'ceil'](offsetlat / tilelat) - this.buffer * rowSign;\n+\n+ return {\n+ tilelon: tilelon,\n+ tilelat: tilelat,\n+ startcol: tilecol,\n+ startrow: tilerow\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.pinching = false;\n- activated = true;\n- }\n- return activated;\n },\n \n /**\n- * Method: deactivate\n- * Deactivate the handler.\n+ * Method: getTileOrigin\n+ * Determine the origin for aligning the grid of tiles. If a \n+ * property is supplied, that will be returned. Otherwise, the origin\n+ * will be derived from the layer's property. In this case,\n+ * the tile origin will be the corner of the given by the \n+ * property.\n *\n * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * {} The tile origin.\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.started = false;\n- this.pinching = false;\n- this.start = null;\n- this.last = null;\n- deactivated = true;\n+ getTileOrigin: function() {\n+ var origin = this.tileOrigin;\n+ if (!origin) {\n+ var extent = this.getMaxExtent();\n+ var edges = ({\n+ \"tl\": [\"left\", \"top\"],\n+ \"tr\": [\"right\", \"top\"],\n+ \"bl\": [\"left\", \"bottom\"],\n+ \"br\": [\"right\", \"bottom\"]\n+ })[this.tileOriginCorner];\n+ origin = new OpenLayers.LonLat(extent[edges[0]], extent[edges[1]]);\n }\n- return deactivated;\n+ return origin;\n },\n \n /**\n- * Method: getDistance\n- * Get the distance in pixels between two touches.\n+ * Method: getTileBoundsForGridIndex\n *\n * Parameters:\n- * touches - {Array(Object)}\n+ * row - {Number} The row of the grid\n+ * col - {Number} The column of the grid\n *\n * Returns:\n- * {Number} The distance in pixels.\n+ * {} The bounds for the tile at (row, col)\n */\n- getDistance: function(touches) {\n- var t0 = touches[0];\n- var t1 = touches[1];\n- return Math.sqrt(\n- Math.pow(t0.olClientX - t1.olClientX, 2) +\n- Math.pow(t0.olClientY - t1.olClientY, 2)\n+ getTileBoundsForGridIndex: function(row, col) {\n+ var origin = this.getTileOrigin();\n+ var tileLayout = this.gridLayout;\n+ var tilelon = tileLayout.tilelon;\n+ var tilelat = tileLayout.tilelat;\n+ var startcol = tileLayout.startcol;\n+ var startrow = tileLayout.startrow;\n+ var rowSign = this.rowSign;\n+ return new OpenLayers.Bounds(\n+ origin.lon + (startcol + col) * tilelon,\n+ origin.lat - (startrow + row * rowSign) * tilelat * rowSign,\n+ origin.lon + (startcol + col + 1) * tilelon,\n+ origin.lat - (startrow + (row - 1) * rowSign) * tilelat * rowSign\n );\n },\n \n-\n /**\n- * Method: getPinchData\n- * Get informations about the pinch event.\n- *\n+ * Method: initGriddedTiles\n+ * \n * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Object} Object that contains data about the current pinch.\n+ * bounds - {}\n */\n- getPinchData: function(evt) {\n- var distance = this.getDistance(evt.touches);\n- var scale = distance / this.start.distance;\n- return {\n- distance: distance,\n- delta: this.last.distance - distance,\n- scale: scale\n- };\n- },\n+ initGriddedTiles: function(bounds) {\n+ this.events.triggerEvent(\"retile\");\n \n- CLASS_NAME: \"OpenLayers.Handler.Pinch\"\n-});\n+ // work out mininum number of rows and columns; this is the number of\n+ // tiles required to cover the viewport plus at least one for panning\n \n-/* ======================================================================\n- OpenLayers/Handler/MouseWheel.js\n- ====================================================================== */\n+ var viewSize = this.map.getSize();\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+ var origin = this.getTileOrigin();\n+ var resolution = this.map.getResolution(),\n+ serverResolution = this.getServerResolution(),\n+ ratio = resolution / serverResolution,\n+ tileSize = {\n+ w: this.tileSize.w / ratio,\n+ h: this.tileSize.h / ratio\n+ };\n \n-/**\n- * @requires OpenLayers/Handler.js\n- */\n+ var minRows = Math.ceil(viewSize.h / tileSize.h) +\n+ 2 * this.buffer + 1;\n+ var minCols = Math.ceil(viewSize.w / tileSize.w) +\n+ 2 * this.buffer + 1;\n \n-/**\n- * Class: OpenLayers.Handler.MouseWheel\n- * Handler for wheel up/down events.\n- * \n- * Inherits from:\n- * - \n- */\n-OpenLayers.Handler.MouseWheel = OpenLayers.Class(OpenLayers.Handler, {\n- /** \n- * Property: wheelListener \n- * {function} \n- */\n- wheelListener: null,\n+ var tileLayout = this.calculateGridLayout(bounds, origin, serverResolution);\n+ this.gridLayout = tileLayout;\n \n- /**\n- * Property: interval\n- * {Integer} In order to increase server performance, an interval (in \n- * milliseconds) can be set to reduce the number of up/down events \n- * called. If set, a new up/down event will not be set until the \n- * interval has passed. \n- * Defaults to 0, meaning no interval. \n- */\n- interval: 0,\n+ var tilelon = tileLayout.tilelon;\n+ var tilelat = tileLayout.tilelat;\n \n- /**\n- * Property: maxDelta\n- * {Integer} Maximum delta to collect before breaking from the current\n- * interval. In cumulative mode, this also limits the maximum delta\n- * returned from the handler. Default is Number.POSITIVE_INFINITY.\n- */\n- maxDelta: Number.POSITIVE_INFINITY,\n+ var layerContainerDivLeft = this.map.layerContainerOriginPx.x;\n+ var layerContainerDivTop = this.map.layerContainerOriginPx.y;\n \n- /**\n- * Property: delta\n- * {Integer} When interval is set, delta collects the mousewheel z-deltas\n- * of the events that occur within the interval.\n- * See also the cumulative option\n- */\n- delta: 0,\n+ var tileBounds = this.getTileBoundsForGridIndex(0, 0);\n+ var startPx = this.map.getViewPortPxFromLonLat(\n+ new OpenLayers.LonLat(tileBounds.left, tileBounds.top)\n+ );\n+ startPx.x = Math.round(startPx.x) - layerContainerDivLeft;\n+ startPx.y = Math.round(startPx.y) - layerContainerDivTop;\n \n- /**\n- * Property: cumulative\n- * {Boolean} When interval is set: true to collect all the mousewheel \n- * z-deltas, false to only record the delta direction (positive or\n- * negative)\n- */\n- cumulative: true,\n+ var tileData = [],\n+ center = this.map.getCenter();\n \n- /**\n- * Constructor: OpenLayers.Handler.MouseWheel\n- *\n- * Parameters:\n- * control - {} \n- * callbacks - {Object} An object containing a single function to be\n- * called when the drag operation is finished.\n- * The callback should expect to recieve a single\n- * argument, the point geometry.\n- * options - {Object} \n- */\n- initialize: function(control, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, arguments);\n- this.wheelListener = OpenLayers.Function.bindAsEventListener(\n- this.onWheelEvent, this\n- );\n+ var rowidx = 0;\n+ do {\n+ var row = this.grid[rowidx];\n+ if (!row) {\n+ row = [];\n+ this.grid.push(row);\n+ }\n+\n+ var colidx = 0;\n+ do {\n+ tileBounds = this.getTileBoundsForGridIndex(rowidx, colidx);\n+ var px = startPx.clone();\n+ px.x = px.x + colidx * Math.round(tileSize.w);\n+ px.y = px.y + rowidx * Math.round(tileSize.h);\n+ var tile = row[colidx];\n+ if (!tile) {\n+ tile = this.addTile(tileBounds, px);\n+ this.addTileMonitoringHooks(tile);\n+ row.push(tile);\n+ } else {\n+ tile.moveTo(tileBounds, px, false);\n+ }\n+ var tileCenter = tileBounds.getCenterLonLat();\n+ tileData.push({\n+ tile: tile,\n+ distance: Math.pow(tileCenter.lon - center.lon, 2) +\n+ Math.pow(tileCenter.lat - center.lat, 2)\n+ });\n+\n+ colidx += 1;\n+ } while ((tileBounds.right <= bounds.right + tilelon * this.buffer) ||\n+ colidx < minCols);\n+\n+ rowidx += 1;\n+ } while ((tileBounds.bottom >= bounds.bottom - tilelat * this.buffer) ||\n+ rowidx < minRows);\n+\n+ //shave off exceess rows and colums\n+ this.removeExcessTiles(rowidx, colidx);\n+\n+ var resolution = this.getServerResolution();\n+ // store the resolution of the grid\n+ this.gridResolution = resolution;\n+\n+ //now actually draw the tiles\n+ tileData.sort(function(a, b) {\n+ return a.distance - b.distance;\n+ });\n+ for (var i = 0, ii = tileData.length; i < ii; ++i) {\n+ tileData[i].tile.draw();\n+ }\n },\n \n /**\n- * Method: destroy\n+ * Method: getMaxExtent\n+ * Get this layer's maximum extent. (Implemented as a getter for\n+ * potential specific implementations in sub-classes.)\n+ *\n+ * Returns:\n+ * {}\n */\n- destroy: function() {\n- OpenLayers.Handler.prototype.destroy.apply(this, arguments);\n- this.wheelListener = null;\n+ getMaxExtent: function() {\n+ return this.maxExtent;\n },\n \n /**\n- * Mouse ScrollWheel code thanks to http://adomas.org/javascript-mouse-wheel/\n+ * APIMethod: addTile\n+ * Create a tile, initialize it, and add it to the layer div. \n+ *\n+ * Parameters\n+ * bounds - {}\n+ * position - {}\n+ *\n+ * Returns:\n+ * {} The added OpenLayers.Tile\n */\n+ addTile: function(bounds, position) {\n+ var tile = new this.tileClass(\n+ this, position, bounds, null, this.tileSize, this.tileOptions\n+ );\n+ this.events.triggerEvent(\"addtile\", {\n+ tile: tile\n+ });\n+ return tile;\n+ },\n \n /** \n- * Method: onWheelEvent\n- * Catch the wheel event and handle it xbrowserly\n+ * Method: addTileMonitoringHooks\n+ * This function takes a tile as input and adds the appropriate hooks to \n+ * the tile so that the layer can keep track of the loading tiles.\n * \n- * Parameters:\n- * e - {Event} \n+ * Parameters: \n+ * tile - {}\n */\n- onWheelEvent: function(e) {\n-\n- // make sure we have a map and check keyboard modifiers\n- if (!this.map || !this.checkModifiers(e)) {\n- return;\n- }\n+ addTileMonitoringHooks: function(tile) {\n \n- // Ride up the element's DOM hierarchy to determine if it or any of \n- // its ancestors was: \n- // * specifically marked as scrollable (CSS overflow property)\n- // * one of our layer divs or a div marked as scrollable\n- // ('olScrollable' CSS class)\n- // * the map div\n- //\n- var overScrollableDiv = false;\n- var allowScroll = false;\n- var overMapDiv = false;\n+ var replacingCls = 'olTileReplacing';\n \n- var elem = OpenLayers.Event.element(e);\n- while ((elem != null) && !overMapDiv && !overScrollableDiv) {\n+ tile.onLoadStart = function() {\n+ //if that was first tile then trigger a 'loadstart' on the layer\n+ if (this.loading === false) {\n+ this.loading = true;\n+ this.events.triggerEvent(\"loadstart\");\n+ }\n+ this.events.triggerEvent(\"tileloadstart\", {\n+ tile: tile\n+ });\n+ this.numLoadingTiles++;\n+ if (!this.singleTile && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n+ OpenLayers.Element.addClass(tile.getTile(), replacingCls);\n+ }\n+ };\n \n- if (!overScrollableDiv) {\n- try {\n- var overflow;\n- if (elem.currentStyle) {\n- overflow = elem.currentStyle[\"overflow\"];\n- } else {\n- var style =\n- document.defaultView.getComputedStyle(elem, null);\n- overflow = style.getPropertyValue(\"overflow\");\n+ tile.onLoadEnd = function(evt) {\n+ this.numLoadingTiles--;\n+ var aborted = evt.type === 'unload';\n+ this.events.triggerEvent(\"tileloaded\", {\n+ tile: tile,\n+ aborted: aborted\n+ });\n+ if (!this.singleTile && !aborted && this.backBuffer && this.gridResolution === this.backBufferResolution) {\n+ var tileDiv = tile.getTile();\n+ if (OpenLayers.Element.getStyle(tileDiv, 'display') === 'none') {\n+ var bufferTile = document.getElementById(tile.id + '_bb');\n+ if (bufferTile) {\n+ bufferTile.parentNode.removeChild(bufferTile);\n }\n- overScrollableDiv = (overflow &&\n- (overflow == \"auto\") || (overflow == \"scroll\"));\n- } catch (err) {\n- //sometimes when scrolling in a popup, this causes \n- // obscure browser error\n }\n+ OpenLayers.Element.removeClass(tileDiv, replacingCls);\n }\n-\n- if (!allowScroll) {\n- allowScroll = OpenLayers.Element.hasClass(elem, 'olScrollable');\n- if (!allowScroll) {\n- for (var i = 0, len = this.map.layers.length; i < len; i++) {\n- // Are we in the layer div? Note that we have two cases\n- // here: one is to catch EventPane layers, which have a\n- // pane above the layer (layer.pane)\n- var layer = this.map.layers[i];\n- if (elem == layer.div || elem == layer.pane) {\n- allowScroll = true;\n- break;\n+ //if that was the last tile, then trigger a 'loadend' on the layer\n+ if (this.numLoadingTiles === 0) {\n+ if (this.backBuffer) {\n+ if (this.backBuffer.childNodes.length === 0) {\n+ // no tiles transitioning, remove immediately\n+ this.removeBackBuffer();\n+ } else {\n+ // wait until transition has ended or delay has passed\n+ this._transitionElement = aborted ?\n+ this.div.lastChild : tile.imgDiv;\n+ var transitionendEvents = this.transitionendEvents;\n+ for (var i = transitionendEvents.length - 1; i >= 0; --i) {\n+ OpenLayers.Event.observe(this._transitionElement,\n+ transitionendEvents[i],\n+ this._removeBackBuffer);\n }\n+ // the removal of the back buffer is delayed to prevent\n+ // flash effects due to the animation of tile displaying\n+ this.backBufferTimerId = window.setTimeout(\n+ this._removeBackBuffer, this.removeBackBufferDelay\n+ );\n }\n }\n+ this.loading = false;\n+ this.events.triggerEvent(\"loadend\");\n }\n- overMapDiv = (elem == this.map.div);\n+ };\n \n- elem = elem.parentNode;\n- }\n+ tile.onLoadError = function() {\n+ this.events.triggerEvent(\"tileerror\", {\n+ tile: tile\n+ });\n+ };\n \n- // Logic below is the following:\n- //\n- // If we are over a scrollable div or not over the map div:\n- // * do nothing (let the browser handle scrolling)\n- //\n- // otherwise \n- // \n- // If we are over the layer div or a 'olScrollable' div:\n- // * zoom/in out\n- // then\n- // * kill event (so as not to also scroll the page after zooming)\n- //\n- // otherwise\n- //\n- // Kill the event (dont scroll the page if we wheel over the \n- // layerswitcher or the pan/zoom control)\n- //\n- if (!overScrollableDiv && overMapDiv) {\n- if (allowScroll) {\n- var delta = 0;\n+ tile.events.on({\n+ \"loadstart\": tile.onLoadStart,\n+ \"loadend\": tile.onLoadEnd,\n+ \"unload\": tile.onLoadEnd,\n+ \"loaderror\": tile.onLoadError,\n+ scope: this\n+ });\n+ },\n \n- if (e.wheelDelta) {\n- delta = e.wheelDelta;\n- if (delta % 160 === 0) {\n- // opera have steps of 160 instead of 120\n- delta = delta * 0.75;\n- }\n- delta = delta / 120;\n- } else if (e.detail) {\n- // detail in Firefox on OS X is 1/3 of Windows\n- // so force delta 1 / -1\n- delta = -(e.detail / Math.abs(e.detail));\n- }\n- this.delta += delta;\n+ /** \n+ * Method: removeTileMonitoringHooks\n+ * This function takes a tile as input and removes the tile hooks \n+ * that were added in addTileMonitoringHooks()\n+ * \n+ * Parameters: \n+ * tile - {}\n+ */\n+ removeTileMonitoringHooks: function(tile) {\n+ tile.unload();\n+ tile.events.un({\n+ \"loadstart\": tile.onLoadStart,\n+ \"loadend\": tile.onLoadEnd,\n+ \"unload\": tile.onLoadEnd,\n+ \"loaderror\": tile.onLoadError,\n+ scope: this\n+ });\n+ },\n \n- window.clearTimeout(this._timeoutId);\n- if (this.interval && Math.abs(this.delta) < this.maxDelta) {\n- // store e because window.event might change during delay\n- var evt = OpenLayers.Util.extend({}, e);\n- this._timeoutId = window.setTimeout(\n- OpenLayers.Function.bind(function() {\n- this.wheelZoom(evt);\n- }, this),\n- this.interval\n- );\n- } else {\n- this.wheelZoom(e);\n- }\n+ /**\n+ * Method: moveGriddedTiles\n+ */\n+ moveGriddedTiles: function() {\n+ var buffer = this.buffer + 1;\n+ while (true) {\n+ var tlTile = this.grid[0][0];\n+ var tlViewPort = {\n+ x: tlTile.position.x +\n+ this.map.layerContainerOriginPx.x,\n+ y: tlTile.position.y +\n+ this.map.layerContainerOriginPx.y\n+ };\n+ var ratio = this.getServerResolution() / this.map.getResolution();\n+ var tileSize = {\n+ w: Math.round(this.tileSize.w * ratio),\n+ h: Math.round(this.tileSize.h * ratio)\n+ };\n+ if (tlViewPort.x > -tileSize.w * (buffer - 1)) {\n+ this.shiftColumn(true, tileSize);\n+ } else if (tlViewPort.x < -tileSize.w * buffer) {\n+ this.shiftColumn(false, tileSize);\n+ } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {\n+ this.shiftRow(true, tileSize);\n+ } else if (tlViewPort.y < -tileSize.h * buffer) {\n+ this.shiftRow(false, tileSize);\n+ } else {\n+ break;\n }\n- OpenLayers.Event.stop(e);\n }\n },\n \n /**\n- * Method: wheelZoom\n- * Given the wheel event, we carry out the appropriate zooming in or out,\n- * based on the 'wheelDelta' or 'detail' property of the event.\n+ * Method: shiftRow\n+ * Shifty grid work\n+ *\n+ * Parameters:\n+ * prepend - {Boolean} if true, prepend to beginning.\n+ * if false, then append to end\n+ * tileSize - {Object} rendered tile size; object with w and h properties\n+ */\n+ shiftRow: function(prepend, tileSize) {\n+ var grid = this.grid;\n+ var rowIndex = prepend ? 0 : (grid.length - 1);\n+ var sign = prepend ? -1 : 1;\n+ var rowSign = this.rowSign;\n+ var tileLayout = this.gridLayout;\n+ tileLayout.startrow += sign * rowSign;\n+\n+ var modelRow = grid[rowIndex];\n+ var row = grid[prepend ? 'pop' : 'shift']();\n+ for (var i = 0, len = row.length; i < len; i++) {\n+ var tile = row[i];\n+ var position = modelRow[i].position.clone();\n+ position.y += tileSize.h * sign;\n+ tile.moveTo(this.getTileBoundsForGridIndex(rowIndex, i), position);\n+ }\n+ grid[prepend ? 'unshift' : 'push'](row);\n+ },\n+\n+ /**\n+ * Method: shiftColumn\n+ * Shift grid work in the other dimension\n+ *\n+ * Parameters:\n+ * prepend - {Boolean} if true, prepend to beginning.\n+ * if false, then append to end\n+ * tileSize - {Object} rendered tile size; object with w and h properties\n+ */\n+ shiftColumn: function(prepend, tileSize) {\n+ var grid = this.grid;\n+ var colIndex = prepend ? 0 : (grid[0].length - 1);\n+ var sign = prepend ? -1 : 1;\n+ var tileLayout = this.gridLayout;\n+ tileLayout.startcol += sign;\n+\n+ for (var i = 0, len = grid.length; i < len; i++) {\n+ var row = grid[i];\n+ var position = row[colIndex].position.clone();\n+ var tile = row[prepend ? 'pop' : 'shift']();\n+ position.x += tileSize.w * sign;\n+ tile.moveTo(this.getTileBoundsForGridIndex(i, colIndex), position);\n+ row[prepend ? 'unshift' : 'push'](tile);\n+ }\n+ },\n+\n+ /**\n+ * Method: removeExcessTiles\n+ * When the size of the map or the buffer changes, we may need to\n+ * remove some excess rows and columns.\n * \n * Parameters:\n- * e - {Event}\n+ * rows - {Integer} Maximum number of rows we want our grid to have.\n+ * columns - {Integer} Maximum number of columns we want our grid to have.\n */\n- wheelZoom: function(e) {\n- var delta = this.delta;\n- this.delta = 0;\n+ removeExcessTiles: function(rows, columns) {\n+ var i, l;\n \n- if (delta) {\n- e.xy = this.map.events.getMousePosition(e);\n- if (delta < 0) {\n- this.callback(\"down\",\n- [e, this.cumulative ? Math.max(-this.maxDelta, delta) : -1]);\n- } else {\n- this.callback(\"up\",\n- [e, this.cumulative ? Math.min(this.maxDelta, delta) : 1]);\n+ // remove extra rows\n+ while (this.grid.length > rows) {\n+ var row = this.grid.pop();\n+ for (i = 0, l = row.length; i < l; i++) {\n+ var tile = row[i];\n+ this.destroyTile(tile);\n+ }\n+ }\n+\n+ // remove extra columns\n+ for (i = 0, l = this.grid.length; i < l; i++) {\n+ while (this.grid[i].length > columns) {\n+ var row = this.grid[i];\n+ var tile = row.pop();\n+ this.destroyTile(tile);\n }\n }\n },\n \n /**\n- * Method: activate \n+ * Method: onMapResize\n+ * For singleTile layers, this will set a new tile size according to the\n+ * dimensions of the map pane.\n */\n- activate: function(evt) {\n- if (OpenLayers.Handler.prototype.activate.apply(this, arguments)) {\n- //register mousewheel events specifically on the window and document\n- var wheelListener = this.wheelListener;\n- OpenLayers.Event.observe(window, \"DOMMouseScroll\", wheelListener);\n- OpenLayers.Event.observe(window, \"mousewheel\", wheelListener);\n- OpenLayers.Event.observe(document, \"mousewheel\", wheelListener);\n- return true;\n- } else {\n- return false;\n+ onMapResize: function() {\n+ if (this.singleTile) {\n+ this.clearGrid();\n+ this.setTileSize();\n }\n },\n \n /**\n- * Method: deactivate \n+ * APIMethod: getTileBounds\n+ * Returns The tile bounds for a layer given a pixel location.\n+ *\n+ * Parameters:\n+ * viewPortPx - {} The location in the viewport.\n+ *\n+ * Returns:\n+ * {} Bounds of the tile at the given pixel location.\n */\n- deactivate: function(evt) {\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- // unregister mousewheel events specifically on the window and document\n- var wheelListener = this.wheelListener;\n- OpenLayers.Event.stopObserving(window, \"DOMMouseScroll\", wheelListener);\n- OpenLayers.Event.stopObserving(window, \"mousewheel\", wheelListener);\n- OpenLayers.Event.stopObserving(document, \"mousewheel\", wheelListener);\n- return true;\n- } else {\n- return false;\n- }\n+ getTileBounds: function(viewPortPx) {\n+ var maxExtent = this.maxExtent;\n+ var resolution = this.getResolution();\n+ var tileMapWidth = resolution * this.tileSize.w;\n+ var tileMapHeight = resolution * this.tileSize.h;\n+ var mapPoint = this.getLonLatFromViewPortPx(viewPortPx);\n+ var tileLeft = maxExtent.left + (tileMapWidth *\n+ Math.floor((mapPoint.lon -\n+ maxExtent.left) /\n+ tileMapWidth));\n+ var tileBottom = maxExtent.bottom + (tileMapHeight *\n+ Math.floor((mapPoint.lat -\n+ maxExtent.bottom) /\n+ tileMapHeight));\n+ return new OpenLayers.Bounds(tileLeft, tileBottom,\n+ tileLeft + tileMapWidth,\n+ tileBottom + tileMapHeight);\n },\n \n- CLASS_NAME: \"OpenLayers.Handler.MouseWheel\"\n+ CLASS_NAME: \"OpenLayers.Layer.Grid\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Feature.js\n+ OpenLayers/TileManager.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+ * @requires OpenLayers/Util.js\n+ * @requires OpenLayers/BaseTypes.js\n+ * @requires OpenLayers/BaseTypes/Element.js\n+ * @requires OpenLayers/Layer/Grid.js\n+ * @requires OpenLayers/Tile/Image.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+ * Class: OpenLayers.TileManager\n+ * Provides queueing of image requests and caching of image elements.\n *\n- * This handler stops event propagation for mousedown and mouseup if those\n- * browser events target features that can be selected.\n+ * Queueing avoids unnecessary image requests while changing zoom levels\n+ * quickly, and helps improve dragging performance on mobile devices that show\n+ * a lag in dragging when loading of new images starts. and\n+ * are the configuration options to control this behavior.\n *\n- * Inherits from:\n- * - \n+ * Caching avoids setting the src on image elements for images that have already\n+ * been used. Several maps can share a TileManager instance, in which case each\n+ * map gets its own tile queue, but all maps share the same tile cache.\n */\n-OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, {\n+OpenLayers.TileManager = OpenLayers.Class({\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: cacheSize\n+ * {Number} Number of image elements to keep referenced in this instance's\n+ * cache for fast reuse. Default is 256.\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+ cacheSize: 256,\n \n /**\n- * Property: feature\n- * {} The last feature that was hovered.\n+ * APIProperty: tilesPerFrame\n+ * {Number} Number of queued tiles to load per frame (see ).\n+ * Default is 2.\n */\n- feature: null,\n+ tilesPerFrame: 2,\n \n /**\n- * Property: lastFeature\n- * {} The last feature that was handled.\n+ * APIProperty: frameDelay\n+ * {Number} Delay between tile loading frames (see ) in\n+ * milliseconds. Default is 16.\n */\n- lastFeature: null,\n+ frameDelay: 16,\n \n /**\n- * Property: down\n- * {} The location of the last mousedown.\n+ * APIProperty: moveDelay\n+ * {Number} Delay in milliseconds after a map's move event before loading\n+ * tiles. Default is 100.\n */\n- down: null,\n+ moveDelay: 100,\n \n /**\n- * Property: up\n- * {} The location of the last mouseup.\n+ * APIProperty: zoomDelay\n+ * {Number} Delay in milliseconds after a map's zoomend event before loading\n+ * tiles. Default is 200.\n */\n- up: null,\n+ zoomDelay: 200,\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+ * Property: maps\n+ * {Array()} The maps to manage tiles on.\n */\n- clickTolerance: 4,\n+ maps: null,\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+ * Property: tileQueueId\n+ * {Object} The ids of the loop, keyed by map id.\n */\n- geometryTypes: null,\n+ tileQueueId: 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+ * Property: tileQueue\n+ * {Object(Array())} Tiles queued for drawing, keyed by\n+ * map id.\n */\n- stopClick: true,\n+ tileQueue: null,\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+ * Property: tileCache\n+ * {Object} Cached image elements, keyed by URL.\n */\n- stopDown: true,\n+ tileCache: 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: tileCacheIndex\n+ * {Array(String)} URLs of cached tiles. First entry is the least recently\n+ * used.\n */\n- stopUp: false,\n+ tileCacheIndex: null,\n+\n+ /** \n+ * Constructor: OpenLayers.TileManager\n+ * Constructor for a new instance.\n+ * \n+ * Parameters:\n+ * options - {Object} Configuration for this instance.\n+ */\n+ initialize: function(options) {\n+ OpenLayers.Util.extend(this, options);\n+ this.maps = [];\n+ this.tileQueueId = {};\n+ this.tileQueue = {};\n+ this.tileCache = {};\n+ this.tileCacheIndex = [];\n+ },\n \n /**\n- * Constructor: OpenLayers.Handler.Feature\n+ * Method: addMap\n+ * Binds this instance to a map\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- * options - {Object} \n+ * map - {}\n */\n- initialize: function(control, layer, callbacks, options) {\n- OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]);\n- this.layer = layer;\n+ addMap: function(map) {\n+ if (this._destroyed || !OpenLayers.Layer.Grid) {\n+ return;\n+ }\n+ this.maps.push(map);\n+ this.tileQueue[map.id] = [];\n+ for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n+ this.addLayer({\n+ layer: map.layers[i]\n+ });\n+ }\n+ map.events.on({\n+ move: this.move,\n+ zoomend: this.zoomEnd,\n+ changelayer: this.changeLayer,\n+ addlayer: this.addLayer,\n+ preremovelayer: this.removeLayer,\n+ scope: this\n+ });\n },\n \n /**\n- * Method: touchstart\n- * Handle touchstart events\n+ * Method: removeMap\n+ * Unbinds this instance from a map\n *\n * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} Let the event propagate.\n+ * map - {}\n */\n- touchstart: function(evt) {\n- this.startTouch();\n- return OpenLayers.Event.isMultiTouch(evt) ?\n- true : this.mousedown(evt);\n+ removeMap: function(map) {\n+ if (this._destroyed || !OpenLayers.Layer.Grid) {\n+ return;\n+ }\n+ window.clearTimeout(this.tileQueueId[map.id]);\n+ if (map.layers) {\n+ for (var i = 0, ii = map.layers.length; i < ii; ++i) {\n+ this.removeLayer({\n+ layer: map.layers[i]\n+ });\n+ }\n+ }\n+ if (map.events) {\n+ map.events.un({\n+ move: this.move,\n+ zoomend: this.zoomEnd,\n+ changelayer: this.changeLayer,\n+ addlayer: this.addLayer,\n+ preremovelayer: this.removeLayer,\n+ scope: this\n+ });\n+ }\n+ delete this.tileQueue[map.id];\n+ delete this.tileQueueId[map.id];\n+ OpenLayers.Util.removeItem(this.maps, map);\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: move\n+ * Handles the map's move event\n *\n * Parameters:\n- * evt - {Event}\n+ * evt - {Object} Listener argument\n */\n- touchmove: function(evt) {\n- OpenLayers.Event.preventDefault(evt);\n+ move: function(evt) {\n+ this.updateTimeout(evt.object, this.moveDelay, 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: zoomEnd\n+ * Handles the map's zoomEnd event\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Object} Listener argument\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.handle(evt) ? !this.stopDown : true;\n+ zoomEnd: function(evt) {\n+ this.updateTimeout(evt.object, this.zoomDelay);\n },\n \n /**\n- * Method: mouseup\n- * Handle mouse up. Stop propagation if a feature is targeted by this\n- * event.\n- * \n+ * Method: changeLayer\n+ * Handles the map's changeLayer event\n+ *\n * Parameters:\n- * evt - {Event} \n+ * evt - {Object} Listener argument\n */\n- mouseup: function(evt) {\n- this.up = evt.xy;\n- return this.handle(evt) ? !this.stopUp : true;\n+ changeLayer: function(evt) {\n+ if (evt.property === 'visibility' || evt.property === 'params') {\n+ this.updateTimeout(evt.object, 0);\n+ }\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+ * Method: addLayer\n+ * Handles the map's addlayer event\n *\n- * Returns:\n- * {Boolean}\n+ * Parameters:\n+ * evt - {Object} The listener argument\n */\n- click: function(evt) {\n- return this.handle(evt) ? !this.stopClick : true;\n+ addLayer: function(evt) {\n+ var layer = evt.layer;\n+ if (layer instanceof OpenLayers.Layer.Grid) {\n+ layer.events.on({\n+ addtile: this.addTile,\n+ retile: this.clearTileQueue,\n+ scope: this\n+ });\n+ var i, j, tile;\n+ for (i = layer.grid.length - 1; i >= 0; --i) {\n+ for (j = layer.grid[i].length - 1; j >= 0; --j) {\n+ tile = layer.grid[i][j];\n+ this.addTile({\n+ tile: tile\n+ });\n+ if (tile.url && !tile.imgDiv) {\n+ this.manageTileCache({\n+ object: tile\n+ });\n+ }\n+ }\n+ }\n+ }\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 - {Event} \n+ * Method: removeLayer\n+ * Handles the map's preremovelayer event\n *\n- * Returns:\n- * {Boolean}\n+ * Parameters:\n+ * evt - {Object} The listener argument\n */\n- mousemove: function(evt) {\n- if (!this.callbacks['over'] && !this.callbacks['out']) {\n- return true;\n+ removeLayer: function(evt) {\n+ var layer = evt.layer;\n+ if (layer instanceof OpenLayers.Layer.Grid) {\n+ this.clearTileQueue({\n+ object: layer\n+ });\n+ if (layer.events) {\n+ layer.events.un({\n+ addtile: this.addTile,\n+ retile: this.clearTileQueue,\n+ scope: this\n+ });\n+ }\n+ if (layer.grid) {\n+ var i, j, tile;\n+ for (i = layer.grid.length - 1; i >= 0; --i) {\n+ for (j = layer.grid[i].length - 1; j >= 0; --j) {\n+ tile = layer.grid[i][j];\n+ this.unloadTile({\n+ object: tile\n+ });\n+ }\n+ }\n+ }\n }\n- this.handle(evt);\n- return true;\n },\n \n /**\n- * Method: dblclick\n- * Handle dblclick. Call the \"dblclick\" callback if dblclick on a feature.\n+ * Method: updateTimeout\n+ * Applies the or to the loop,\n+ * and schedules more queue processing after if there are still\n+ * tiles in the queue.\n *\n * Parameters:\n- * evt - {Event} \n- *\n- * Returns:\n- * {Boolean}\n+ * map - {} The map to update the timeout for\n+ * delay - {Number} The delay to apply\n+ * nice - {Boolean} If true, the timeout function will only be created if\n+ * the tilequeue is not empty. This is used by the move handler to\n+ * avoid impacts on dragging performance. For other events, the tile\n+ * queue may not be populated yet, so we need to set the timer\n+ * regardless of the queue size.\n */\n- dblclick: function(evt) {\n- return !this.handle(evt);\n+ updateTimeout: function(map, delay, nice) {\n+ window.clearTimeout(this.tileQueueId[map.id]);\n+ var tileQueue = this.tileQueue[map.id];\n+ if (!nice || tileQueue.length) {\n+ this.tileQueueId[map.id] = window.setTimeout(\n+ OpenLayers.Function.bind(function() {\n+ this.drawTilesFromQueue(map);\n+ if (tileQueue.length) {\n+ this.updateTimeout(map, this.frameDelay);\n+ }\n+ }, this), delay\n+ );\n+ }\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: addTile\n+ * Listener for the layer's addtile event\n *\n * Parameters:\n- * feature - {}\n- *\n- * Returns:\n- * {Boolean}\n+ * evt - {Object} The listener argument\n */\n- geometryTypeMatches: function(feature) {\n- return this.geometryTypes == null ||\n- OpenLayers.Util.indexOf(this.geometryTypes,\n- feature.geometry.CLASS_NAME) > -1;\n+ addTile: function(evt) {\n+ if (evt.tile instanceof OpenLayers.Tile.Image) {\n+ evt.tile.events.on({\n+ beforedraw: this.queueTileDraw,\n+ beforeload: this.manageTileCache,\n+ loadend: this.addToCache,\n+ unload: this.unloadTile,\n+ scope: this\n+ });\n+ } else {\n+ // Layer has the wrong tile type, so don't handle it any longer\n+ this.removeLayer({\n+ layer: evt.tile.layer\n+ });\n+ }\n },\n \n /**\n- * Method: handle\n+ * Method: unloadTile\n+ * Listener for the tile's unload event\n *\n * Parameters:\n- * evt - {Event}\n- *\n- * Returns:\n- * {Boolean} The event occurred over a relevant feature.\n+ * evt - {Object} The listener argument\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+ unloadTile: function(evt) {\n+ var tile = evt.object;\n+ tile.events.un({\n+ beforedraw: this.queueTileDraw,\n+ beforeload: this.manageTileCache,\n+ loadend: this.addToCache,\n+ unload: this.unloadTile,\n+ scope: this\n+ });\n+ OpenLayers.Util.removeItem(this.tileQueue[tile.layer.map.id], tile);\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: queueTileDraw\n+ * Adds a tile to the queue that will draw it.\n *\n * Parameters:\n- * type - {String}\n+ * evt - {Object} Listener argument of the tile's beforedraw event\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- );\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+ queueTileDraw: function(evt) {\n+ var tile = evt.object;\n+ var queued = false;\n+ var layer = tile.layer;\n+ var url = layer.getURL(tile.bounds);\n+ var img = this.tileCache[url];\n+ if (img && img.className !== 'olTileImage') {\n+ // cached image no longer valid, e.g. because we're olTileReplacing\n+ delete this.tileCache[url];\n+ OpenLayers.Util.removeItem(this.tileCacheIndex, url);\n+ img = null;\n+ }\n+ // queue only if image with same url not cached already\n+ if (layer.url && (layer.async || !img)) {\n+ // add to queue only if not in queue already\n+ var tileQueue = this.tileQueue[layer.map.id];\n+ if (!~OpenLayers.Util.indexOf(tileQueue, tile)) {\n+ tileQueue.push(tile);\n }\n+ queued = true;\n }\n+ return !queued;\n },\n \n /**\n- * Method: activate \n- * Turn on the handler. Returns false if the handler was already active.\n- *\n- * Returns:\n- * {Boolean}\n+ * Method: drawTilesFromQueue\n+ * Draws tiles from the tileQueue, and unqueues the tiles\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+ drawTilesFromQueue: function(map) {\n+ var tileQueue = this.tileQueue[map.id];\n+ var limit = this.tilesPerFrame;\n+ var animating = map.zoomTween && map.zoomTween.playing;\n+ while (!animating && tileQueue.length && limit) {\n+ tileQueue.shift().draw(true);\n+ --limit;\n }\n- return activated;\n },\n \n /**\n- * Method: deactivate \n- * Turn off the handler. Returns false if the handler was already active.\n+ * Method: manageTileCache\n+ * Adds, updates, removes and fetches cache entries.\n *\n- * Returns: \n- * {Boolean}\n+ * Parameters:\n+ * evt - {Object} Listener argument of the tile's beforeload event\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- deactivated = true;\n+ manageTileCache: function(evt) {\n+ var tile = evt.object;\n+ var img = this.tileCache[tile.url];\n+ if (img) {\n+ // if image is on its layer's backbuffer, remove it from backbuffer\n+ if (img.parentNode &&\n+ OpenLayers.Element.hasClass(img.parentNode, 'olBackBuffer')) {\n+ img.parentNode.removeChild(img);\n+ img.id = null;\n+ }\n+ // only use image from cache if it is not on a layer already\n+ if (!img.parentNode) {\n+ img.style.visibility = 'hidden';\n+ img.style.opacity = 0;\n+ tile.setImage(img);\n+ // LRU - move tile to the end of the array to mark it as the most\n+ // recently used\n+ OpenLayers.Util.removeItem(this.tileCacheIndex, tile.url);\n+ this.tileCacheIndex.push(tile.url);\n+ }\n }\n- return deactivated;\n },\n \n /**\n- * Method: handleMapEvents\n- * \n+ * Method: addToCache\n+ *\n * Parameters:\n- * evt - {Object}\n+ * evt - {Object} Listener argument for the tile's loadend event\n */\n- handleMapEvents: function(evt) {\n- if (evt.type == \"removelayer\" || evt.property == \"order\") {\n- this.moveLayerToTop();\n+ addToCache: function(evt) {\n+ var tile = evt.object;\n+ if (!this.tileCache[tile.url]) {\n+ if (!OpenLayers.Element.hasClass(tile.imgDiv, 'olImageLoadError')) {\n+ if (this.tileCacheIndex.length >= this.cacheSize) {\n+ delete this.tileCache[this.tileCacheIndex[0]];\n+ this.tileCacheIndex.shift();\n+ }\n+ this.tileCache[tile.url] = tile.imgDiv;\n+ this.tileCacheIndex.push(tile.url);\n+ }\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+ * Method: clearTileQueue\n+ * Clears the tile queue from tiles of a specific layer\n+ *\n+ * Parameters:\n+ * evt - {Object} Listener argument of the layer's retile event\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+ clearTileQueue: function(evt) {\n+ var layer = evt.object;\n+ var tileQueue = this.tileQueue[layer.map.id];\n+ for (var i = tileQueue.length - 1; i >= 0; --i) {\n+ if (tileQueue[i].layer === layer) {\n+ tileQueue.splice(i, 1);\n+ }\n+ }\n },\n \n /**\n- * Method: moveLayerBack\n- * Moves the layer back to the position determined by the map's layers\n- * array.\n+ * Method: destroy\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+ destroy: function() {\n+ for (var i = this.maps.length - 1; i >= 0; --i) {\n+ this.removeMap(this.maps[i]);\n }\n- },\n+ this.maps = null;\n+ this.tileQueue = null;\n+ this.tileQueueId = null;\n+ this.tileCache = null;\n+ this.tileCacheIndex = null;\n+ this._destroyed = true;\n+ }\n \n- CLASS_NAME: \"OpenLayers.Handler.Feature\"\n });\n /* ======================================================================\n- OpenLayers/Handler/Click.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/Handler.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Events.js\n */\n \n /**\n- * Class: OpenLayers.Handler.Click\n- * A handler for mouse clicks. The intention of this handler is to give\n- * controls more flexibility with handling clicks. Browsers trigger\n- * click events twice for a double-click. In addition, the mousedown,\n- * mousemove, mouseup sequence fires a click event. With this handler,\n- * controls can decide whether to ignore clicks associated with a double\n- * click. By setting a , controls can also ignore clicks\n- * that include a drag. Create a new instance with the\n- * constructor.\n- * \n- * Inherits from:\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.Click = OpenLayers.Class(OpenLayers.Handler, {\n- /**\n- * APIProperty: delay\n- * {Number} Number of milliseconds between clicks before the event is\n- * considered a double-click.\n- */\n- delay: 300,\n-\n- /**\n- * APIProperty: single\n- * {Boolean} Handle single clicks. Default is true. If false, clicks\n- * will not be reported. If true, single-clicks will be reported.\n- */\n- single: true,\n-\n- /**\n- * APIProperty: double\n- * {Boolean} Handle double-clicks. Default is false.\n- */\n- 'double': false,\n-\n- /**\n- * APIProperty: pixelTolerance\n- * {Number} Maximum number of pixels between mouseup and mousedown for an\n- * event to be considered a click. Default is 0. If set to an\n- * integer value, clicks with a drag greater than the value will be\n- * ignored. This property can only be set when the handler is\n- * constructed.\n- */\n- pixelTolerance: 0,\n+OpenLayers.Handler = OpenLayers.Class({\n \n /**\n- * APIProperty: dblclickTolerance\n- * {Number} Maximum distance in pixels between clicks for a sequence of \n- * events to be considered a double click. Default is 13. If the\n- * distance between two clicks is greater than this value, a double-\n- * click will not be fired.\n+ * Property: id\n+ * {String}\n */\n- dblclickTolerance: 13,\n+ id: null,\n \n /**\n- * APIProperty: stopSingle\n- * {Boolean} Stop other listeners from being notified of clicks. Default\n- * is false. If true, any listeners registered before this one for \n- * click or rightclick events will not be notified.\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- stopSingle: false,\n+ control: null,\n \n /**\n- * APIProperty: stopDouble\n- * {Boolean} Stop other listeners from being notified of double-clicks.\n- * Default is false. If true, any click listeners registered before\n- * this one will not be notified of *any* double-click events.\n- * \n- * The one caveat with stopDouble is that given a map with two click\n- * handlers, one with stopDouble true and the other with stopSingle\n- * true, the stopSingle handler should be activated last to get\n- * uniform cross-browser performance. Since IE triggers one click\n- * with a dblclick and FF triggers two, if a stopSingle handler is\n- * activated first, all it gets in IE is a single click when the\n- * second handler stops propagation on the dblclick.\n+ * Property: map\n+ * {}\n */\n- stopDouble: false,\n+ map: null,\n \n /**\n- * Property: timerId\n- * {Number} The id of the timeout waiting to clear the .\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- timerId: null,\n+ keyMask: null,\n \n /**\n- * Property: down\n- * {Object} Object that store relevant information about the last\n- * mousedown or touchstart. Its 'xy' OpenLayers.Pixel property gives\n- * the average location of the mouse/touch event. Its 'touches'\n- * property records clientX/clientY of each touches.\n+ * Property: active\n+ * {Boolean}\n */\n- down: null,\n+ active: false,\n \n /**\n- * Property: last\n- * {Object} Object that store relevant information about the last\n- * mousemove or touchmove. Its 'xy' OpenLayers.Pixel property gives\n- * the average location of the mouse/touch event. Its 'touches'\n- * property records clientX/clientY of each touches.\n- */\n- last: null,\n-\n- /** \n- * Property: first\n- * {Object} When waiting for double clicks, this object will store \n- * information about the first click in a two click sequence.\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- first: null,\n+ evt: null,\n \n /**\n- * Property: rightclickTimerId\n- * {Number} The id of the right mouse timeout waiting to clear the \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- rightclickTimerId: null,\n+ touch: false,\n \n /**\n- * Constructor: OpenLayers.Handler.Click\n- * Create a new click handler.\n- * \n+ * Constructor: OpenLayers.Handler\n+ * Construct a 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- * handler's setMap method must be overridden to deal properly with\n- * the map.\n- * callbacks - {Object} An object with keys corresponding to callbacks\n- * that will be called by the handler. The callbacks should\n- * expect to recieve a single argument, the click event.\n- * Callbacks for 'click' and 'dblclick' are supported.\n- * options - {Object} Optional object whose properties will be set on the\n- * handler.\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- /**\n- * Method: touchstart\n- * Handle touchstart.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- touchstart: function(evt) {\n- this.startTouch();\n- this.down = this.getEventInfo(evt);\n- this.last = this.getEventInfo(evt);\n- return true;\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: touchmove\n- * Store position of last move, because touchend event can have\n- * an empty \"touches\" property.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ * Method: setMap\n */\n- touchmove: function(evt) {\n- this.last = this.getEventInfo(evt);\n- return true;\n+ setMap: function(map) {\n+ this.map = map;\n },\n \n /**\n- * Method: touchend\n- * Correctly set event xy property, and add lastTouches to have\n- * touches property from last touchstart or touchmove\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} Continue propagating this event.\n+ * {Boolean} The keyMask matches the keys down on an event.\n */\n- touchend: function(evt) {\n- // touchstart may not have been allowed to propagate\n- if (this.down) {\n- evt.xy = this.last.xy;\n- evt.lastTouches = this.last.touches;\n- this.handleSingle(evt);\n- this.down = null;\n+ checkModifiers: function(evt) {\n+ if (this.keyMask == null) {\n+ return true;\n }\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- /**\n- * Method: mousedown\n- * Handle mousedown.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- mousedown: function(evt) {\n- this.down = this.getEventInfo(evt);\n- this.last = this.getEventInfo(evt);\n- return true;\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- * Method: mouseup\n- * Handle mouseup. Installed to support collection of right mouse events.\n+ * APIMethod: activate\n+ * Turn on the handler. Returns false if the handler was already active.\n * \n- * Returns:\n- * {Boolean} Continue propagating this event.\n+ * Returns: \n+ * {Boolean} The handler was activated.\n */\n- mouseup: function(evt) {\n- var propagate = true;\n-\n- // Collect right mouse clicks from the mouseup\n- // IE - ignores the second right click in mousedown so using\n- // mouseup instead\n- if (this.checkModifiers(evt) && this.control.handleRightClicks &&\n- OpenLayers.Event.isRightClick(evt)) {\n- propagate = this.rightclick(evt);\n+ activate: function() {\n+ if (this.active) {\n+ return false;\n }\n-\n- return propagate;\n- },\n-\n- /**\n- * Method: rightclick\n- * Handle rightclick. For a dblrightclick, we get two clicks so we need \n- * to always register for dblrightclick to properly handle single \n- * clicks.\n- * \n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- rightclick: function(evt) {\n- if (this.passesTolerance(evt)) {\n- if (this.rightclickTimerId != null) {\n- //Second click received before timeout this must be \n- // a double click\n- this.clearTimer();\n- this.callback('dblrightclick', [evt]);\n- return !this.stopDouble;\n- } else {\n- //Set the rightclickTimerId, send evt only if double is \n- // true else trigger single\n- var clickEvent = this['double'] ?\n- OpenLayers.Util.extend({}, evt) :\n- this.callback('rightclick', [evt]);\n-\n- var delayedRightCall = OpenLayers.Function.bind(\n- this.delayedRightCall,\n- this,\n- clickEvent\n- );\n- this.rightclickTimerId = window.setTimeout(\n- delayedRightCall, this.delay\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- return !this.stopSingle;\n- },\n-\n- /**\n- * Method: delayedRightCall\n- * Sets to null. And optionally triggers the \n- * rightclick callback if evt is set.\n- */\n- delayedRightCall: function(evt) {\n- this.rightclickTimerId = null;\n- if (evt) {\n- this.callback('rightclick', [evt]);\n- }\n- },\n-\n- /**\n- * Method: click\n- * Handle click events from the browser. This is registered as a listener\n- * for click events and should not be called from other events in this\n- * handler.\n- *\n- * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- click: function(evt) {\n- if (!this.last) {\n- this.last = this.getEventInfo(evt);\n- }\n- this.handleSingle(evt);\n- return !this.stopSingle;\n+ this.active = true;\n+ return true;\n },\n \n /**\n- * Method: dblclick\n- * Handle dblclick. For a dblclick, we get two clicks in some browsers\n- * (FF) and one in others (IE). So we need to always register for\n- * dblclick to properly handle single clicks. This method is registered\n- * as a listener for the dblclick browser event. It should *not* be\n- * called by other methods in this handler.\n- * \n+ * APIMethod: deactivate\n+ * Turn off the handler. Returns false if the handler was already inactive.\n+ * \n * Returns:\n- * {Boolean} Continue propagating this event.\n- */\n- dblclick: function(evt) {\n- this.handleDouble(evt);\n- return !this.stopDouble;\n- },\n-\n- /** \n- * Method: handleDouble\n- * Handle double-click sequence.\n+ * {Boolean} The handler was deactivated.\n */\n- handleDouble: function(evt) {\n- if (this.passesDblclickTolerance(evt)) {\n- if (this[\"double\"]) {\n- this.callback(\"dblclick\", [evt]);\n- }\n- // to prevent a dblclick from firing the click callback in IE\n- this.clearTimer();\n+ deactivate: function() {\n+ if (!this.active) {\n+ return false;\n }\n- },\n-\n- /** \n- * Method: handleSingle\n- * Handle single click sequence.\n- */\n- handleSingle: function(evt) {\n- if (this.passesTolerance(evt)) {\n- if (this.timerId != null) {\n- // already received a click\n- if (this.last.touches && this.last.touches.length === 1) {\n- // touch device, no dblclick event - this may be a double\n- if (this[\"double\"]) {\n- // on Android don't let the browser zoom on the page\n- OpenLayers.Event.preventDefault(evt);\n- }\n- this.handleDouble(evt);\n- }\n- // if we're not in a touch environment we clear the click timer\n- // if we've got a second touch, we'll get two touchend events\n- if (!this.last.touches || this.last.touches.length !== 2) {\n- this.clearTimer();\n- }\n- } else {\n- // remember the first click info so we can compare to the second\n- this.first = this.getEventInfo(evt);\n- // set the timer, send evt only if single is true\n- //use a clone of the event object because it will no longer \n- //be a valid event object in IE in the timer callback\n- var clickEvent = this.single ?\n- OpenLayers.Util.extend({}, evt) : null;\n- this.queuePotentialClick(clickEvent);\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- },\n-\n- /** \n- * Method: queuePotentialClick\n- * This method is separated out largely to make testing easier (so we\n- * don't have to override window.setTimeout)\n- */\n- queuePotentialClick: function(evt) {\n- this.timerId = window.setTimeout(\n- OpenLayers.Function.bind(this.delayedCall, this, evt),\n- this.delay\n- );\n+ this.touch = false;\n+ this.active = false;\n+ return true;\n },\n \n /**\n- * Method: passesTolerance\n- * Determine whether the event is within the optional pixel tolerance. Note\n- * that the pixel tolerance check only works if mousedown events get to\n- * the listeners registered here. If they are stopped by other elements,\n- * the will have no effect here (this method will always\n- * return true).\n- *\n- * Returns:\n- * {Boolean} The click is within the pixel tolerance (if specified).\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- passesTolerance: function(evt) {\n- var passes = true;\n- if (this.pixelTolerance != null && this.down && this.down.xy) {\n- passes = this.pixelTolerance >= this.down.xy.distanceTo(evt.xy);\n- // for touch environments, we also enforce that all touches\n- // start and end within the given tolerance to be considered a click\n- if (passes && this.touch &&\n- this.down.touches.length === this.last.touches.length) {\n- // the touchend event doesn't come with touches, so we check\n- // down and last\n- for (var i = 0, ii = this.down.touches.length; i < ii; ++i) {\n- if (this.getTouchDistance(\n- this.down.touches[i],\n- this.last.touches[i]\n- ) > this.pixelTolerance) {\n- passes = false;\n- break;\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 }\n- return passes;\n- },\n-\n- /** \n- * Method: getTouchDistance\n- *\n- * Returns:\n- * {Boolean} The pixel displacement between two touches.\n- */\n- getTouchDistance: function(from, to) {\n- return Math.sqrt(\n- Math.pow(from.clientX - to.clientX, 2) +\n- Math.pow(from.clientY - to.clientY, 2)\n- );\n },\n \n /**\n- * Method: passesDblclickTolerance\n- * Determine whether the event is within the optional double-cick pixel \n- * tolerance.\n+ * Method: callback\n+ * Trigger the control's named callback with the given arguments\n *\n- * Returns:\n- * {Boolean} The click is within the double-click pixel tolerance.\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- passesDblclickTolerance: function(evt) {\n- var passes = true;\n- if (this.down && this.first) {\n- passes = this.down.xy.distanceTo(this.first.xy) <= this.dblclickTolerance;\n+ callback: function(name, args) {\n+ if (name && this.callbacks[name]) {\n+ this.callbacks[name].apply(this.control, args);\n }\n- return passes;\n },\n \n /**\n- * Method: clearTimer\n- * Clear the timer and set to null.\n+ * Method: register\n+ * register an event on the map\n */\n- clearTimer: function() {\n- if (this.timerId != null) {\n- window.clearTimeout(this.timerId);\n- this.timerId = null;\n- }\n- if (this.rightclickTimerId != null) {\n- window.clearTimeout(this.rightclickTimerId);\n- this.rightclickTimerId = null;\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: delayedCall\n- * Sets to null. And optionally triggers the click callback if\n- * evt is set.\n+ * Method: unregister\n+ * unregister an event from the map\n */\n- delayedCall: function(evt) {\n- this.timerId = null;\n- if (evt) {\n- this.callback(\"click\", [evt]);\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: getEventInfo\n- * This method allows us to store event information without storing the\n- * actual event. In touch devices (at least), the same event is \n- * modified between touchstart, touchmove, and touchend.\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- * Returns:\n- * {Object} An object with event related info.\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- getEventInfo: function(evt) {\n- var touches;\n- if (evt.touches) {\n- var len = evt.touches.length;\n- touches = new Array(len);\n- var touch;\n- for (var i = 0; i < len; i++) {\n- touch = evt.touches[i];\n- touches[i] = {\n- clientX: touch.olClientX,\n- clientY: touch.olClientY\n- };\n- }\n- }\n- return {\n- xy: evt.xy,\n- touches: touches\n- };\n+ setEvent: function(evt) {\n+ this.evt = evt;\n+ return true;\n },\n \n /**\n- * APIMethod: deactivate\n- * Deactivate the handler.\n- *\n- * Returns:\n- * {Boolean} The handler was successfully deactivated.\n+ * Method: destroy\n+ * Deconstruct the handler.\n */\n- deactivate: function() {\n- var deactivated = false;\n- if (OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {\n- this.clearTimer();\n- this.down = null;\n- this.first = null;\n- this.last = null;\n- deactivated = true;\n- }\n- return deactivated;\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.Click\"\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/Events/buttonclick.js\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/Events.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n+ * @requires OpenLayers/Style.js\n+ * @requires OpenLayers/Feature/Vector.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+ * Class: OpenLayers.StyleMap\n */\n-OpenLayers.Events.buttonclick = OpenLayers.Class({\n-\n- /**\n- * Property: target\n- * {} The events instance that the buttonclick event will\n- * be triggered on.\n- */\n- target: null,\n-\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- events: [\n- 'mousedown', 'mouseup', 'click', 'dblclick',\n- 'touchstart', 'touchmove', 'touchend', 'keydown'\n- ],\n-\n- /**\n- * Property: startRegEx\n- * {RegExp} Regular expression to test Event.type for events that start\n- * a buttonclick sequence.\n- */\n- startRegEx: /^mousedown|touchstart$/,\n-\n- /**\n- * Property: cancelRegEx\n- * {RegExp} Regular expression to test Event.type for events that cancel\n- * a buttonclick sequence.\n- */\n- cancelRegEx: /^touchmove$/,\n+OpenLayers.StyleMap = OpenLayers.Class({\n \n /**\n- * Property: completeRegEx\n- * {RegExp} Regular expression to test Event.type for events that complete\n- * a buttonclick sequence.\n+ * Property: styles\n+ * {Object} Hash of {}, keyed by names of well known\n+ * rendering intents (e.g. \"default\", \"temporary\", \"select\", \"delete\").\n */\n- completeRegEx: /^mouseup|touchend$/,\n+ styles: null,\n \n /**\n- * Property: startEvt\n- * {Event} The event that started the click sequence\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.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+ * Constructor: OpenLayers.StyleMap\n+ * \n * Parameters:\n- * target - {} The events instance that the buttonclick\n- * event will be triggered on.\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(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+ 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 i = this.events.length - 1; i >= 0; --i) {\n- this.target.unregister(this.events[i], this, this.buttonClick);\n+ for (var key in this.styles) {\n+ this.styles[key].destroy();\n }\n- delete this.target;\n- },\n-\n- /**\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- * {DOMElement} The button element, or undefined.\n- */\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+ this.styles = null;\n },\n \n /**\n- * Method: ignore\n- * Check for event target elements that should be ignored by OpenLayers.\n- *\n+ * Method: createSymbolizer\n+ * Creates the symbolizer for a feature for a render intent.\n+ * \n * Parameters:\n- * element - {DOMElement} The event target.\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- 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+ 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: buttonClick\n- * Check if a button was clicked, and fire the buttonclick event\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- * evt - {Event}\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- 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+ 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- return propagate;\n- }\n+ this.styles[renderIntent].addRules(rules);\n+ },\n \n+ CLASS_NAME: \"OpenLayers.StyleMap\"\n });\n /* ======================================================================\n- OpenLayers/Events/featureclick.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- * @requires OpenLayers/Events.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \n /**\n- * Class: OpenLayers.Events.featureclick\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- * Extension event type for handling feature click events, including overlapping\n- * features. \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- * Event types provided by this extension:\n- * - featureclick \n */\n-OpenLayers.Events.featureclick = OpenLayers.Class({\n+OpenLayers.Control = OpenLayers.Class({\n \n- /**\n- * Property: cache\n- * {Object} A cache of features under the mouse.\n+ /** \n+ * Property: id \n+ * {String} \n */\n- cache: null,\n+ id: null,\n \n- /**\n- * Property: map\n- * {} The map to register browser events on.\n+ /** \n+ * Property: map \n+ * {} this gets set in the addControl() function in\n+ * OpenLayers.Map \n */\n map: null,\n \n- /**\n- * Property: provides\n- * {Array(String)} The event types provided by this extension.\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- provides: [\"featureclick\", \"nofeatureclick\", \"featureover\", \"featureout\"],\n+ div: null,\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+\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+ allowSelection: false,\n+\n+ /** \n+ * Property: displayClass \n+ * {string} This property is used for CSS related to the drawing of the\n+ * Control. \n+ */\n+ displayClass: \"\",\n \n /**\n- * Constructor: OpenLayers.Events.featureclick\n- * Create a new featureclick event type.\n- *\n- * Parameters:\n- * target - {} The events instance to create the events\n- * for.\n+ * APIProperty: title \n+ * {string} This property is used for showing a tooltip over the \n+ * Control. \n */\n- initialize: function(target) {\n- this.target = target;\n- if (target.object instanceof OpenLayers.Map) {\n- this.setMap(target.object);\n- } else if (target.object instanceof OpenLayers.Layer.Vector) {\n- if (target.object.map) {\n- this.setMap(target.object.map);\n- } else {\n- target.object.events.register(\"added\", this, function(evt) {\n- this.setMap(target.object.map);\n- });\n- }\n- } else {\n- throw (\"Listeners for '\" + this.provides.join(\"', '\") +\n- \"' events can only be registered for OpenLayers.Layer.Vector \" +\n- \"or OpenLayers.Map instances\");\n- }\n- for (var i = this.provides.length - 1; i >= 0; --i) {\n- target.extensions[this.provides[i]] = true;\n- }\n- },\n+ title: \"\",\n \n /**\n- * Method: setMap\n- *\n- * Parameters:\n- * map - {} The map to register browser events on.\n+ * APIProperty: autoActivate\n+ * {Boolean} Activate the control when it is added to a map. Default is\n+ * false.\n */\n- setMap: function(map) {\n- this.map = map;\n- this.cache = {};\n- map.events.register(\"mousedown\", this, this.start, {\n- extension: true\n- });\n- map.events.register(\"mouseup\", this, this.onClick, {\n- extension: true\n- });\n- map.events.register(\"touchstart\", this, this.start, {\n- extension: true\n- });\n- map.events.register(\"touchmove\", this, this.cancel, {\n- extension: true\n- });\n- map.events.register(\"touchend\", this, this.onClick, {\n- extension: true\n- });\n- map.events.register(\"mousemove\", this, this.onMousemove, {\n- extension: true\n- });\n- },\n+ autoActivate: false,\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 \n /**\n- * Method: start\n- * Sets startEvt = evt.\n- *\n- * Parameters:\n- * evt - {}\n+ * Property: handlerOptions\n+ * {Object} Used to set non-default properties on the control's handler\n */\n- start: function(evt) {\n- this.startEvt = evt;\n- },\n+ handlerOptions: null,\n+\n+ /** \n+ * Property: handler \n+ * {} null\n+ */\n+ handler: null,\n \n /**\n- * Method: cancel\n- * Deletes the start event.\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: events\n+ * {} Events instance for listeners and triggering\n+ * control specific events.\n *\n- * Parameters:\n- * evt - {}\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- cancel: function(evt) {\n- delete this.startEvt;\n- },\n+ events: null,\n \n /**\n- * Method: onClick\n- * Listener for the click event.\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 *\n+ * Overrides the default div attribute value of null.\n+ * \n * Parameters:\n- * evt - {}\n+ * options - {Object} \n */\n- onClick: function(evt) {\n- if (!this.startEvt || evt.type !== \"touchend\" &&\n- !OpenLayers.Event.isLeftClick(evt)) {\n- return;\n- }\n- var features = this.getFeatures(this.startEvt);\n- delete this.startEvt;\n- // fire featureclick events\n- var feature, layer, more, clicked = {};\n- for (var i = 0, len = features.length; i < len; ++i) {\n- feature = features[i];\n- layer = feature.layer;\n- clicked[layer.id] = true;\n- more = this.triggerEvent(\"featureclick\", {\n- feature: feature\n- });\n- if (more === false) {\n- break;\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+\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- // fire nofeatureclick events on all vector layers with no targets\n- for (i = 0, len = this.map.layers.length; i < len; ++i) {\n- layer = this.map.layers[i];\n- if (layer instanceof OpenLayers.Layer.Vector && !clicked[layer.id]) {\n- this.triggerEvent(\"nofeatureclick\", {\n- layer: layer\n- });\n- }\n+ if (this.id == null) {\n+ this.id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + \"_\");\n }\n },\n \n /**\n- * Method: onMousemove\n- * Listener for the mousemove event.\n- *\n- * Parameters:\n- * evt - {}\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- onMousemove: function(evt) {\n- delete this.startEvt;\n- var features = this.getFeatures(evt);\n- var over = {},\n- newly = [],\n- feature;\n- for (var i = 0, len = features.length; i < len; ++i) {\n- feature = features[i];\n- over[feature.id] = feature;\n- if (!this.cache[feature.id]) {\n- newly.push(feature);\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- // check if already over features\n- var out = [];\n- for (var id in this.cache) {\n- feature = this.cache[id];\n- if (feature.layer && feature.layer.map) {\n- if (!over[feature.id]) {\n- out.push(feature);\n+ this.eventListeners = null;\n+\n+ // eliminate circular references\n+ if (this.handler) {\n+ this.handler.destroy();\n+ this.handler = null;\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- } else {\n- // removed\n- delete this.cache[id];\n }\n+ this.handlers = null;\n }\n- // fire featureover events\n- var more;\n- for (i = 0, len = newly.length; i < len; ++i) {\n- feature = newly[i];\n- this.cache[feature.id] = feature;\n- more = this.triggerEvent(\"featureover\", {\n- feature: feature\n- });\n- if (more === false) {\n- break;\n- }\n+ if (this.map) {\n+ this.map.removeControl(this);\n+ this.map = null;\n }\n- // fire featureout events\n- for (i = 0, len = out.length; i < len; ++i) {\n- feature = out[i];\n- delete this.cache[feature.id];\n- more = this.triggerEvent(\"featureout\", {\n- feature: feature\n- });\n- if (more === false) {\n- break;\n- }\n+ this.div = null;\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+ *\n+ * Parameters:\n+ * map - {} \n+ */\n+ setMap: function(map) {\n+ this.map = map;\n+ if (this.handler) {\n+ this.handler.setMap(map);\n }\n },\n \n /**\n- * Method: triggerEvent\n- * Determines where to trigger the event and triggers it.\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- * type - {String} The event type to trigger\n- * evt - {Object} The listener argument\n+ * px - {} The top-left pixel position of the control\n+ * or null.\n *\n * Returns:\n- * {Boolean} The last listener return.\n+ * {DOMElement} A reference to the DIV DOMElement containing the control\n */\n- triggerEvent: function(type, evt) {\n- var layer = evt.feature ? evt.feature.layer : evt.layer,\n- object = this.target.object;\n- if (object instanceof OpenLayers.Map || object === layer) {\n- return this.target.triggerEvent(type, evt);\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+ if (this.title != \"\") {\n+ this.div.title = this.title;\n+ }\n+ }\n+ if (px != null) {\n+ this.position = px.clone();\n }\n+ this.moveTo(this.position);\n+ return this.div;\n },\n \n /**\n- * Method: getFeatures\n- * Get all features at the given screen location.\n+ * Method: moveTo\n+ * Sets the left and top style attributes to the passed in pixel \n+ * coordinates.\n *\n * Parameters:\n- * evt - {Object} Event object.\n- *\n+ * px - {}\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+ * 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- * {Array()} List of features at the given point.\n+ * {Boolean} True if the control was successfully activated or\n+ * false if the control was already active.\n */\n- getFeatures: function(evt) {\n- var x = evt.clientX,\n- y = evt.clientY,\n- features = [],\n- targets = [],\n- layers = [],\n- layer, target, feature, i, len;\n- // go through all layers looking for targets\n- for (i = this.map.layers.length - 1; i >= 0; --i) {\n- layer = this.map.layers[i];\n- if (layer.div.style.display !== \"none\") {\n- if (layer.renderer instanceof OpenLayers.Renderer.Elements) {\n- if (layer instanceof OpenLayers.Layer.Vector) {\n- target = document.elementFromPoint(x, y);\n- while (target && target._featureId) {\n- feature = layer.getFeatureById(target._featureId);\n- if (feature) {\n- features.push(feature);\n- target.style.display = \"none\";\n- targets.push(target);\n- target = document.elementFromPoint(x, y);\n- } else {\n- // sketch, all bets off\n- target = false;\n- }\n- }\n- }\n- layers.push(layer);\n- layer.div.style.display = \"none\";\n- } else if (layer.renderer instanceof OpenLayers.Renderer.Canvas) {\n- feature = layer.renderer.getFeatureIdFromEvent(evt);\n- if (feature) {\n- features.push(feature);\n- layers.push(layer);\n- }\n- }\n- }\n+ activate: function() {\n+ if (this.active) {\n+ return false;\n }\n- // restore feature visibility\n- for (i = 0, len = targets.length; i < len; ++i) {\n- targets[i].style.display = \"\";\n+ if (this.handler) {\n+ this.handler.activate();\n }\n- // restore layer visibility\n- for (i = layers.length - 1; i >= 0; --i) {\n- layers[i].div.style.display = \"block\";\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 features;\n+ this.events.triggerEvent(\"activate\");\n+ return true;\n },\n \n /**\n- * APIMethod: destroy\n- * Clean up.\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+ * Returns:\n+ * {Boolean} True if the control was effectively deactivated or false\n+ * if the control was already inactive.\n */\n- destroy: function() {\n- for (var i = this.provides.length - 1; i >= 0; --i) {\n- delete this.target.extensions[this.provides[i]];\n+ deactivate: function() {\n+ if (this.active) {\n+ if (this.handler) {\n+ this.handler.deactivate();\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- this.map.events.un({\n- mousemove: this.onMousemove,\n- mousedown: this.start,\n- mouseup: this.onClick,\n- touchstart: this.start,\n- touchmove: this.cancel,\n- touchend: this.onClick,\n- scope: this\n- });\n- delete this.cache;\n- delete this.map;\n- delete this.target;\n- }\n+ return false;\n+ },\n \n+ CLASS_NAME: \"OpenLayers.Control\"\n });\n \n /**\n- * Class: OpenLayers.Events.nofeatureclick\n- *\n- * Extension event type for handling click events that do not hit a feature. \n- * \n- * Event types provided by this extension:\n- * - nofeatureclick \n+ * Constant: OpenLayers.Control.TYPE_BUTTON\n */\n-OpenLayers.Events.nofeatureclick = OpenLayers.Events.featureclick;\n+OpenLayers.Control.TYPE_BUTTON = 1;\n \n /**\n- * Class: OpenLayers.Events.featureover\n- *\n- * Extension event type for handling hovering over a feature. \n- * \n- * Event types provided by this extension:\n- * - featureover \n+ * Constant: OpenLayers.Control.TYPE_TOGGLE\n */\n-OpenLayers.Events.featureover = OpenLayers.Events.featureclick;\n+OpenLayers.Control.TYPE_TOGGLE = 2;\n \n /**\n- * Class: OpenLayers.Events.featureout\n- *\n- * Extension event type for handling leaving a feature. \n- * \n- * Event types provided by this extension:\n- * - featureout \n+ * Constant: OpenLayers.Control.TYPE_TOOL\n */\n-OpenLayers.Events.featureout = OpenLayers.Events.featureclick;\n+OpenLayers.Control.TYPE_TOOL = 3;\n /* ======================================================================\n- OpenLayers/Layer/WMTS.js\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/Layer/Grid.js\n+ * @requires OpenLayers/BaseTypes/Class.js\n */\n \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+ * 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.Layer.WMTS = OpenLayers.Class(OpenLayers.Layer.Grid, {\n+OpenLayers.Popup = OpenLayers.Class({\n \n- /**\n- * APIProperty: isBaseLayer\n- * {Boolean} The layer will be considered a base layer. Default is true.\n+ /** \n+ * Property: events \n+ * {} custom event manager \n */\n- isBaseLayer: true,\n+ events: null,\n \n- /**\n- * Property: version\n- * {String} WMTS version. Default is \"1.0.0\".\n+ /** Property: id\n+ * {String} the unique identifier assigned to this popup.\n */\n- version: \"1.0.0\",\n+ id: \"\",\n \n- /**\n- * APIProperty: requestEncoding\n- * {String} Request encoding. Can be \"REST\" or \"KVP\". Default is \"KVP\".\n+ /** \n+ * Property: lonlat \n+ * {} the position of this popup on the map\n */\n- requestEncoding: \"KVP\",\n+ lonlat: null,\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+ * Property: div \n+ * {DOMElement} the div that contains this popup.\n */\n- url: null,\n+ div: null,\n \n- /**\n- * APIProperty: layer\n- * {String} The layer identifier advertised by the WMTS service. Must be \n- * provided.\n+ /** \n+ * Property: contentSize \n+ * {} the width and height of the content.\n */\n- layer: null,\n+ contentSize: null,\n \n /** \n- * APIProperty: matrixSet\n- * {String} One of the advertised matrix set identifiers. Must be provided.\n+ * Property: size \n+ * {} the width and height of the popup.\n */\n- matrixSet: null,\n+ size: null,\n \n /** \n- * APIProperty: style\n- * {String} One of the advertised layer styles. Must be provided.\n+ * Property: contentHTML \n+ * {String} An HTML string for this popup to display.\n */\n- style: null,\n+ contentHTML: null,\n \n /** \n- * APIProperty: format\n- * {String} The image MIME type. Default is \"image/jpeg\".\n+ * Property: backgroundColor \n+ * {String} the background color used by the popup.\n */\n- format: \"image/jpeg\",\n+ backgroundColor: \"\",\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+ * Property: opacity \n+ * {float} the opacity of this popup (between 0.0 and 1.0)\n */\n- tileOrigin: null,\n+ opacity: \"\",\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+ * Property: border \n+ * {String} the border size of the popup. (eg 2px)\n */\n- tileFullExtent: null,\n+ border: \"\",\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+ * Property: contentDiv \n+ * {DOMElement} a reference to the element that holds the content of\n+ * the div.\n */\n- formatSuffix: null,\n+ contentDiv: 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+ * Property: groupDiv \n+ * {DOMElement} First and only child of 'div'. The group Div contains the\n+ * 'contentDiv' and the 'closeDiv'.\n */\n- matrixIds: null,\n+ groupDiv: 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+ * Property: closeDiv\n+ * {DOMElement} the optional closer image\n */\n- dimensions: null,\n+ closeDiv: 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+ * APIProperty: autoSize\n+ * {Boolean} Resize the popup to auto-fit the contents.\n+ * Default is false.\n */\n- params: null,\n+ autoSize: false,\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+ * APIProperty: minSize\n+ * {} Minimum size allowed for the popup's contents.\n */\n- zoomOffset: 0,\n+ minSize: null,\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+ * APIProperty: maxSize\n+ * {} Maximum size allowed for the popup's contents.\n */\n- serverResolutions: null,\n+ maxSize: null,\n \n- /**\n- * Property: formatSuffixMap\n- * {Object} a map between WMTS 'format' request parameter and tile image file suffix\n+ /** \n+ * Property: displayClass\n+ * {String} The CSS class of the popup.\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- },\n+ displayClass: \"olPopup\",\n \n- /**\n- * Property: matrix\n- * {Object} Matrix definition for the current map resolution. Updated by\n- * the method.\n+ /** \n+ * Property: contentDisplayClass\n+ * {String} The CSS class of the popup content div.\n */\n- matrix: null,\n+ contentDisplayClass: \"olPopupContent\",\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- *\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