Fix all cases where we have Windows line endings, and set eol-style="native"
on all files. Hopefully, this makes it easier for people to write patches and do other neat things. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1424 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -2,51 +2,51 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
*
|
||||
* @requires OpenLayers/Feature.js
|
||||
*/
|
||||
OpenLayers.Feature.WFS = Class.create();
|
||||
OpenLayers.Feature.WFS.prototype =
|
||||
Object.extend( new OpenLayers.Feature(), {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {OpenLayers.Layer} layer
|
||||
* @param {XMLNode} xmlNode
|
||||
*/
|
||||
initialize: function(layer, xmlNode) {
|
||||
var newArguments = arguments;
|
||||
if (arguments.length > 0) {
|
||||
var data = this.processXMLNode(xmlNode);
|
||||
newArguments = new Array(layer, data.lonlat, data)
|
||||
}
|
||||
OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
this.createMarker();
|
||||
this.layer.addMarker(this.marker);
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if (this.marker != null) {
|
||||
this.layer.removeMarker(this.marker);
|
||||
}
|
||||
OpenLayers.Feature.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {XMLNode} xmlNode
|
||||
*
|
||||
* @returns Data Object with 'id', 'lonlat', and private properties set
|
||||
* @type Object
|
||||
*/
|
||||
processXMLNode: function(xmlNode) {
|
||||
//this should be overridden by subclasses
|
||||
// must return an Object with 'id' and 'lonlat' values set
|
||||
*/
|
||||
OpenLayers.Feature.WFS = Class.create();
|
||||
OpenLayers.Feature.WFS.prototype =
|
||||
Object.extend( new OpenLayers.Feature(), {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {OpenLayers.Layer} layer
|
||||
* @param {XMLNode} xmlNode
|
||||
*/
|
||||
initialize: function(layer, xmlNode) {
|
||||
var newArguments = arguments;
|
||||
if (arguments.length > 0) {
|
||||
var data = this.processXMLNode(xmlNode);
|
||||
newArguments = new Array(layer, data.lonlat, data)
|
||||
}
|
||||
OpenLayers.Feature.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
if (arguments.length > 0) {
|
||||
this.createMarker();
|
||||
this.layer.addMarker(this.marker);
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
if (this.marker != null) {
|
||||
this.layer.removeMarker(this.marker);
|
||||
}
|
||||
OpenLayers.Feature.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {XMLNode} xmlNode
|
||||
*
|
||||
* @returns Data Object with 'id', 'lonlat', and private properties set
|
||||
* @type Object
|
||||
*/
|
||||
processXMLNode: function(xmlNode) {
|
||||
//this should be overridden by subclasses
|
||||
// must return an Object with 'id' and 'lonlat' values set
|
||||
var point = xmlNode.getElementsByTagName("Point");
|
||||
var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]);
|
||||
var floats = text.split(",");
|
||||
@@ -54,13 +54,13 @@ OpenLayers.Feature.WFS.prototype =
|
||||
parseFloat(floats[1])),
|
||||
id: null};
|
||||
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Feature.WFS"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
CLASS_NAME: "OpenLayers.Feature.WFS"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+226
-226
@@ -2,234 +2,234 @@
|
||||
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
|
||||
* text of the license. */
|
||||
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Popup = Class.create();
|
||||
|
||||
OpenLayers.Popup.WIDTH = 200;
|
||||
OpenLayers.Popup.HEIGHT = 200;
|
||||
OpenLayers.Popup.COLOR = "white";
|
||||
OpenLayers.Popup.OPACITY = 1;
|
||||
OpenLayers.Popup.BORDER = "0px";
|
||||
|
||||
OpenLayers.Popup.prototype = {
|
||||
|
||||
/** @type OpenLayers.Events*/
|
||||
events: null,
|
||||
|
||||
/** @type String */
|
||||
id: "",
|
||||
|
||||
/** @type OpenLayers.LonLat */
|
||||
lonlat: null,
|
||||
|
||||
/** @type DOMElement */
|
||||
div: null,
|
||||
|
||||
/** @type OpenLayers.Size*/
|
||||
size: null,
|
||||
|
||||
/** @type String */
|
||||
contentHTML: "",
|
||||
|
||||
/** @type String */
|
||||
backgroundColor: "",
|
||||
|
||||
/** @type float */
|
||||
opacity: "",
|
||||
|
||||
/** @type String */
|
||||
border: "",
|
||||
|
||||
/** this gets set in Map.js when the popup is added to the map
|
||||
* @type OpenLayers.Map */
|
||||
map: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML) {
|
||||
/**
|
||||
* @class
|
||||
*/
|
||||
OpenLayers.Popup = Class.create();
|
||||
|
||||
OpenLayers.Popup.WIDTH = 200;
|
||||
OpenLayers.Popup.HEIGHT = 200;
|
||||
OpenLayers.Popup.COLOR = "white";
|
||||
OpenLayers.Popup.OPACITY = 1;
|
||||
OpenLayers.Popup.BORDER = "0px";
|
||||
|
||||
OpenLayers.Popup.prototype = {
|
||||
|
||||
/** @type OpenLayers.Events*/
|
||||
events: null,
|
||||
|
||||
/** @type String */
|
||||
id: "",
|
||||
|
||||
/** @type OpenLayers.LonLat */
|
||||
lonlat: null,
|
||||
|
||||
/** @type DOMElement */
|
||||
div: null,
|
||||
|
||||
/** @type OpenLayers.Size*/
|
||||
size: null,
|
||||
|
||||
/** @type String */
|
||||
contentHTML: "",
|
||||
|
||||
/** @type String */
|
||||
backgroundColor: "",
|
||||
|
||||
/** @type float */
|
||||
opacity: "",
|
||||
|
||||
/** @type String */
|
||||
border: "",
|
||||
|
||||
/** this gets set in Map.js when the popup is added to the map
|
||||
* @type OpenLayers.Map */
|
||||
map: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML) {
|
||||
if (id == null) {
|
||||
id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
this.lonlat = lonlat;
|
||||
this.size = (size != null) ? size
|
||||
: new OpenLayers.Size(
|
||||
OpenLayers.Popup.WIDTH,
|
||||
OpenLayers.Popup.HEIGHT);
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
this.backgroundColor = OpenLayers.Popup.COLOR;
|
||||
this.opacity = OpenLayers.Popup.OPACITY;
|
||||
this.border = OpenLayers.Popup.BORDER;
|
||||
|
||||
this.div = OpenLayers.Util.createDiv(this.id, null, null,
|
||||
null, null, null, "hidden");
|
||||
|
||||
this.events = new OpenLayers.Events(this, this.div, null);
|
||||
},
|
||||
|
||||
/**
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.map != null) {
|
||||
this.map.removePopup(this);
|
||||
}
|
||||
this.div = null;
|
||||
this.map = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns Reference to a div that contains the drawn popup
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function(px) {
|
||||
if (px == null) {
|
||||
if ((this.lonlat != null) && (this.map != null)) {
|
||||
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
}
|
||||
}
|
||||
|
||||
this.setSize();
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
this.setBorder();
|
||||
this.setContentHTML();
|
||||
this.moveTo(px);
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* if the popup has a lonlat and its map members set,
|
||||
* then have it move itself to its proper position
|
||||
*/
|
||||
updatePosition: function() {
|
||||
if ((this.lonlat) && (this.map)) {
|
||||
var px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
this.moveTo(px);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*/
|
||||
moveTo: function(px) {
|
||||
if ((px != null) && (this.div != null)) {
|
||||
this.div.style.left = px.x + "px";
|
||||
this.div.style.top = px.y + "px";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns Boolean indicating whether or not the popup is visible
|
||||
* @type Boolean
|
||||
*/
|
||||
visible: function() {
|
||||
return Element.visible(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
toggle: function() {
|
||||
Element.toggle(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
show: function() {
|
||||
Element.show(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
hide: function() {
|
||||
Element.hide(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setSize:function(size) {
|
||||
if (size != undefined) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.style.width = this.size.w + "px";
|
||||
this.div.style.height = this.size.h + "px";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} color
|
||||
*/
|
||||
setBackgroundColor:function(color) {
|
||||
if (color != undefined) {
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.style.backgroundColor = this.backgroundColor;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {float} opacity
|
||||
*/
|
||||
setOpacity:function(opacity) {
|
||||
if (opacity != undefined) {
|
||||
this.opacity = opacity;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
// for Mozilla and Safari
|
||||
this.div.style.opacity = this.opacity;
|
||||
|
||||
// for IE
|
||||
this.div.style.filter = 'alpha(opacity=' + this.opacity*100 + ')';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} border
|
||||
*/
|
||||
setBorder:function(border) {
|
||||
if (border != undefined) {
|
||||
this.border = border;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.style.border = this.border;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
setContentHTML:function(contentHTML) {
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.innerHTML = this.contentHTML;
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup"
|
||||
};
|
||||
this.lonlat = lonlat;
|
||||
this.size = (size != null) ? size
|
||||
: new OpenLayers.Size(
|
||||
OpenLayers.Popup.WIDTH,
|
||||
OpenLayers.Popup.HEIGHT);
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
this.backgroundColor = OpenLayers.Popup.COLOR;
|
||||
this.opacity = OpenLayers.Popup.OPACITY;
|
||||
this.border = OpenLayers.Popup.BORDER;
|
||||
|
||||
this.div = OpenLayers.Util.createDiv(this.id, null, null,
|
||||
null, null, null, "hidden");
|
||||
|
||||
this.events = new OpenLayers.Events(this, this.div, null);
|
||||
},
|
||||
|
||||
/**
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.map != null) {
|
||||
this.map.removePopup(this);
|
||||
}
|
||||
this.div = null;
|
||||
this.map = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns Reference to a div that contains the drawn popup
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function(px) {
|
||||
if (px == null) {
|
||||
if ((this.lonlat != null) && (this.map != null)) {
|
||||
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
}
|
||||
}
|
||||
|
||||
this.setSize();
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
this.setBorder();
|
||||
this.setContentHTML();
|
||||
this.moveTo(px);
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* if the popup has a lonlat and its map members set,
|
||||
* then have it move itself to its proper position
|
||||
*/
|
||||
updatePosition: function() {
|
||||
if ((this.lonlat) && (this.map)) {
|
||||
var px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
this.moveTo(px);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*/
|
||||
moveTo: function(px) {
|
||||
if ((px != null) && (this.div != null)) {
|
||||
this.div.style.left = px.x + "px";
|
||||
this.div.style.top = px.y + "px";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns Boolean indicating whether or not the popup is visible
|
||||
* @type Boolean
|
||||
*/
|
||||
visible: function() {
|
||||
return Element.visible(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
toggle: function() {
|
||||
Element.toggle(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
show: function() {
|
||||
Element.show(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
hide: function() {
|
||||
Element.hide(this.div);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setSize:function(size) {
|
||||
if (size != undefined) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.style.width = this.size.w + "px";
|
||||
this.div.style.height = this.size.h + "px";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} color
|
||||
*/
|
||||
setBackgroundColor:function(color) {
|
||||
if (color != undefined) {
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.style.backgroundColor = this.backgroundColor;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {float} opacity
|
||||
*/
|
||||
setOpacity:function(opacity) {
|
||||
if (opacity != undefined) {
|
||||
this.opacity = opacity;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
// for Mozilla and Safari
|
||||
this.div.style.opacity = this.opacity;
|
||||
|
||||
// for IE
|
||||
this.div.style.filter = 'alpha(opacity=' + this.opacity*100 + ')';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {int} border
|
||||
*/
|
||||
setBorder:function(border) {
|
||||
if (border != undefined) {
|
||||
this.border = border;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.style.border = this.border;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
setContentHTML:function(contentHTML) {
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
this.div.innerHTML = this.contentHTML;
|
||||
}
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup"
|
||||
};
|
||||
|
||||
+120
-120
@@ -1,126 +1,126 @@
|
||||
/* 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. */
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Popup.js
|
||||
*/
|
||||
OpenLayers.Popup.Anchored = Class.create();
|
||||
OpenLayers.Popup.Anchored.prototype =
|
||||
Object.extend( new OpenLayers.Popup(), {
|
||||
|
||||
/** "lr", "ll", "tr", "tl" - relative position of the popup.
|
||||
* @type String */
|
||||
relativePosition: null,
|
||||
|
||||
/** Object which must have expose a 'size' (OpenLayers.Size) and
|
||||
* 'offset' (OpenLayers.Pixel)
|
||||
* @type Object */
|
||||
anchor: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
* @param {Object} anchor Object which must expose a
|
||||
* - 'size' (OpenLayers.Size) and
|
||||
* - 'offset' (OpenLayers.Pixel)
|
||||
* (this is generally an OpenLayers.Icon)
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
||||
var newArguments = new Array(id, lonlat, size, contentHTML);
|
||||
OpenLayers.Popup.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
this.anchor = (anchor != null) ? anchor
|
||||
: { size: new OpenLayers.Size(0,0),
|
||||
offset: new OpenLayers.Pixel(0,0)};
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns Reference to a div that contains the drawn popup
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function(px) {
|
||||
if (px == null) {
|
||||
if ((this.lonlat != null) && (this.map != null)) {
|
||||
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
}
|
||||
}
|
||||
|
||||
//calculate relative position
|
||||
this.relativePosition = this.calculateRelativePosition(px);
|
||||
|
||||
return OpenLayers.Popup.prototype.draw.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns The relative position ("br" "tr" "tl "bl") at which the popup
|
||||
* should be placed
|
||||
* @type String
|
||||
*/
|
||||
calculateRelativePosition:function(px) {
|
||||
var lonlat = this.map.getLonLatFromLayerPx(px);
|
||||
|
||||
var extent = this.map.getExtent();
|
||||
var quadrant = extent.determineQuadrant(lonlat);
|
||||
|
||||
return OpenLayers.Bounds.oppositeQuadrant(quadrant);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*/
|
||||
moveTo: function(px) {
|
||||
|
||||
var newPx = this.calculateNewPx(px);
|
||||
|
||||
var newArguments = new Array(newPx);
|
||||
OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setSize:function(size) {
|
||||
OpenLayers.Popup.prototype.setSize.apply(this, arguments);
|
||||
|
||||
if ((this.lonlat) && (this.map)) {
|
||||
var px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
this.moveTo(px);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns The the new px position of the popup on the screen
|
||||
* relative to the passed-in px
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
calculateNewPx:function(px) {
|
||||
var newPx = px.offset(this.anchor.offset);
|
||||
|
||||
var top = (this.relativePosition.charAt(0) == 't');
|
||||
newPx.y += (top) ? -this.size.h : this.anchor.size.h;
|
||||
|
||||
var left = (this.relativePosition.charAt(1) == 'l');
|
||||
newPx.x += (left) ? -this.size.w : this.anchor.size.w;
|
||||
|
||||
return newPx;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup.Anchored"
|
||||
});
|
||||
*/
|
||||
OpenLayers.Popup.Anchored = Class.create();
|
||||
OpenLayers.Popup.Anchored.prototype =
|
||||
Object.extend( new OpenLayers.Popup(), {
|
||||
|
||||
/** "lr", "ll", "tr", "tl" - relative position of the popup.
|
||||
* @type String */
|
||||
relativePosition: null,
|
||||
|
||||
/** Object which must have expose a 'size' (OpenLayers.Size) and
|
||||
* 'offset' (OpenLayers.Pixel)
|
||||
* @type Object */
|
||||
anchor: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
* @param {Object} anchor Object which must expose a
|
||||
* - 'size' (OpenLayers.Size) and
|
||||
* - 'offset' (OpenLayers.Pixel)
|
||||
* (this is generally an OpenLayers.Icon)
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
||||
var newArguments = new Array(id, lonlat, size, contentHTML);
|
||||
OpenLayers.Popup.prototype.initialize.apply(this, newArguments);
|
||||
|
||||
this.anchor = (anchor != null) ? anchor
|
||||
: { size: new OpenLayers.Size(0,0),
|
||||
offset: new OpenLayers.Pixel(0,0)};
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns Reference to a div that contains the drawn popup
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function(px) {
|
||||
if (px == null) {
|
||||
if ((this.lonlat != null) && (this.map != null)) {
|
||||
px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
}
|
||||
}
|
||||
|
||||
//calculate relative position
|
||||
this.relativePosition = this.calculateRelativePosition(px);
|
||||
|
||||
return OpenLayers.Popup.prototype.draw.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns The relative position ("br" "tr" "tl "bl") at which the popup
|
||||
* should be placed
|
||||
* @type String
|
||||
*/
|
||||
calculateRelativePosition:function(px) {
|
||||
var lonlat = this.map.getLonLatFromLayerPx(px);
|
||||
|
||||
var extent = this.map.getExtent();
|
||||
var quadrant = extent.determineQuadrant(lonlat);
|
||||
|
||||
return OpenLayers.Bounds.oppositeQuadrant(quadrant);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*/
|
||||
moveTo: function(px) {
|
||||
|
||||
var newPx = this.calculateNewPx(px);
|
||||
|
||||
var newArguments = new Array(newPx);
|
||||
OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setSize:function(size) {
|
||||
OpenLayers.Popup.prototype.setSize.apply(this, arguments);
|
||||
|
||||
if ((this.lonlat) && (this.map)) {
|
||||
var px = this.map.getLayerPxFromLonLat(this.lonlat);
|
||||
this.moveTo(px);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns The the new px position of the popup on the screen
|
||||
* relative to the passed-in px
|
||||
* @type OpenLayers.Pixel
|
||||
*/
|
||||
calculateNewPx:function(px) {
|
||||
var newPx = px.offset(this.anchor.offset);
|
||||
|
||||
var top = (this.relativePosition.charAt(0) == 't');
|
||||
newPx.y += (top) ? -this.size.h : this.anchor.size.h;
|
||||
|
||||
var left = (this.relativePosition.charAt(1) == 'l');
|
||||
newPx.x += (left) ? -this.size.w : this.anchor.size.w;
|
||||
|
||||
return newPx;
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup.Anchored"
|
||||
});
|
||||
|
||||
@@ -1,184 +1,184 @@
|
||||
/* 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. */
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Popup/Anchored.js
|
||||
*/
|
||||
OpenLayers.Popup.AnchoredBubble = Class.create();
|
||||
|
||||
//Border space for the rico corners
|
||||
OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;
|
||||
|
||||
OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
Object.extend( new OpenLayers.Popup.Anchored(), {
|
||||
|
||||
/** @type DOMElement */
|
||||
contentDiv:null,
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
* @param {Object} anchor Object which must expose a
|
||||
* - 'size' (OpenLayers.Size) and
|
||||
* - 'offset' (OpenLayers.Pixel)
|
||||
* (this is generally an OpenLayers.Icon)
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
||||
OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns Reference to a div that contains the drawn popup
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function(px) {
|
||||
|
||||
OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments);
|
||||
|
||||
// make the content Div
|
||||
var contentSize = this.size.clone();
|
||||
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
|
||||
|
||||
var id = this.div.id + "_contentDiv";
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize,
|
||||
null, "relative", null,
|
||||
"hidden");
|
||||
this.div.appendChild(this.contentDiv);
|
||||
this.setContentHTML();
|
||||
|
||||
this.setRicoCorners(true);
|
||||
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setSize:function(size) {
|
||||
OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments);
|
||||
|
||||
if (this.contentDiv != null) {
|
||||
|
||||
var contentSize = this.size.clone();
|
||||
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
|
||||
|
||||
this.contentDiv.style.height = contentSize.h + "px";
|
||||
|
||||
//size has changed - must redo corners
|
||||
this.setRicoCorners(false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} color
|
||||
*/
|
||||
setBackgroundColor:function(color) {
|
||||
if (color != undefined) {
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
if (this.contentDiv != null) {
|
||||
this.div.style.background = "transparent";
|
||||
Rico.Corner.changeColor(this.contentDiv, this.backgroundColor);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {float} opacity
|
||||
*/
|
||||
setOpacity:function(opacity) {
|
||||
if (opacity != undefined) {
|
||||
this.opacity = opacity;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
if (this.contentDiv != null) {
|
||||
Rico.Corner.changeOpacity(this.contentDiv, this.opacity);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** Bubble Popups can not have a border
|
||||
*
|
||||
* @param {int} border
|
||||
*/
|
||||
setBorder:function(border) {
|
||||
this.border = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
setContentHTML:function(contentHTML) {
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
|
||||
if (this.contentDiv != null) {
|
||||
this.contentDiv.innerHTML = this.contentHTML;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {Boolean} firstTime Is this the first time the corners are being
|
||||
* rounded?
|
||||
*
|
||||
* update the rico corners according to the popup's
|
||||
* current relative postion
|
||||
*/
|
||||
setRicoCorners:function(firstTime) {
|
||||
|
||||
var corners = this.getCornersToRound(this.relativePosition);
|
||||
var options = {corners: corners,
|
||||
color: this.backgroundColor,
|
||||
bgColor: "transparent",
|
||||
blend: false};
|
||||
|
||||
if (firstTime) {
|
||||
Rico.Corner.round(this.div, options);
|
||||
} else {
|
||||
Rico.Corner.reRound(this.contentDiv, options);
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @returns The proper corners string ("tr tl bl br") for rico
|
||||
* to round
|
||||
* @type String
|
||||
*/
|
||||
getCornersToRound:function() {
|
||||
|
||||
var corners = ['tl', 'tr', 'bl', 'br'];
|
||||
|
||||
//we want to round all the corners _except_ the opposite one.
|
||||
var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);
|
||||
corners.remove(corner);
|
||||
|
||||
return corners.join(" ");
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup.AnchoredBubble"
|
||||
});
|
||||
*/
|
||||
OpenLayers.Popup.AnchoredBubble = Class.create();
|
||||
|
||||
//Border space for the rico corners
|
||||
OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;
|
||||
|
||||
OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
Object.extend( new OpenLayers.Popup.Anchored(), {
|
||||
|
||||
/** @type DOMElement */
|
||||
contentDiv:null,
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*
|
||||
* @param {String} id
|
||||
* @param {OpenLayers.LonLat} lonlat
|
||||
* @param {OpenLayers.Size} size
|
||||
* @param {String} contentHTML
|
||||
* @param {Object} anchor Object which must expose a
|
||||
* - 'size' (OpenLayers.Size) and
|
||||
* - 'offset' (OpenLayers.Pixel)
|
||||
* (this is generally an OpenLayers.Icon)
|
||||
*/
|
||||
initialize:function(id, lonlat, size, contentHTML, anchor) {
|
||||
OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Pixel} px
|
||||
*
|
||||
* @returns Reference to a div that contains the drawn popup
|
||||
* @type DOMElement
|
||||
*/
|
||||
draw: function(px) {
|
||||
|
||||
OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments);
|
||||
|
||||
// make the content Div
|
||||
var contentSize = this.size.clone();
|
||||
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
|
||||
|
||||
var id = this.div.id + "_contentDiv";
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize,
|
||||
null, "relative", null,
|
||||
"hidden");
|
||||
this.div.appendChild(this.contentDiv);
|
||||
this.setContentHTML();
|
||||
|
||||
this.setRicoCorners(true);
|
||||
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
|
||||
return this.div;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {OpenLayers.Size} size
|
||||
*/
|
||||
setSize:function(size) {
|
||||
OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments);
|
||||
|
||||
if (this.contentDiv != null) {
|
||||
|
||||
var contentSize = this.size.clone();
|
||||
contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);
|
||||
|
||||
this.contentDiv.style.height = contentSize.h + "px";
|
||||
|
||||
//size has changed - must redo corners
|
||||
this.setRicoCorners(false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} color
|
||||
*/
|
||||
setBackgroundColor:function(color) {
|
||||
if (color != undefined) {
|
||||
this.backgroundColor = color;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
if (this.contentDiv != null) {
|
||||
this.div.style.background = "transparent";
|
||||
Rico.Corner.changeColor(this.contentDiv, this.backgroundColor);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {float} opacity
|
||||
*/
|
||||
setOpacity:function(opacity) {
|
||||
if (opacity != undefined) {
|
||||
this.opacity = opacity;
|
||||
}
|
||||
|
||||
if (this.div != null) {
|
||||
if (this.contentDiv != null) {
|
||||
Rico.Corner.changeOpacity(this.contentDiv, this.opacity);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/** Bubble Popups can not have a border
|
||||
*
|
||||
* @param {int} border
|
||||
*/
|
||||
setBorder:function(border) {
|
||||
this.border = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} contentHTML
|
||||
*/
|
||||
setContentHTML:function(contentHTML) {
|
||||
if (contentHTML != null) {
|
||||
this.contentHTML = contentHTML;
|
||||
}
|
||||
|
||||
if (this.contentDiv != null) {
|
||||
this.contentDiv.innerHTML = this.contentHTML;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @param {Boolean} firstTime Is this the first time the corners are being
|
||||
* rounded?
|
||||
*
|
||||
* update the rico corners according to the popup's
|
||||
* current relative postion
|
||||
*/
|
||||
setRicoCorners:function(firstTime) {
|
||||
|
||||
var corners = this.getCornersToRound(this.relativePosition);
|
||||
var options = {corners: corners,
|
||||
color: this.backgroundColor,
|
||||
bgColor: "transparent",
|
||||
blend: false};
|
||||
|
||||
if (firstTime) {
|
||||
Rico.Corner.round(this.div, options);
|
||||
} else {
|
||||
Rico.Corner.reRound(this.contentDiv, options);
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @private
|
||||
*
|
||||
* @returns The proper corners string ("tr tl bl br") for rico
|
||||
* to round
|
||||
* @type String
|
||||
*/
|
||||
getCornersToRound:function() {
|
||||
|
||||
var corners = ['tl', 'tr', 'bl', 'br'];
|
||||
|
||||
//we want to round all the corners _except_ the opposite one.
|
||||
var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);
|
||||
corners.remove(corner);
|
||||
|
||||
return corners.join(" ");
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Popup.AnchoredBubble"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user