/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the 2-clause BSD license. * See license.txt in the OpenLayers distribution or repository for the * full text of the license. */ /** * @requires OpenLayers/Control.js */ /** * Class: OpenLayers.Control.ArgParser * The ArgParser control adds location bar query string parsing functionality * to an OpenLayers Map. * When added to a Map control, on a page load/refresh, the Map will * automatically take the href string and parse it for lon, lat, zoom, and * layers information. * * Inherits from: * - */ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, { /** * Property: center * {} */ center: null, /** * Property: zoom * {int} */ zoom: null, /** * Property: layers * {String} Each character represents the state of the corresponding layer * on the map. */ layers: null, /** * APIProperty: displayProjection * {} Requires proj4js support. * Projection used when reading the coordinates from the URL. This will * reproject the map coordinates from the URL into the map's * projection. * * If you are using this functionality, be aware that any permalink * which is added to the map will determine the coordinate type which * is read from the URL, which means you should not add permalinks with * different displayProjections to the same map. */ displayProjection: null, /** * Constructor: OpenLayers.Control.ArgParser * * Parameters: * options - {Object} */ /** * Method: getParameters */ getParameters: function(url) { url = url || window.location.href; var parameters = OpenLayers.Util.getParameters(url); // If we have an anchor in the url use it to split the url var index = url.indexOf('#'); if (index > 0) { // create an url to parse on the getParameters url = '?' + url.substring(index + 1, url.length); OpenLayers.Util.extend(parameters, OpenLayers.Util.getParameters(url)); } return parameters; }, /** * Method: setMap * Set the map property for the control. * * Parameters: * map - {} */ setMap: function(map) { OpenLayers.Control.prototype.setMap.apply(this, arguments); //make sure we dont already have an arg parser attached for(var i=0, len=this.map.controls.length; i