Pullup trunk for RC4.
Fixes: #694 Safari 1.3.2 doesn't work with OL 2.4 #695 GeoRSS serializer is broken #696 events need to fall through the overview map extent rectangle #697 Vector example to show how to use styles #698 add close box option to AnchoredBubble #701 SVG render does not always clear features when map extent changes #703 OpenLayers.Layer.Vector do not properly destroy its features #706 Full CSS support fails when Control.OverviewMap is loaded #708 change WKT format to deal in features instead of geometries #710 Install instructions unclear #711 OpenLayers.Layer.Image requires OpenLayers.Tile.Image #715 layer.js needs sanity check #718 WMS.Untiled Clone doesn't work #719 SVG renderer does not always redraw LineStrings and Polygons #720 remove console.log() from OpenLayers.Format.WKT git-svn-id: http://svn.openlayers.org/branches/openlayers/2.4@3177 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
OpenLayers contributors:
|
||||
Howard Butler
|
||||
Bertil Chaupis
|
||||
John Cole
|
||||
Jeff Dege
|
||||
Schuyler Erle
|
||||
Christian López Espínola
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<head>
|
||||
<style type="text/css">
|
||||
#map {
|
||||
width: 512px;
|
||||
width: 45%;
|
||||
height: 350px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
@@ -42,8 +42,8 @@
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<h1>OpenLayers Draw Point Example</h1>
|
||||
<div style="float:right">
|
||||
<textarea id="gml" cols="80" rows="30"></textarea>
|
||||
<div style="float:right;width:50%">
|
||||
<textarea id="gml" style="width:100%" rows="30"></textarea>
|
||||
</div>
|
||||
<div id="map"></div>
|
||||
</body>
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
popup = new OpenLayers.Popup.Anchored("chicken",
|
||||
new OpenLayers.LonLat(5,40),
|
||||
new OpenLayers.Size(200,200),
|
||||
"example popup");
|
||||
"example popup", true);
|
||||
|
||||
map.addPopup(popup);
|
||||
}
|
||||
@@ -69,8 +69,17 @@
|
||||
}
|
||||
|
||||
function mousedown(evt) {
|
||||
// check to see if the popup was hidden by the close box
|
||||
// if so, then destroy it before continuing
|
||||
if (popup != null) {
|
||||
if (!popup.visible()) {
|
||||
markers.map.removePopup(popup);
|
||||
popup.destroy();
|
||||
popup = null;
|
||||
}
|
||||
}
|
||||
if (popup == null) {
|
||||
popup = feature.createPopup();
|
||||
popup = feature.createPopup(true);
|
||||
popup.setContentHTML("<a href='http://www.somethingconstructive.net' target='_blank'>click me</a>");
|
||||
popup.setBackgroundColor("yellow");
|
||||
popup.setOpacity(0.7);
|
||||
|
||||
@@ -17,11 +17,23 @@
|
||||
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
|
||||
map.addLayer(layer);
|
||||
|
||||
var style_blue = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
|
||||
style_blue.strokeColor = "blue";
|
||||
style_blue.fillColor = "blue";
|
||||
var style_green = {
|
||||
strokeColor: "#00FF00",
|
||||
strokeOpacity: 1,
|
||||
strokeWidth: 3,
|
||||
pointRadius: 6,
|
||||
pointerEvents: "visiblePainted"
|
||||
};
|
||||
|
||||
var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry");
|
||||
|
||||
// create a point feature
|
||||
var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
|
||||
var pointFeature = new OpenLayers.Feature.Vector(point);
|
||||
var pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue);
|
||||
|
||||
// create a line feature from a list of points
|
||||
var pointList = [];
|
||||
@@ -32,7 +44,7 @@
|
||||
pointList.push(newPoint);
|
||||
}
|
||||
var lineFeature = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString(pointList));
|
||||
new OpenLayers.Geometry.LineString(pointList),null,style_green);
|
||||
|
||||
// create a polygon feature from a linear ring of points
|
||||
var pointList = [];
|
||||
@@ -59,5 +71,9 @@
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<div id="map"></div>
|
||||
<p>This example shows drawing simple vector features -- point, line, polygon
|
||||
in different styles, created 'manually', by constructing the entire style
|
||||
object, via 'copy', extending the default style object, and by
|
||||
inheriting the default style from the layer.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
}
|
||||
|
||||
function displayWKT(feature) {
|
||||
var str = wkt.write(feature.geometry);
|
||||
var str = wkt.write(feature);
|
||||
// not a good idea in general, just for this demo
|
||||
str = str.replace(/,/g, ', ');
|
||||
document.getElementById('info').innerHTML = str;
|
||||
@@ -86,19 +86,18 @@
|
||||
|
||||
function parseWKT() {
|
||||
var element = document.getElementById('wkt');
|
||||
var collection = wkt.read(element.value);
|
||||
var features = wkt.read(element.value);
|
||||
var bounds;
|
||||
if(collection) {
|
||||
if(collection.constructor != Array) {
|
||||
collection = [collection];
|
||||
if(features) {
|
||||
if(features.constructor != Array) {
|
||||
features = [features];
|
||||
}
|
||||
var features = [];
|
||||
for(var i=0; i<collection.length; ++i) {
|
||||
features.push(new OpenLayers.Feature.Vector(collection[i]));
|
||||
for(var i=0; i<features.length; ++i) {
|
||||
if (!bounds) {
|
||||
bounds = collection[i].getBounds();
|
||||
bounds = features[i].geometry.getBounds();
|
||||
} else {
|
||||
bounds.extend(features[i].geometry.getBounds());
|
||||
}
|
||||
bounds.extend(collection[i].getBounds());
|
||||
|
||||
}
|
||||
vectors.addFeatures(features);
|
||||
|
||||
@@ -32,7 +32,8 @@ OpenLayers.Class = {
|
||||
//
|
||||
// to be revisited in 3.0
|
||||
//
|
||||
if (arguments[i].hasOwnProperty('toString')) {
|
||||
if((arguments[i].hasOwnProperty && arguments[i].hasOwnProperty('toString')) ||
|
||||
(!arguments[i].hasOwnProperty && arguments[i].toString)) {
|
||||
proto.toString = arguments[i].toString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,8 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
this.elementEvents.register('dblclick', this, function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle);
|
||||
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,
|
||||
null, true);
|
||||
this.rectEvents.register('mouseout', this, this.rectMouseOut);
|
||||
this.rectEvents.register('mousedown', this, this.rectMouseDown);
|
||||
this.rectEvents.register('mousemove', this, this.rectMouseMove);
|
||||
|
||||
@@ -121,6 +121,7 @@ OpenLayers.Feature.prototype= {
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {Boolean} closeBox create popup with closebox or not
|
||||
* @returns A Popup Object created from the 'lonlat', 'popupSize',
|
||||
* and 'popupContentHTML' properties set in this.data. It uses
|
||||
* this.marker.icon as default anchor.
|
||||
@@ -132,7 +133,7 @@ OpenLayers.Feature.prototype= {
|
||||
*
|
||||
* @type OpenLayers.Popup.AnchoredBubble
|
||||
*/
|
||||
createPopup: function() {
|
||||
createPopup: function(closeBox) {
|
||||
|
||||
if (this.lonlat != null) {
|
||||
|
||||
@@ -143,7 +144,7 @@ OpenLayers.Feature.prototype= {
|
||||
this.lonlat,
|
||||
this.data.popupSize,
|
||||
this.data.popupContentHTML,
|
||||
anchor);
|
||||
anchor, closeBox);
|
||||
}
|
||||
return this.popup;
|
||||
},
|
||||
|
||||
@@ -97,10 +97,10 @@ OpenLayers.Format.GeoRSS.prototype =
|
||||
var path = "";
|
||||
if (points) {
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
path += points[i].lat + " " + points[i].lon + " ";
|
||||
path += points[i].y + " " + points[i].x + " ";
|
||||
}
|
||||
} else {
|
||||
path += geometry.lat + " " + geometry.lon + " ";
|
||||
path += geometry.y + " " + geometry.x + " ";
|
||||
}
|
||||
return document.createTextNode(path);
|
||||
},
|
||||
|
||||
@@ -25,38 +25,41 @@ OpenLayers.Format.WKT.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* Deserialize a WKT string and return an OpenLayers.Geometry or an array
|
||||
* of OpenLayers.Geometry. Supports WKT for POINT, MULTIPOINT, LINESTRING,
|
||||
* MULTILINESTRING, POLYGON, MULTIPOLYGON, and GEOMETRYCOLLECTION.
|
||||
* Deserialize a WKT string and return an OpenLayers.Feature.Vector or an
|
||||
* array of OpenLayers.Feature.Vector. Supports WKT for POINT, MULTIPOINT,
|
||||
* LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, and
|
||||
* GEOMETRYCOLLECTION.
|
||||
* @param {String} wkt A WKT string
|
||||
* @returns {OpenLayers.Geometry|Array} A geometry or array of geometries
|
||||
* for GEOMETRYCOLLECTION WKT.
|
||||
* @returns {OpenLayers.Feature.Vector|Array} A feature or array of
|
||||
* features for
|
||||
* GEOMETRYCOLLECTION WKT.
|
||||
*/
|
||||
read: function(wkt) {
|
||||
var geometry, type, str;
|
||||
var features, type, str;
|
||||
var matches = this.regExes.typeStr.exec(wkt);
|
||||
if(matches) {
|
||||
type = matches[1].toLowerCase();
|
||||
str = matches[2];
|
||||
if(this.parse[type]) {
|
||||
geometry = this.parse[type].apply(this, [str]);
|
||||
features = this.parse[type].apply(this, [str]);
|
||||
}
|
||||
}
|
||||
return geometry;
|
||||
return features;
|
||||
},
|
||||
|
||||
/**
|
||||
* Serialize a geometry or array of geometries into a WKT string.
|
||||
* @param {OpenLayers.Geometry|Array} geom A geometry or array of geometries
|
||||
* Serialize a feature or array of features into a WKT string.
|
||||
* @param {OpenLayers.Feature.Vector|Array} features A feature or array of
|
||||
* features
|
||||
* @returns {String} The WKT string representation of the input geometries
|
||||
*/
|
||||
write: function(geom) {
|
||||
write: function(features) {
|
||||
var collection, geometry, type, data, isCollection;
|
||||
if(geom.constructor == Array) {
|
||||
collection = geom;
|
||||
if(features.constructor == Array) {
|
||||
collection = features;
|
||||
isCollection = true;
|
||||
} else {
|
||||
collection = [geom];
|
||||
collection = [features];
|
||||
isCollection = false;
|
||||
}
|
||||
var pieces = [];
|
||||
@@ -67,7 +70,7 @@ OpenLayers.Format.WKT.prototype =
|
||||
if(isCollection && i>0) {
|
||||
pieces.push(',');
|
||||
}
|
||||
geometry = collection[i];
|
||||
geometry = collection[i].geometry;
|
||||
type = geometry.CLASS_NAME.split('.')[2].toLowerCase();
|
||||
if(!this.extract[type]) {
|
||||
return null;
|
||||
@@ -178,47 +181,57 @@ OpenLayers.Format.WKT.prototype =
|
||||
*/
|
||||
parse: {
|
||||
/**
|
||||
* Return point geometry given a point WKT fragment.
|
||||
* Return point feature given a point WKT fragment.
|
||||
* @param {String} str A WKT fragment representing the point
|
||||
* @returns {OpenLayers.Geometry.Point} A point geometry
|
||||
* @returns {OpenLayers.Feature.Vector} A point feature
|
||||
* @private
|
||||
*/
|
||||
'point': function(str) {
|
||||
var coords = str.trim().split(this.regExes.spaces);
|
||||
return new OpenLayers.Geometry.Point(coords[0], coords[1]);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(coords[0], coords[1])
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a multipoint geometry given a multipoint WKT fragment.
|
||||
* Return a multipoint feature given a multipoint WKT fragment.
|
||||
* @param {String} A WKT fragment representing the multipoint
|
||||
* @returns {OpenLayers.Geometry.MultiPoint} A multipoint geometry
|
||||
* @returns {OpenLayers.Feature.Vector} A multipoint feature
|
||||
* @private
|
||||
*/
|
||||
'multipoint': function(str) {
|
||||
var points = str.trim().split(',');
|
||||
var components = [];
|
||||
for(var i=0; i<points.length; ++i) {
|
||||
components.push(this.parse.point.apply(this, [points[i]]));
|
||||
components.push(this.parse.point.apply(this, [points[i]]).geometry);
|
||||
}
|
||||
return new OpenLayers.Geometry.MultiPoint(components);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPoint(components)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a linestring geometry given a linestring WKT fragment.
|
||||
* Return a linestring feature given a linestring WKT fragment.
|
||||
* @param {String} A WKT fragment representing the linestring
|
||||
* @returns {OpenLayers.Geometry.LineString} A linestring geometry
|
||||
* @returns {OpenLayers.Feature.Vector} A linestring feature
|
||||
* @private
|
||||
*/
|
||||
'linestring': function(str) {
|
||||
var points = str.trim().split(',');
|
||||
var components = [];
|
||||
for(var i=0; i<points.length; ++i) {
|
||||
components.push(this.parse.point.apply(this, [points[i]]));
|
||||
components.push(this.parse.point.apply(this, [points[i]]).geometry);
|
||||
}
|
||||
return new OpenLayers.Geometry.LineString(components);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString(components)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a multilinestring geometry given a multilinestring WKT fragment.
|
||||
* Return a multilinestring feature given a multilinestring WKT fragment.
|
||||
* @param {String} A WKT fragment representing the multilinestring
|
||||
* @returns {OpenLayers.Geometry.LineString} A multilinestring geometry
|
||||
* @returns {OpenLayers.Feature.Vector} A multilinestring feature
|
||||
* @private
|
||||
*/
|
||||
'multilinestring': function(str) {
|
||||
var line;
|
||||
@@ -226,15 +239,18 @@ OpenLayers.Format.WKT.prototype =
|
||||
var components = [];
|
||||
for(var i=0; i<lines.length; ++i) {
|
||||
line = lines[i].replace(this.regExes.trimParens, '$1');
|
||||
components.push(this.parse.linestring.apply(this, [line]));
|
||||
components.push(this.parse.linestring.apply(this, [line]).geometry);
|
||||
}
|
||||
return new OpenLayers.Geometry.MultiLineString(components);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiLineString(components)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a polygon geometry given a polygon WKT fragment.
|
||||
* Return a polygon feature given a polygon WKT fragment.
|
||||
* @param {String} A WKT fragment representing the polygon
|
||||
* @returns {OpenLayers.Geometry.Polygon} A polygon geometry
|
||||
* @returns {OpenLayers.Feature.Vector} A polygon feature
|
||||
* @private
|
||||
*/
|
||||
'polygon': function(str) {
|
||||
var ring, linestring, linearring;
|
||||
@@ -242,17 +258,20 @@ OpenLayers.Format.WKT.prototype =
|
||||
var components = [];
|
||||
for(var i=0; i<rings.length; ++i) {
|
||||
ring = rings[i].replace(this.regExes.trimParens, '$1');
|
||||
linestring = this.parse.linestring.apply(this, [ring]);
|
||||
linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
|
||||
linestring = this.parse.linestring.apply(this, [ring]).geometry;
|
||||
linearring = new OpenLayers.Geometry.LinearRing(linestring.components)
|
||||
components.push(linearring);
|
||||
}
|
||||
return new OpenLayers.Geometry.Polygon(components);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon(components)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return a multipolygon geometry given a multipolygon WKT fragment.
|
||||
* Return a multipolygon feature given a multipolygon WKT fragment.
|
||||
* @param {String} A WKT fragment representing the multipolygon
|
||||
* @returns {OpenLayers.Geometry.MultiPolygon} A multipolygon geometry
|
||||
* @returns {OpenLayers.Feature.Vector} A multipolygon feature
|
||||
* @private
|
||||
*/
|
||||
'multipolygon': function(str) {
|
||||
var polygon;
|
||||
@@ -260,15 +279,18 @@ OpenLayers.Format.WKT.prototype =
|
||||
var components = [];
|
||||
for(var i=0; i<polygons.length; ++i) {
|
||||
polygon = polygons[i].replace(this.regExes.trimParens, '$1');
|
||||
components.push(this.parse.polygon.apply(this, [polygon]));
|
||||
components.push(this.parse.polygon.apply(this, [polygon]).geometry);
|
||||
}
|
||||
return new OpenLayers.Geometry.MultiPolygon(components);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPolygon(components)
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an array of geometries given a geometrycollection WKT fragment.
|
||||
* Return an array of features given a geometrycollection WKT fragment.
|
||||
* @param {String} A WKT fragment representing the geometrycollection
|
||||
* @returns {Array} An array of OpenLayers.Geometry
|
||||
* @returns {Array} An array of OpenLayers.Feature.Vector
|
||||
* @private
|
||||
*/
|
||||
'geometrycollection': function(str) {
|
||||
// separate components of the collection with |
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
/**
|
||||
* @class
|
||||
* @requires OpenLayers/Format/WKT.js
|
||||
* @requires OpenLayers/Feature/Vector.js
|
||||
*/
|
||||
OpenLayers.Geometry = OpenLayers.Class.create();
|
||||
OpenLayers.Geometry.prototype = {
|
||||
@@ -150,7 +151,9 @@ OpenLayers.Geometry.prototype = {
|
||||
* @type String
|
||||
*/
|
||||
toString: function() {
|
||||
return OpenLayers.Format.WKT.prototype.write(this);
|
||||
return OpenLayers.Format.WKT.prototype.write(
|
||||
new OpenLayers.Feature.Vector(this)
|
||||
);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
@@ -608,13 +608,15 @@ OpenLayers.Layer.prototype = {
|
||||
if (viewPortPx != null) {
|
||||
var size = this.map.getSize();
|
||||
var center = this.map.getCenter();
|
||||
var res = this.map.getResolution();
|
||||
if (center) {
|
||||
var res = this.map.getResolution();
|
||||
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
var delta_y = viewPortPx.y - (size.h / 2);
|
||||
var delta_x = viewPortPx.x - (size.w / 2);
|
||||
var delta_y = viewPortPx.y - (size.h / 2);
|
||||
|
||||
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
} // else { DEBUG STATEMENT }
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer.js
|
||||
* @requires OpenLayers/Tile/Image.js
|
||||
*/
|
||||
OpenLayers.Layer.Image = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Image.prototype =
|
||||
|
||||
@@ -97,8 +97,7 @@ OpenLayers.Layer.Vector.prototype =
|
||||
destroy: function() {
|
||||
OpenLayers.Layer.prototype.destroy.apply(this, arguments);
|
||||
|
||||
// HACK HACK -- I believe we should be iterating and
|
||||
// calling feature[i].destroy() here.
|
||||
this.destroyFeatures();
|
||||
this.features = null;
|
||||
this.selectedFeatures = null;
|
||||
if (this.renderer) {
|
||||
@@ -247,7 +246,9 @@ OpenLayers.Layer.Vector.prototype =
|
||||
var feature = features[i];
|
||||
this.features = OpenLayers.Util.removeItem(this.features, feature);
|
||||
|
||||
this.renderer.eraseGeometry(feature.geometry);
|
||||
if (feature.geometry) {
|
||||
this.renderer.eraseGeometry(feature.geometry);
|
||||
}
|
||||
|
||||
//in the case that this feature is one of the selected features,
|
||||
// remove it from that array as well.
|
||||
|
||||
@@ -93,6 +93,8 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
|
||||
// copy/set any non-init, non-simple values here
|
||||
|
||||
obj.tile = null;
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
|
||||
@@ -199,11 +199,25 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
// only append link stylesheet if the theme property is set
|
||||
if(this.theme) {
|
||||
var cssNode = document.createElement('link');
|
||||
cssNode.setAttribute('rel', 'stylesheet');
|
||||
cssNode.setAttribute('type', 'text/css');
|
||||
cssNode.setAttribute('href', this.theme);
|
||||
document.getElementsByTagName('head')[0].appendChild(cssNode);
|
||||
// check existing links for equivalent url
|
||||
var addNode = true;
|
||||
var nodes = document.getElementsByTagName('link');
|
||||
for(var i=0; i<nodes.length; ++i) {
|
||||
if(OpenLayers.Util.isEquivalentUrl(nodes.item(i).href,
|
||||
this.theme)) {
|
||||
addNode = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// only add a new node if one with an equivalent url hasn't already
|
||||
// been added
|
||||
if(addNode) {
|
||||
var cssNode = document.createElement('link');
|
||||
cssNode.setAttribute('rel', 'stylesheet');
|
||||
cssNode.setAttribute('type', 'text/css');
|
||||
cssNode.setAttribute('href', this.theme);
|
||||
document.getElementsByTagName('head')[0].appendChild(cssNode);
|
||||
}
|
||||
}
|
||||
|
||||
this.layers = [];
|
||||
|
||||
@@ -46,6 +46,9 @@ OpenLayers.Popup.prototype = {
|
||||
/** @type DOMElement */
|
||||
contentDiv:null,
|
||||
|
||||
/** @type DOMElement */
|
||||
groupDiv:null,
|
||||
|
||||
/** @type int */
|
||||
padding: 5,
|
||||
|
||||
@@ -85,12 +88,17 @@ OpenLayers.Popup.prototype = {
|
||||
null, null, null, "hidden");
|
||||
this.div.className = 'olPopup';
|
||||
|
||||
this.groupDiv = OpenLayers.Util.createDiv(null, null, null,
|
||||
null, "relative", null,
|
||||
"hidden");
|
||||
|
||||
var id = this.div.id + "_contentDiv";
|
||||
this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(),
|
||||
null, "relative", null,
|
||||
"hidden");
|
||||
this.contentDiv.className = 'olPopupContent';
|
||||
this.div.appendChild(this.contentDiv);
|
||||
this.groupDiv.appendChild(this.contentDiv);
|
||||
this.div.appendChild(this.groupDiv);
|
||||
|
||||
if (closeBox == true) {
|
||||
// close icon
|
||||
@@ -102,7 +110,7 @@ OpenLayers.Popup.prototype = {
|
||||
img);
|
||||
closeImg.style.right = this.padding + "px";
|
||||
closeImg.style.top = this.padding + "px";
|
||||
this.div.appendChild(closeImg);
|
||||
this.groupDiv.appendChild(closeImg);
|
||||
|
||||
var closePopup = function(e) {
|
||||
this.hide();
|
||||
|
||||
@@ -139,7 +139,7 @@ OpenLayers.Popup.AnchoredBubble.prototype =
|
||||
if (firstTime) {
|
||||
OpenLayers.Rico.Corner.round(this.div, options);
|
||||
} else {
|
||||
OpenLayers.Rico.Corner.reRound(this.contentDiv, options);
|
||||
OpenLayers.Rico.Corner.reRound(this.groupDiv, options);
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
|
||||
@@ -282,9 +282,7 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
node.setAttributeNS(null, "cy", y);
|
||||
node.setAttributeNS(null, "r", radius);
|
||||
} else {
|
||||
node.setAttributeNS(null, "cx", "");
|
||||
node.setAttributeNS(null, "cy", "");
|
||||
node.setAttributeNS(null, "r", 0);
|
||||
this.root.removeChild(node);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -434,8 +432,9 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
var strings = [];
|
||||
for(var i = 0; i < components.length; i++) {
|
||||
var component = this.getShortString(components[i]);
|
||||
if (!component) { return false; }
|
||||
strings.push(component);
|
||||
if (component) {
|
||||
strings.push(component);
|
||||
}
|
||||
}
|
||||
return strings.join(",");
|
||||
},
|
||||
|
||||
21
readme.txt
21
readme.txt
@@ -20,17 +20,30 @@ Installing OpenLayers
|
||||
---------------------
|
||||
|
||||
You can use OpenLayers as-is by copying build/OpenLayers.js and the
|
||||
entire lib/ directory up to your webserver, putting them in the same
|
||||
directory. To include the OpenLayers library in your web page, use:
|
||||
entire theme/ and img/ directories up to your webserver, putting them
|
||||
in the same directory. The files can be in subdirectories on your website, or right in the root of the site, as in these examples. To include the OpenLayers library in your web page from the root of the site, use:
|
||||
|
||||
<script type="text/javascript" src="OpenLayers.js" />
|
||||
<script type="text/javascript" src="/OpenLayers.js" />
|
||||
|
||||
As an example, using bash (with the release files in ~/openlayers ):
|
||||
$ cd /var/www/html
|
||||
$ cp ~/openlayers/build/OpenLayers.js ./
|
||||
$ cp -R ~/openlayers/theme ./
|
||||
$ cp -R ~/openlayers/img ./
|
||||
|
||||
If you want to use the multiple-file version of OpenLayers (for, say,
|
||||
debugging or development purposes), copy the lib/ directory up to your
|
||||
webserver in the same directory you put the img/ folder. Then add
|
||||
the following to your web page instead:
|
||||
|
||||
<script type="text/javascript" src="lib/OpenLayers.js" />
|
||||
<script type="text/javascript" src="/lib/OpenLayers.js" />
|
||||
|
||||
As an example, using bash (with the release files in ~/openlayers ):
|
||||
$ cd /var/www/html
|
||||
$ cp -R ~/openlayers/lib ./
|
||||
$ cp -R ~/openlayers/theme ./
|
||||
$ cp -R ~/openlayers/img ./
|
||||
|
||||
|
||||
------------------------------------
|
||||
Using OpenLayers in Your Own Website
|
||||
|
||||
34
tests/Format/test_GeoRSS.html
Normal file
34
tests/Format/test_GeoRSS.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
|
||||
|
||||
function test_Format_GeoRSS_constructor(t) {
|
||||
t.plan(4);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var format = new OpenLayers.Format.GeoRSS(options);
|
||||
t.ok(format instanceof OpenLayers.Format.GeoRSS,
|
||||
"new OpenLayers.Format.GeoRSS returns object" );
|
||||
t.eq(format.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof format.read, "function", "format has a read function");
|
||||
t.eq(typeof format.write, "function", "format has a write function");
|
||||
}
|
||||
function test_Format_GeoRSS_serializeline(t) {
|
||||
t.plan(1);
|
||||
var parser = new OpenLayers.Format.GeoRSS();
|
||||
var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
|
||||
var point2 = new OpenLayers.Geometry.Point(-112.04, 45.68);
|
||||
var l = new OpenLayers.Geometry.LineString([point, point2]);
|
||||
var f = new OpenLayers.Feature.Vector(l);
|
||||
var data = parser.write([f]);
|
||||
t.eq(data.firstChild.childNodes[2].firstChild.nodeValue, '45.68 -111.04 45.68 -112.04 ', 'GeoRSS serializes a line correctly');
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,37 +5,53 @@
|
||||
|
||||
var points = [];
|
||||
for(var i=0; i<12; ++i) {
|
||||
points.push(new OpenLayers.Geometry.Point(Math.random() * 100,
|
||||
Math.random() * 100));
|
||||
points.push(new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(Math.random() * 100,
|
||||
Math.random() * 100))
|
||||
);
|
||||
}
|
||||
var multipoint = new OpenLayers.Geometry.MultiPoint([
|
||||
points[0], points[1], points[2]
|
||||
]);
|
||||
var multipoint = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPoint([
|
||||
points[0].geometry, points[1].geometry, points[2].geometry
|
||||
])
|
||||
);
|
||||
|
||||
var linestrings = [
|
||||
new OpenLayers.Geometry.LineString([points[0], points[1], points[2]]),
|
||||
new OpenLayers.Geometry.LineString([points[3], points[4], points[5]])
|
||||
new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString([points[0].geometry, points[1].geometry, points[2].geometry])
|
||||
),
|
||||
new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString([points[3].geometry, points[4].geometry, points[5].geometry])
|
||||
)
|
||||
];
|
||||
|
||||
var multilinestring = new OpenLayers.Geometry.MultiLineString([
|
||||
linestrings[0], linestrings[1]
|
||||
]);
|
||||
var multilinestring = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiLineString([
|
||||
linestrings[0].geometry, linestrings[1].geometry
|
||||
])
|
||||
);
|
||||
|
||||
var rings = [
|
||||
new OpenLayers.Geometry.LinearRing([points[0], points[1], points[2]]),
|
||||
new OpenLayers.Geometry.LinearRing([points[3], points[4], points[5]]),
|
||||
new OpenLayers.Geometry.LinearRing([points[6], points[7], points[8]]),
|
||||
new OpenLayers.Geometry.LinearRing([points[9], points[10], points[11]])
|
||||
new OpenLayers.Geometry.LinearRing([points[0].geometry, points[1].geometry, points[2].geometry]),
|
||||
new OpenLayers.Geometry.LinearRing([points[3].geometry, points[4].geometry, points[5].geometry]),
|
||||
new OpenLayers.Geometry.LinearRing([points[6].geometry, points[7].geometry, points[8].geometry]),
|
||||
new OpenLayers.Geometry.LinearRing([points[9].geometry, points[10].geometry, points[11].geometry])
|
||||
];
|
||||
|
||||
var polygons = [
|
||||
new OpenLayers.Geometry.Polygon([rings[0], rings[1]]),
|
||||
new OpenLayers.Geometry.Polygon([rings[2], rings[3]])
|
||||
new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon([rings[0], rings[1]])
|
||||
),
|
||||
new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon([rings[2], rings[3]])
|
||||
)
|
||||
];
|
||||
|
||||
var multipolygon = new OpenLayers.Geometry.MultiPolygon([
|
||||
polygons[0], polygons[1]
|
||||
]);
|
||||
var multipolygon = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPolygon([
|
||||
polygons[0].geometry, polygons[1].geometry
|
||||
])
|
||||
);
|
||||
|
||||
var collection = [points[0], linestrings[0]];
|
||||
|
||||
@@ -56,71 +72,71 @@
|
||||
|
||||
// test a point
|
||||
t.eq(format.write(points[0]),
|
||||
"POINT(" + points[0].x + " " + points[0].y + ")",
|
||||
"POINT(" + points[0].geometry.x + " " + points[0].geometry.y + ")",
|
||||
"format correctly writes Point WKT");
|
||||
|
||||
// test a multipoint
|
||||
t.eq(format.write(multipoint),
|
||||
"MULTIPOINT(" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + ")",
|
||||
"MULTIPOINT(" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + ")",
|
||||
"format correctly writes MultiPoint WKT");
|
||||
|
||||
// test a linestring
|
||||
t.eq(format.write(linestrings[0]),
|
||||
"LINESTRING(" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + ")",
|
||||
"LINESTRING(" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + ")",
|
||||
"format correctly writes LineString WKT");
|
||||
|
||||
// test a multilinestring
|
||||
t.eq(format.write(multilinestring),
|
||||
"MULTILINESTRING((" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + ")," +
|
||||
"(" + points[3].x + " " + points[3].y + "," +
|
||||
points[4].x + " " + points[4].y + "," +
|
||||
points[5].x + " " + points[5].y + "))",
|
||||
"MULTILINESTRING((" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + ")," +
|
||||
"(" + points[3].geometry.x + " " + points[3].geometry.y + "," +
|
||||
points[4].geometry.x + " " + points[4].geometry.y + "," +
|
||||
points[5].geometry.x + " " + points[5].geometry.y + "))",
|
||||
"format correctly writes MultiLineString WKT");
|
||||
|
||||
// test a polygon
|
||||
t.eq(format.write(polygons[0]),
|
||||
"POLYGON((" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + "," +
|
||||
points[0].x + " " + points[0].y + ")," +
|
||||
"(" + points[3].x + " " + points[3].y + "," +
|
||||
points[4].x + " " + points[4].y + "," +
|
||||
points[5].x + " " + points[5].y + "," +
|
||||
points[3].x + " " + points[3].y + "))",
|
||||
"POLYGON((" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + "," +
|
||||
points[0].geometry.x + " " + points[0].geometry.y + ")," +
|
||||
"(" + points[3].geometry.x + " " + points[3].geometry.y + "," +
|
||||
points[4].geometry.x + " " + points[4].geometry.y + "," +
|
||||
points[5].geometry.x + " " + points[5].geometry.y + "," +
|
||||
points[3].geometry.x + " " + points[3].geometry.y + "))",
|
||||
"format correctly writes Polygon WKT");
|
||||
|
||||
// test a multipolygon
|
||||
t.eq(format.write(multipolygon),
|
||||
"MULTIPOLYGON(((" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + "," +
|
||||
points[0].x + " " + points[0].y + ")," +
|
||||
"(" + points[3].x + " " + points[3].y + "," +
|
||||
points[4].x + " " + points[4].y + "," +
|
||||
points[5].x + " " + points[5].y + "," +
|
||||
points[3].x + " " + points[3].y + "))," +
|
||||
"((" + points[6].x + " " + points[6].y + "," +
|
||||
points[7].x + " " + points[7].y + "," +
|
||||
points[8].x + " " + points[8].y + "," +
|
||||
points[6].x + " " + points[6].y + ")," +
|
||||
"(" + points[9].x + " " + points[9].y + "," +
|
||||
points[10].x + " " + points[10].y + "," +
|
||||
points[11].x + " " + points[11].y + "," +
|
||||
points[9].x + " " + points[9].y + ")))",
|
||||
"MULTIPOLYGON(((" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + "," +
|
||||
points[0].geometry.x + " " + points[0].geometry.y + ")," +
|
||||
"(" + points[3].geometry.x + " " + points[3].geometry.y + "," +
|
||||
points[4].geometry.x + " " + points[4].geometry.y + "," +
|
||||
points[5].geometry.x + " " + points[5].geometry.y + "," +
|
||||
points[3].geometry.x + " " + points[3].geometry.y + "))," +
|
||||
"((" + points[6].geometry.x + " " + points[6].geometry.y + "," +
|
||||
points[7].geometry.x + " " + points[7].geometry.y + "," +
|
||||
points[8].geometry.x + " " + points[8].geometry.y + "," +
|
||||
points[6].geometry.x + " " + points[6].geometry.y + ")," +
|
||||
"(" + points[9].geometry.x + " " + points[9].geometry.y + "," +
|
||||
points[10].geometry.x + " " + points[10].geometry.y + "," +
|
||||
points[11].geometry.x + " " + points[11].geometry.y + "," +
|
||||
points[9].geometry.x + " " + points[9].geometry.y + ")))",
|
||||
"format correctly writes MultiPolygon WKT");
|
||||
|
||||
// test a geometrycollection
|
||||
t.eq(format.write(collection),
|
||||
"GEOMETRYCOLLECTION(POINT(" + points[0].x + " " + points[0].y + ")," +
|
||||
"LINESTRING(" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + "))",
|
||||
"GEOMETRYCOLLECTION(POINT(" + points[0].geometry.x + " " + points[0].geometry.y + ")," +
|
||||
"LINESTRING(" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + "))",
|
||||
"format correctly writes GeometryCollection WKT");
|
||||
|
||||
}
|
||||
@@ -134,35 +150,35 @@
|
||||
*/
|
||||
|
||||
// test a point
|
||||
t.ok(points[0].equals(format.read(format.write(points[0]))),
|
||||
t.ok(points[0].geometry.equals(format.read(format.write(points[0])).geometry),
|
||||
"format correctly reads Point WKT");
|
||||
|
||||
// test a multipoint
|
||||
t.ok(multipoint.equals(format.read(format.write(multipoint))),
|
||||
t.ok(multipoint.geometry.equals(format.read(format.write(multipoint)).geometry),
|
||||
"format correctly reads MultiPoint WKT");
|
||||
|
||||
// test a linestring
|
||||
t.ok(linestrings[0].equals(format.read(format.write(linestrings[0]))),
|
||||
t.ok(linestrings[0].geometry.equals(format.read(format.write(linestrings[0])).geometry),
|
||||
"format correctly reads LineString WKT");
|
||||
|
||||
// test a multilinestring
|
||||
t.ok(multilinestring.equals(format.read(format.write(multilinestring))),
|
||||
t.ok(multilinestring.geometry.equals(format.read(format.write(multilinestring)).geometry),
|
||||
"format correctly reads MultiLineString WKT");
|
||||
|
||||
// test a polygon
|
||||
t.ok(polygons[0].equals(format.read(format.write(polygons[0]))),
|
||||
t.ok(polygons[0].geometry.equals(format.read(format.write(polygons[0])).geometry),
|
||||
"format correctly reads Polygon WKT");
|
||||
|
||||
// test a multipolygon
|
||||
t.ok(multipolygon.equals(format.read(format.write(multipolygon))),
|
||||
t.ok(multipolygon.geometry.equals(format.read(format.write(multipolygon)).geometry),
|
||||
"format correctly reads MultiPolygon WKT");
|
||||
|
||||
// test a geometrycollection
|
||||
t.eq(format.write(collection),
|
||||
"GEOMETRYCOLLECTION(POINT(" + points[0].x + " " + points[0].y + ")," +
|
||||
"LINESTRING(" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + "))",
|
||||
"GEOMETRYCOLLECTION(POINT(" + points[0].geometry.x + " " + points[0].geometry.y + ")," +
|
||||
"LINESTRING(" + points[0].geometry.x + " " + points[0].geometry.y + "," +
|
||||
points[1].geometry.x + " " + points[1].geometry.y + "," +
|
||||
points[2].geometry.x + " " + points[2].geometry.y + "))",
|
||||
"format correctly writes GeometryCollection WKT");
|
||||
|
||||
}
|
||||
|
||||
@@ -187,7 +187,8 @@
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
map.addLayer(layer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 10);
|
||||
|
||||
|
||||
//grab a reference to one of the tiles
|
||||
var tile = layer.grid[1][1];
|
||||
|
||||
@@ -188,13 +188,14 @@
|
||||
map.setCenter(new OpenLayers.LonLat(0,0), 5);
|
||||
|
||||
var tile = layer.grid[0][0];
|
||||
|
||||
t.ok(tile.layer.imageSize.equals(tile.size),
|
||||
"zero size gutter doesn't change image size");
|
||||
|
||||
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(0, 0)),
|
||||
"zero size gutter doesn't affect image offset");
|
||||
|
||||
var zero_gutter_bounds = tile.bounds;
|
||||
|
||||
map.destroy();
|
||||
|
||||
var gutter = 15;
|
||||
@@ -209,8 +210,7 @@
|
||||
|
||||
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)),
|
||||
"gutter properly sets image offset");
|
||||
|
||||
t.ok(tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)),
|
||||
t.ok(tile.bounds.equals(zero_gutter_bounds),
|
||||
"gutter doesn't affect tile bounds");
|
||||
|
||||
map.destroy();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<li>Geometry/test_Rectangle.html</li>
|
||||
<li>Geometry/test_Surface.html</li>
|
||||
<li>test_Format.html</li>
|
||||
<li>Format/test_GeoRSS.html</li>
|
||||
<li>Format/test_GML.html</li>
|
||||
<li>Format/test_WKT.html</li>
|
||||
<li>test_Icon.html</li>
|
||||
@@ -38,7 +39,7 @@
|
||||
<li>Layer/test_Image.html</li>
|
||||
<li>Layer/test_KaMap.html</li>
|
||||
<li>Layer/test_Markers.html</li>
|
||||
<li>Layer/test_Multimap.html</li>
|
||||
<li>Layer/test_MultiMap.html</li>
|
||||
<li>Layer/test_MapServer.html</li>
|
||||
<li>Layer/test_MapServer_Untiled.html</li>
|
||||
<li>Layer/test_Text.html</li>
|
||||
@@ -58,6 +59,5 @@
|
||||
<li>Control/test_PanZoomBar.html</li>
|
||||
<li>Control/test_Permalink.html</li>
|
||||
<li>Control/test_Scale.html</li>
|
||||
<li>test_Format.html</li>
|
||||
<li>test_Map.html</li>
|
||||
</ul>
|
||||
|
||||
@@ -336,34 +336,48 @@
|
||||
function test_01_Map_defaultTheme(t) {
|
||||
t.plan(5);
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var nodeCount = head.childNodes.length;
|
||||
|
||||
var links = document.getElementsByTagName('link');
|
||||
map = new OpenLayers.Map('map');
|
||||
var lastNode = head.childNodes[head.childNodes.length - 1];
|
||||
var gotNodes = 0;
|
||||
var themeNode = null;
|
||||
for(var i=0; i<links.length; ++i) {
|
||||
if(OpenLayers.Util.isEquivalentUrl(map.theme, links.item(i).href)) {
|
||||
gotNodes += 1;
|
||||
themeNode = links.item(i);
|
||||
}
|
||||
}
|
||||
t.eq(gotNodes, 1, "by default, a single link node is added to document");
|
||||
t.ok(themeNode != null, "a link node with the theme href was added");
|
||||
t.eq(themeNode.rel, "stylesheet", "node added has rel set to stylesheet");
|
||||
t.eq(themeNode.type, "text/css", "node added has type set to text/css");
|
||||
|
||||
t.eq(nodeCount + 1, head.childNodes.length, "by default, a node is added to document head" );
|
||||
t.eq(lastNode.tagName, "LINK", "node added is a link element");
|
||||
t.eq(lastNode.rel, "stylesheet", "node added has rel set to stylesheet");
|
||||
t.eq(lastNode.type, "text/css", "node added has type set to text/css");
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(map.theme, lastNode.href), "node added has href equivalent to map.theme");
|
||||
// reconstruct the map to prove that another link is not added
|
||||
map = new OpenLayers.Map('map');
|
||||
t.eq(links.length, document.getElementsByTagName('link').length,
|
||||
"calling the map constructor twice with the same theme doesn't add duplicate link nodes");
|
||||
}
|
||||
function test_01_Map_customTheme(t) {
|
||||
t.plan(5);
|
||||
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var nodeCount = head.childNodes.length;
|
||||
|
||||
var options = {theme: 'foo'};
|
||||
var customTheme = 'foo';
|
||||
var options = {theme: customTheme};
|
||||
map = new OpenLayers.Map('map', options);
|
||||
|
||||
var lastNode = head.childNodes[head.childNodes.length - 1];
|
||||
var links = document.getElementsByTagName('link');
|
||||
var gotNodes = 0;
|
||||
var themeNode = null;
|
||||
for(var i=0; i<links.length; ++i) {
|
||||
if(OpenLayers.Util.isEquivalentUrl(map.theme, links.item(i).href)) {
|
||||
gotNodes += 1;
|
||||
themeNode = links.item(i);
|
||||
}
|
||||
}
|
||||
|
||||
t.eq(nodeCount + 1, head.childNodes.length, "with custom theme, a node is added to document head" );
|
||||
t.eq(lastNode.tagName, "LINK", "node added is a link element");
|
||||
t.eq(lastNode.rel, "stylesheet", "node added has rel set to stylesheet");
|
||||
t.eq(lastNode.type, "text/css", "node added has type set to text/css");
|
||||
t.ok(OpenLayers.Util.isEquivalentUrl(map.theme, lastNode.href), "node added has href equivalent to map.theme");
|
||||
t.eq(map.theme, customTheme, "map theme is properly set");
|
||||
t.eq(gotNodes, 1, "with custom theme, a single link node is added to document");
|
||||
t.ok(themeNode != null, "a link node with the theme href was added");
|
||||
t.eq(themeNode.rel, "stylesheet", "node added has rel set to stylesheet");
|
||||
t.eq(themeNode.type, "text/css", "node added has type set to text/css");
|
||||
}
|
||||
function test_01_Map_noTheme(t) {
|
||||
t.plan(1);
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly");
|
||||
t.eq(popup.div.style.height, h + "px", "heightposition of popup.div set correctly");
|
||||
|
||||
var contentDiv = popup.div.childNodes[0];
|
||||
var contentDiv = popup.div.childNodes[0].childNodes[0];
|
||||
|
||||
t.eq(contentDiv.className, "olPopupContent", "correct content div className");
|
||||
t.eq(contentDiv.id, "chicken_contentDiv", "correct content div id");
|
||||
|
||||
Reference in New Issue
Block a user