+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Popup.js\r
-\r
-/**\r
-* @class\r
-*/\r
-OpenLayers.Popup.Anchored = Class.create();\r
-OpenLayers.Popup.Anchored.prototype =\r
- Object.extend( new OpenLayers.Popup(), {\r
-\r
- /** "lr", "ll", "tr", "tl" - relative position of the popup.\r
- * @type String */\r
- relativePosition: null,\r
-\r
- /** Object which must have expose a 'size' (OpenLayers.Size) and \r
- * 'offset' (OpenLayers.Pixel) \r
- * @type Object */\r
- anchor: null,\r
-\r
- /** \r
- * @constructor\r
- * \r
- * @param {String} id\r
- * @param {OpenLayers.LonLat} lonlat\r
- * @param {OpenLayers.Size} size\r
- * @param {String} contentHTML\r
- * @param {Object} anchor Object which must expose a \r
- * - 'size' (OpenLayers.Size) and \r
- * - 'offset' (OpenLayers.Pixel) \r
- * (this is generally an OpenLayers.Icon)\r
- */\r
- initialize:function(id, lonlat, size, contentHTML, anchor) {\r
- var newArguments = new Array(id, lonlat, size, contentHTML);\r
- OpenLayers.Popup.prototype.initialize.apply(this, newArguments);\r
-\r
- this.anchor = (anchor != null) ? anchor \r
- : { size: new OpenLayers.Size(0,0),\r
- offset: new OpenLayers.Pixel(0,0)};\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns Reference to a div that contains the drawn popup\r
- * @type DOMElement\r
- */\r
- draw: function(px) {\r
- if (px == null) {\r
- if ((this.lonlat != null) && (this.map != null)) {\r
- px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- }\r
- }\r
- \r
- //calculate relative position\r
- this.relativePosition = this.calculateRelativePosition(px);\r
- \r
- return OpenLayers.Popup.prototype.draw.apply(this, arguments);\r
- },\r
- \r
- /** \r
- * @private\r
- * \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns The relative position ("br" "tr" "tl "bl") at which the popup\r
- * should be placed\r
- * @type String\r
- */\r
- calculateRelativePosition:function(px) {\r
- var lonlat = this.map.getLonLatFromLayerPx(px); \r
- \r
- var extent = this.map.getExtent();\r
- var quadrant = extent.determineQuadrant(lonlat);\r
- \r
- return OpenLayers.Bounds.oppositeQuadrant(quadrant);\r
- }, \r
-\r
- /**\r
- * @param {OpenLayers.Pixel} px\r
- */\r
- moveTo: function(px) {\r
- \r
- var newPx = this.calculateNewPx(px);\r
- \r
- var newArguments = new Array(newPx); \r
- OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);\r
- },\r
- \r
- /**\r
- * @param {OpenLayers.Size} size\r
- */\r
- setSize:function(size) { \r
- OpenLayers.Popup.prototype.setSize.apply(this, arguments);\r
-\r
- if ((this.lonlat) && (this.map)) {\r
- var px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- this.moveTo(px);\r
- }\r
- }, \r
- \r
- /** \r
- * @private \r
- * \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns The the new px position of the popup on the screen\r
- * relative to the passed-in px\r
- * @type OpenLayers.Pixel\r
- */\r
- calculateNewPx:function(px) {\r
- var newPx = px.offset(this.anchor.offset);\r
-\r
- var top = (this.relativePosition.charAt(0) == 't');\r
- newPx.y += (top) ? -this.size.h : this.anchor.size.h;\r
- \r
- var left = (this.relativePosition.charAt(1) == 'l');\r
- newPx.x += (left) ? -this.size.w : this.anchor.size.w;\r
-\r
- return newPx; \r
- },\r
-\r
- CLASS_NAME: "OpenLayers.Popup.Anchored"\r
-});\r