Compare commits

..

1 Commits

Author SHA1 Message Date
crschmidt
044368664f Tag OpenLayers 2.4-rc3.
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.4-rc3@3113 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2007-05-02 14:20:28 +00:00
28 changed files with 194 additions and 389 deletions

View File

@@ -1,7 +1,6 @@
OpenLayers contributors: OpenLayers contributors:
Howard Butler Howard Butler
Bertil Chaupis Bertil Chaupis
John Cole
Jeff Dege Jeff Dege
Schuyler Erle Schuyler Erle
Christian López Espínola Christian López Espínola

View File

@@ -2,7 +2,7 @@
<head> <head>
<style type="text/css"> <style type="text/css">
#map { #map {
width: 45%; width: 512px;
height: 350px; height: 350px;
border: 1px solid gray; border: 1px solid gray;
} }
@@ -42,8 +42,8 @@
</head> </head>
<body onload="init()"> <body onload="init()">
<h1>OpenLayers Draw Point Example</h1> <h1>OpenLayers Draw Point Example</h1>
<div style="float:right;width:50%"> <div style="float:right">
<textarea id="gml" style="width:100%" rows="30"></textarea> <textarea id="gml" cols="80" rows="30"></textarea>
</div> </div>
<div id="map"></div> <div id="map"></div>
</body> </body>

View File

@@ -47,7 +47,7 @@
popup = new OpenLayers.Popup.Anchored("chicken", popup = new OpenLayers.Popup.Anchored("chicken",
new OpenLayers.LonLat(5,40), new OpenLayers.LonLat(5,40),
new OpenLayers.Size(200,200), new OpenLayers.Size(200,200),
"example popup", true); "example popup");
map.addPopup(popup); map.addPopup(popup);
} }
@@ -69,17 +69,8 @@
} }
function mousedown(evt) { 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) { if (popup == null) {
popup = feature.createPopup(true); popup = feature.createPopup();
popup.setContentHTML("<a href='http://www.somethingconstructive.net' target='_blank'>click me</a>"); popup.setContentHTML("<a href='http://www.somethingconstructive.net' target='_blank'>click me</a>");
popup.setBackgroundColor("yellow"); popup.setBackgroundColor("yellow");
popup.setOpacity(0.7); popup.setOpacity(0.7);

View File

@@ -17,23 +17,11 @@
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer); 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"); var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry");
// create a point feature // create a point feature
var point = new OpenLayers.Geometry.Point(-111.04, 45.68); var point = new OpenLayers.Geometry.Point(-111.04, 45.68);
var pointFeature = new OpenLayers.Feature.Vector(point,null,style_blue); var pointFeature = new OpenLayers.Feature.Vector(point);
// create a line feature from a list of points // create a line feature from a list of points
var pointList = []; var pointList = [];
@@ -44,7 +32,7 @@
pointList.push(newPoint); pointList.push(newPoint);
} }
var lineFeature = new OpenLayers.Feature.Vector( var lineFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString(pointList),null,style_green); new OpenLayers.Geometry.LineString(pointList));
// create a polygon feature from a linear ring of points // create a polygon feature from a linear ring of points
var pointList = []; var pointList = [];
@@ -71,9 +59,5 @@
</head> </head>
<body onload="init()"> <body onload="init()">
<div id="map"></div> <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> </body>
</html> </html>

View File

@@ -78,7 +78,7 @@
} }
function displayWKT(feature) { function displayWKT(feature) {
var str = wkt.write(feature); var str = wkt.write(feature.geometry);
// not a good idea in general, just for this demo // not a good idea in general, just for this demo
str = str.replace(/,/g, ', '); str = str.replace(/,/g, ', ');
document.getElementById('info').innerHTML = str; document.getElementById('info').innerHTML = str;
@@ -86,18 +86,19 @@
function parseWKT() { function parseWKT() {
var element = document.getElementById('wkt'); var element = document.getElementById('wkt');
var features = wkt.read(element.value); var collection = wkt.read(element.value);
var bounds; var bounds;
if(features) { if(collection) {
if(features.constructor != Array) { if(collection.constructor != Array) {
features = [features]; collection = [collection];
} }
for(var i=0; i<features.length; ++i) { var features = [];
for(var i=0; i<collection.length; ++i) {
features.push(new OpenLayers.Feature.Vector(collection[i]));
if (!bounds) { if (!bounds) {
bounds = features[i].geometry.getBounds(); bounds = collection[i].getBounds();
} else {
bounds.extend(features[i].geometry.getBounds());
} }
bounds.extend(collection[i].getBounds());
} }
vectors.addFeatures(features); vectors.addFeatures(features);

View File

@@ -31,9 +31,8 @@ OpenLayers.Class = {
// so the util.extend() doesnt copy it over. we do it manually. // so the util.extend() doesnt copy it over. we do it manually.
// //
// to be revisited in 3.0 // to be revisited in 3.0
// //
if((arguments[i].hasOwnProperty && arguments[i].hasOwnProperty('toString')) || if (arguments[i].hasOwnProperty('toString')) {
(!arguments[i].hasOwnProperty && arguments[i].toString)) {
proto.toString = arguments[i].toString; proto.toString = arguments[i].toString;
} }
} }

View File

@@ -180,8 +180,7 @@ OpenLayers.Control.OverviewMap.prototype =
this.elementEvents.register('dblclick', this, function(e) { this.elementEvents.register('dblclick', this, function(e) {
OpenLayers.Event.stop(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('mouseout', this, this.rectMouseOut);
this.rectEvents.register('mousedown', this, this.rectMouseDown); this.rectEvents.register('mousedown', this, this.rectMouseDown);
this.rectEvents.register('mousemove', this, this.rectMouseMove); this.rectEvents.register('mousemove', this, this.rectMouseMove);

View File

@@ -121,7 +121,6 @@ OpenLayers.Feature.prototype= {
}, },
/** /**
* @param {Boolean} closeBox create popup with closebox or not
* @returns A Popup Object created from the 'lonlat', 'popupSize', * @returns A Popup Object created from the 'lonlat', 'popupSize',
* and 'popupContentHTML' properties set in this.data. It uses * and 'popupContentHTML' properties set in this.data. It uses
* this.marker.icon as default anchor. * this.marker.icon as default anchor.
@@ -133,7 +132,7 @@ OpenLayers.Feature.prototype= {
* *
* @type OpenLayers.Popup.AnchoredBubble * @type OpenLayers.Popup.AnchoredBubble
*/ */
createPopup: function(closeBox) { createPopup: function() {
if (this.lonlat != null) { if (this.lonlat != null) {
@@ -144,7 +143,7 @@ OpenLayers.Feature.prototype= {
this.lonlat, this.lonlat,
this.data.popupSize, this.data.popupSize,
this.data.popupContentHTML, this.data.popupContentHTML,
anchor, closeBox); anchor);
} }
return this.popup; return this.popup;
}, },

View File

@@ -97,10 +97,10 @@ OpenLayers.Format.GeoRSS.prototype =
var path = ""; var path = "";
if (points) { if (points) {
for (var i = 0; i < points.length; i++) { for (var i = 0; i < points.length; i++) {
path += points[i].y + " " + points[i].x + " "; path += points[i].lat + " " + points[i].lon + " ";
} }
} else { } else {
path += geometry.y + " " + geometry.x + " "; path += geometry.lat + " " + geometry.lon + " ";
} }
return document.createTextNode(path); return document.createTextNode(path);
}, },

View File

@@ -25,41 +25,38 @@ OpenLayers.Format.WKT.prototype =
}, },
/** /**
* Deserialize a WKT string and return an OpenLayers.Feature.Vector or an * Deserialize a WKT string and return an OpenLayers.Geometry or an array
* array of OpenLayers.Feature.Vector. Supports WKT for POINT, MULTIPOINT, * of OpenLayers.Geometry. Supports WKT for POINT, MULTIPOINT, LINESTRING,
* LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, and * MULTILINESTRING, POLYGON, MULTIPOLYGON, and GEOMETRYCOLLECTION.
* GEOMETRYCOLLECTION.
* @param {String} wkt A WKT string * @param {String} wkt A WKT string
* @returns {OpenLayers.Feature.Vector|Array} A feature or array of * @returns {OpenLayers.Geometry|Array} A geometry or array of geometries
* features for * for GEOMETRYCOLLECTION WKT.
* GEOMETRYCOLLECTION WKT.
*/ */
read: function(wkt) { read: function(wkt) {
var features, type, str; var geometry, type, str;
var matches = this.regExes.typeStr.exec(wkt); var matches = this.regExes.typeStr.exec(wkt);
if(matches) { if(matches) {
type = matches[1].toLowerCase(); type = matches[1].toLowerCase();
str = matches[2]; str = matches[2];
if(this.parse[type]) { if(this.parse[type]) {
features = this.parse[type].apply(this, [str]); geometry = this.parse[type].apply(this, [str]);
} }
} }
return features; return geometry;
}, },
/** /**
* Serialize a feature or array of features into a WKT string. * Serialize a geometry or array of geometries into a WKT string.
* @param {OpenLayers.Feature.Vector|Array} features A feature or array of * @param {OpenLayers.Geometry|Array} geom A geometry or array of geometries
* features
* @returns {String} The WKT string representation of the input geometries * @returns {String} The WKT string representation of the input geometries
*/ */
write: function(features) { write: function(geom) {
var collection, geometry, type, data, isCollection; var collection, geometry, type, data, isCollection;
if(features.constructor == Array) { if(geom.constructor == Array) {
collection = features; collection = geom;
isCollection = true; isCollection = true;
} else { } else {
collection = [features]; collection = [geom];
isCollection = false; isCollection = false;
} }
var pieces = []; var pieces = [];
@@ -70,7 +67,7 @@ OpenLayers.Format.WKT.prototype =
if(isCollection && i>0) { if(isCollection && i>0) {
pieces.push(','); pieces.push(',');
} }
geometry = collection[i].geometry; geometry = collection[i];
type = geometry.CLASS_NAME.split('.')[2].toLowerCase(); type = geometry.CLASS_NAME.split('.')[2].toLowerCase();
if(!this.extract[type]) { if(!this.extract[type]) {
return null; return null;
@@ -181,57 +178,47 @@ OpenLayers.Format.WKT.prototype =
*/ */
parse: { parse: {
/** /**
* Return point feature given a point WKT fragment. * Return point geometry given a point WKT fragment.
* @param {String} str A WKT fragment representing the point * @param {String} str A WKT fragment representing the point
* @returns {OpenLayers.Feature.Vector} A point feature * @returns {OpenLayers.Geometry.Point} A point geometry
* @private
*/ */
'point': function(str) { 'point': function(str) {
var coords = str.trim().split(this.regExes.spaces); var coords = str.trim().split(this.regExes.spaces);
return new OpenLayers.Feature.Vector( return new OpenLayers.Geometry.Point(coords[0], coords[1]);
new OpenLayers.Geometry.Point(coords[0], coords[1])
);
}, },
/** /**
* Return a multipoint feature given a multipoint WKT fragment. * Return a multipoint geometry given a multipoint WKT fragment.
* @param {String} A WKT fragment representing the multipoint * @param {String} A WKT fragment representing the multipoint
* @returns {OpenLayers.Feature.Vector} A multipoint feature * @returns {OpenLayers.Geometry.MultiPoint} A multipoint geometry
* @private
*/ */
'multipoint': function(str) { 'multipoint': function(str) {
var points = str.trim().split(','); var points = str.trim().split(',');
var components = []; var components = [];
for(var i=0; i<points.length; ++i) { for(var i=0; i<points.length; ++i) {
components.push(this.parse.point.apply(this, [points[i]]).geometry); components.push(this.parse.point.apply(this, [points[i]]));
} }
return new OpenLayers.Feature.Vector( return new OpenLayers.Geometry.MultiPoint(components);
new OpenLayers.Geometry.MultiPoint(components)
);
}, },
/** /**
* Return a linestring feature given a linestring WKT fragment. * Return a linestring geometry given a linestring WKT fragment.
* @param {String} A WKT fragment representing the linestring * @param {String} A WKT fragment representing the linestring
* @returns {OpenLayers.Feature.Vector} A linestring feature * @returns {OpenLayers.Geometry.LineString} A linestring geometry
* @private
*/ */
'linestring': function(str) { 'linestring': function(str) {
var points = str.trim().split(','); var points = str.trim().split(',');
var components = []; var components = [];
for(var i=0; i<points.length; ++i) { for(var i=0; i<points.length; ++i) {
components.push(this.parse.point.apply(this, [points[i]]).geometry); components.push(this.parse.point.apply(this, [points[i]]));
} }
return new OpenLayers.Feature.Vector( return new OpenLayers.Geometry.LineString(components);
new OpenLayers.Geometry.LineString(components)
);
}, },
/** /**
* Return a multilinestring feature given a multilinestring WKT fragment. * Return a multilinestring geometry given a multilinestring WKT fragment.
* @param {String} A WKT fragment representing the multilinestring * @param {String} A WKT fragment representing the multilinestring
* @returns {OpenLayers.Feature.Vector} A multilinestring feature * @returns {OpenLayers.Geometry.LineString} A multilinestring geometry
* @private
*/ */
'multilinestring': function(str) { 'multilinestring': function(str) {
var line; var line;
@@ -239,18 +226,15 @@ OpenLayers.Format.WKT.prototype =
var components = []; var components = [];
for(var i=0; i<lines.length; ++i) { for(var i=0; i<lines.length; ++i) {
line = lines[i].replace(this.regExes.trimParens, '$1'); line = lines[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.linestring.apply(this, [line]).geometry); components.push(this.parse.linestring.apply(this, [line]));
} }
return new OpenLayers.Feature.Vector( return new OpenLayers.Geometry.MultiLineString(components);
new OpenLayers.Geometry.MultiLineString(components)
);
}, },
/** /**
* Return a polygon feature given a polygon WKT fragment. * Return a polygon geometry given a polygon WKT fragment.
* @param {String} A WKT fragment representing the polygon * @param {String} A WKT fragment representing the polygon
* @returns {OpenLayers.Feature.Vector} A polygon feature * @returns {OpenLayers.Geometry.Polygon} A polygon geometry
* @private
*/ */
'polygon': function(str) { 'polygon': function(str) {
var ring, linestring, linearring; var ring, linestring, linearring;
@@ -258,20 +242,17 @@ OpenLayers.Format.WKT.prototype =
var components = []; var components = [];
for(var i=0; i<rings.length; ++i) { for(var i=0; i<rings.length; ++i) {
ring = rings[i].replace(this.regExes.trimParens, '$1'); ring = rings[i].replace(this.regExes.trimParens, '$1');
linestring = this.parse.linestring.apply(this, [ring]).geometry; linestring = this.parse.linestring.apply(this, [ring]);
linearring = new OpenLayers.Geometry.LinearRing(linestring.components) linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
components.push(linearring); components.push(linearring);
} }
return new OpenLayers.Feature.Vector( return new OpenLayers.Geometry.Polygon(components);
new OpenLayers.Geometry.Polygon(components)
);
}, },
/** /**
* Return a multipolygon feature given a multipolygon WKT fragment. * Return a multipolygon geometry given a multipolygon WKT fragment.
* @param {String} A WKT fragment representing the multipolygon * @param {String} A WKT fragment representing the multipolygon
* @returns {OpenLayers.Feature.Vector} A multipolygon feature * @returns {OpenLayers.Geometry.MultiPolygon} A multipolygon geometry
* @private
*/ */
'multipolygon': function(str) { 'multipolygon': function(str) {
var polygon; var polygon;
@@ -279,18 +260,15 @@ OpenLayers.Format.WKT.prototype =
var components = []; var components = [];
for(var i=0; i<polygons.length; ++i) { for(var i=0; i<polygons.length; ++i) {
polygon = polygons[i].replace(this.regExes.trimParens, '$1'); polygon = polygons[i].replace(this.regExes.trimParens, '$1');
components.push(this.parse.polygon.apply(this, [polygon]).geometry); components.push(this.parse.polygon.apply(this, [polygon]));
} }
return new OpenLayers.Feature.Vector( return new OpenLayers.Geometry.MultiPolygon(components);
new OpenLayers.Geometry.MultiPolygon(components)
);
}, },
/** /**
* Return an array of features given a geometrycollection WKT fragment. * Return an array of geometries given a geometrycollection WKT fragment.
* @param {String} A WKT fragment representing the geometrycollection * @param {String} A WKT fragment representing the geometrycollection
* @returns {Array} An array of OpenLayers.Feature.Vector * @returns {Array} An array of OpenLayers.Geometry
* @private
*/ */
'geometrycollection': function(str) { 'geometrycollection': function(str) {
// separate components of the collection with | // separate components of the collection with |

View File

@@ -5,7 +5,6 @@
/** /**
* @class * @class
* @requires OpenLayers/Format/WKT.js * @requires OpenLayers/Format/WKT.js
* @requires OpenLayers/Feature/Vector.js
*/ */
OpenLayers.Geometry = OpenLayers.Class.create(); OpenLayers.Geometry = OpenLayers.Class.create();
OpenLayers.Geometry.prototype = { OpenLayers.Geometry.prototype = {
@@ -151,9 +150,7 @@ OpenLayers.Geometry.prototype = {
* @type String * @type String
*/ */
toString: function() { toString: function() {
return OpenLayers.Format.WKT.prototype.write( return OpenLayers.Format.WKT.prototype.write(this);
new OpenLayers.Feature.Vector(this)
);
}, },
/** @final @type String */ /** @final @type String */

View File

@@ -608,15 +608,13 @@ OpenLayers.Layer.prototype = {
if (viewPortPx != null) { if (viewPortPx != null) {
var size = this.map.getSize(); var size = this.map.getSize();
var center = this.map.getCenter(); var center = this.map.getCenter();
if (center) { var res = this.map.getResolution();
var res = this.map.getResolution();
var delta_x = viewPortPx.x - (size.w / 2); var delta_x = viewPortPx.x - (size.w / 2);
var delta_y = viewPortPx.y - (size.h / 2); var delta_y = viewPortPx.y - (size.h / 2);
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res , lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res); center.lat - delta_y * res);
} // else { DEBUG STATEMENT }
} }
return lonlat; return lonlat;
}, },

View File

@@ -11,7 +11,6 @@
* @class * @class
* *
* @requires OpenLayers/Layer.js * @requires OpenLayers/Layer.js
* @requires OpenLayers/Tile/Image.js
*/ */
OpenLayers.Layer.Image = OpenLayers.Class.create(); OpenLayers.Layer.Image = OpenLayers.Class.create();
OpenLayers.Layer.Image.prototype = OpenLayers.Layer.Image.prototype =

View File

@@ -97,7 +97,8 @@ OpenLayers.Layer.Vector.prototype =
destroy: function() { destroy: function() {
OpenLayers.Layer.prototype.destroy.apply(this, arguments); OpenLayers.Layer.prototype.destroy.apply(this, arguments);
this.destroyFeatures(); // HACK HACK -- I believe we should be iterating and
// calling feature[i].destroy() here.
this.features = null; this.features = null;
this.selectedFeatures = null; this.selectedFeatures = null;
if (this.renderer) { if (this.renderer) {
@@ -246,10 +247,8 @@ OpenLayers.Layer.Vector.prototype =
var feature = features[i]; var feature = features[i];
this.features = OpenLayers.Util.removeItem(this.features, feature); this.features = OpenLayers.Util.removeItem(this.features, feature);
if (feature.geometry) { this.renderer.eraseGeometry(feature.geometry);
this.renderer.eraseGeometry(feature.geometry);
}
//in the case that this feature is one of the selected features, //in the case that this feature is one of the selected features,
// remove it from that array as well. // remove it from that array as well.
if (OpenLayers.Util.indexOf(this.selectedFeatures, feature) != -1){ if (OpenLayers.Util.indexOf(this.selectedFeatures, feature) != -1){

View File

@@ -92,9 +92,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]); obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here // copy/set any non-init, non-simple values here
obj.tile = null;
return obj; return obj;
}, },

View File

@@ -199,25 +199,11 @@ OpenLayers.Map.prototype = {
// only append link stylesheet if the theme property is set // only append link stylesheet if the theme property is set
if(this.theme) { if(this.theme) {
// check existing links for equivalent url var cssNode = document.createElement('link');
var addNode = true; cssNode.setAttribute('rel', 'stylesheet');
var nodes = document.getElementsByTagName('link'); cssNode.setAttribute('type', 'text/css');
for(var i=0; i<nodes.length; ++i) { cssNode.setAttribute('href', this.theme);
if(OpenLayers.Util.isEquivalentUrl(nodes.item(i).href, document.getElementsByTagName('head')[0].appendChild(cssNode);
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 = []; this.layers = [];

View File

@@ -45,9 +45,6 @@ OpenLayers.Popup.prototype = {
/** @type DOMElement */ /** @type DOMElement */
contentDiv:null, contentDiv:null,
/** @type DOMElement */
groupDiv:null,
/** @type int */ /** @type int */
padding: 5, padding: 5,
@@ -87,18 +84,13 @@ OpenLayers.Popup.prototype = {
this.div = OpenLayers.Util.createDiv(this.id, null, null, this.div = OpenLayers.Util.createDiv(this.id, null, null,
null, null, null, "hidden"); null, null, null, "hidden");
this.div.className = 'olPopup'; this.div.className = 'olPopup';
this.groupDiv = OpenLayers.Util.createDiv(null, null, null,
null, "relative", null,
"hidden");
var id = this.div.id + "_contentDiv"; var id = this.div.id + "_contentDiv";
this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(), this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(),
null, "relative", null, null, "relative", null,
"hidden"); "hidden");
this.contentDiv.className = 'olPopupContent'; this.contentDiv.className = 'olPopupContent';
this.groupDiv.appendChild(this.contentDiv); this.div.appendChild(this.contentDiv);
this.div.appendChild(this.groupDiv);
if (closeBox == true) { if (closeBox == true) {
// close icon // close icon
@@ -110,7 +102,7 @@ OpenLayers.Popup.prototype = {
img); img);
closeImg.style.right = this.padding + "px"; closeImg.style.right = this.padding + "px";
closeImg.style.top = this.padding + "px"; closeImg.style.top = this.padding + "px";
this.groupDiv.appendChild(closeImg); this.div.appendChild(closeImg);
var closePopup = function(e) { var closePopup = function(e) {
this.hide(); this.hide();

View File

@@ -139,7 +139,7 @@ OpenLayers.Popup.AnchoredBubble.prototype =
if (firstTime) { if (firstTime) {
OpenLayers.Rico.Corner.round(this.div, options); OpenLayers.Rico.Corner.round(this.div, options);
} else { } else {
OpenLayers.Rico.Corner.reRound(this.groupDiv, options); OpenLayers.Rico.Corner.reRound(this.contentDiv, options);
//set the popup color and opacity //set the popup color and opacity
this.setBackgroundColor(); this.setBackgroundColor();
this.setOpacity(); this.setOpacity();

View File

@@ -50,9 +50,7 @@ OpenLayers.Renderer.SVG.prototype =
*/ */
supported: function() { supported: function() {
var svgFeature = "http://www.w3.org/TR/SVG11/feature#SVG"; var svgFeature = "http://www.w3.org/TR/SVG11/feature#SVG";
var supported = (document.implementation && var supported = (document.implementation.hasFeature("org.w3c.svg", "1.0") || document.implementation.hasFeature(svgFeature, "1.1"));
(document.implementation.hasFeature("org.w3c.svg", "1.0") ||
document.implementation.hasFeature(svgFeature, "1.1")));
return supported; return supported;
}, },
@@ -284,7 +282,9 @@ OpenLayers.Renderer.SVG.prototype =
node.setAttributeNS(null, "cy", y); node.setAttributeNS(null, "cy", y);
node.setAttributeNS(null, "r", radius); node.setAttributeNS(null, "r", radius);
} else { } else {
this.root.removeChild(node); node.setAttributeNS(null, "cx", "");
node.setAttributeNS(null, "cy", "");
node.setAttributeNS(null, "r", 0);
} }
}, },
@@ -434,9 +434,8 @@ OpenLayers.Renderer.SVG.prototype =
var strings = []; var strings = [];
for(var i = 0; i < components.length; i++) { for(var i = 0; i < components.length; i++) {
var component = this.getShortString(components[i]); var component = this.getShortString(components[i]);
if (component) { if (!component) { return false; }
strings.push(component); strings.push(component);
}
} }
return strings.join(","); return strings.join(",");
}, },

View File

@@ -20,30 +20,17 @@ Installing OpenLayers
--------------------- ---------------------
You can use OpenLayers as-is by copying build/OpenLayers.js and the You can use OpenLayers as-is by copying build/OpenLayers.js and the
entire theme/ and img/ directories up to your webserver, putting them entire lib/ directory up to your webserver, putting them in the same
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: directory. To include the OpenLayers library in your web page, 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, If you want to use the multiple-file version of OpenLayers (for, say,
debugging or development purposes), copy the lib/ directory up to your debugging or development purposes), copy the lib/ directory up to your
webserver in the same directory you put the img/ folder. Then add webserver in the same directory you put the img/ folder. Then add
the following to your web page instead: 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 Using OpenLayers in Your Own Website

View File

@@ -1,35 +0,0 @@
This license applies to all code and content in the OpenLayers code
repository at svn.openlayers.org:
Copyright (c) 2005-2006 MetaCarta, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of MetaCarta, Inc. nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
This license grants no rights to any components related to natural language
processing, free text querying, or unstructured information retrieval. This
license grants no rights to components that implement inventions on which
MetaCarta has patents or has filed applications for patents.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,34 +0,0 @@
<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>

View File

@@ -5,53 +5,37 @@
var points = []; var points = [];
for(var i=0; i<12; ++i) { for(var i=0; i<12; ++i) {
points.push(new OpenLayers.Feature.Vector( points.push(new OpenLayers.Geometry.Point(Math.random() * 100,
new OpenLayers.Geometry.Point(Math.random() * 100, Math.random() * 100));
Math.random() * 100))
);
} }
var multipoint = new OpenLayers.Feature.Vector( var multipoint = new OpenLayers.Geometry.MultiPoint([
new OpenLayers.Geometry.MultiPoint([ points[0], points[1], points[2]
points[0].geometry, points[1].geometry, points[2].geometry ]);
])
);
var linestrings = [ var linestrings = [
new OpenLayers.Feature.Vector( new OpenLayers.Geometry.LineString([points[0], points[1], points[2]]),
new OpenLayers.Geometry.LineString([points[0].geometry, points[1].geometry, points[2].geometry]) new OpenLayers.Geometry.LineString([points[3], points[4], points[5]])
),
new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LineString([points[3].geometry, points[4].geometry, points[5].geometry])
)
]; ];
var multilinestring = new OpenLayers.Feature.Vector( var multilinestring = new OpenLayers.Geometry.MultiLineString([
new OpenLayers.Geometry.MultiLineString([ linestrings[0], linestrings[1]
linestrings[0].geometry, linestrings[1].geometry ]);
])
);
var rings = [ var rings = [
new OpenLayers.Geometry.LinearRing([points[0].geometry, points[1].geometry, points[2].geometry]), new OpenLayers.Geometry.LinearRing([points[0], points[1], points[2]]),
new OpenLayers.Geometry.LinearRing([points[3].geometry, points[4].geometry, points[5].geometry]), new OpenLayers.Geometry.LinearRing([points[3], points[4], points[5]]),
new OpenLayers.Geometry.LinearRing([points[6].geometry, points[7].geometry, points[8].geometry]), new OpenLayers.Geometry.LinearRing([points[6], points[7], points[8]]),
new OpenLayers.Geometry.LinearRing([points[9].geometry, points[10].geometry, points[11].geometry]) new OpenLayers.Geometry.LinearRing([points[9], points[10], points[11]])
]; ];
var polygons = [ var polygons = [
new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Polygon([rings[0], rings[1]]),
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[2], rings[3]])
)
]; ];
var multipolygon = new OpenLayers.Feature.Vector( var multipolygon = new OpenLayers.Geometry.MultiPolygon([
new OpenLayers.Geometry.MultiPolygon([ polygons[0], polygons[1]
polygons[0].geometry, polygons[1].geometry ]);
])
);
var collection = [points[0], linestrings[0]]; var collection = [points[0], linestrings[0]];
@@ -69,74 +53,74 @@
function test_Format_WKT_write(t) { function test_Format_WKT_write(t) {
t.plan(7); t.plan(7);
var format = new OpenLayers.Format.WKT(); var format = new OpenLayers.Format.WKT();
// test a point // test a point
t.eq(format.write(points[0]), t.eq(format.write(points[0]),
"POINT(" + points[0].geometry.x + " " + points[0].geometry.y + ")", "POINT(" + points[0].x + " " + points[0].y + ")",
"format correctly writes Point WKT"); "format correctly writes Point WKT");
// test a multipoint // test a multipoint
t.eq(format.write(multipoint), t.eq(format.write(multipoint),
"MULTIPOINT(" + points[0].geometry.x + " " + points[0].geometry.y + "," + "MULTIPOINT(" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + ")", points[2].x + " " + points[2].y + ")",
"format correctly writes MultiPoint WKT"); "format correctly writes MultiPoint WKT");
// test a linestring // test a linestring
t.eq(format.write(linestrings[0]), t.eq(format.write(linestrings[0]),
"LINESTRING(" + points[0].geometry.x + " " + points[0].geometry.y + "," + "LINESTRING(" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + ")", points[2].x + " " + points[2].y + ")",
"format correctly writes LineString WKT"); "format correctly writes LineString WKT");
// test a multilinestring // test a multilinestring
t.eq(format.write(multilinestring), t.eq(format.write(multilinestring),
"MULTILINESTRING((" + points[0].geometry.x + " " + points[0].geometry.y + "," + "MULTILINESTRING((" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + ")," + points[2].x + " " + points[2].y + ")," +
"(" + points[3].geometry.x + " " + points[3].geometry.y + "," + "(" + points[3].x + " " + points[3].y + "," +
points[4].geometry.x + " " + points[4].geometry.y + "," + points[4].x + " " + points[4].y + "," +
points[5].geometry.x + " " + points[5].geometry.y + "))", points[5].x + " " + points[5].y + "))",
"format correctly writes MultiLineString WKT"); "format correctly writes MultiLineString WKT");
// test a polygon // test a polygon
t.eq(format.write(polygons[0]), t.eq(format.write(polygons[0]),
"POLYGON((" + points[0].geometry.x + " " + points[0].geometry.y + "," + "POLYGON((" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + "," + points[2].x + " " + points[2].y + "," +
points[0].geometry.x + " " + points[0].geometry.y + ")," + points[0].x + " " + points[0].y + ")," +
"(" + points[3].geometry.x + " " + points[3].geometry.y + "," + "(" + points[3].x + " " + points[3].y + "," +
points[4].geometry.x + " " + points[4].geometry.y + "," + points[4].x + " " + points[4].y + "," +
points[5].geometry.x + " " + points[5].geometry.y + "," + points[5].x + " " + points[5].y + "," +
points[3].geometry.x + " " + points[3].geometry.y + "))", points[3].x + " " + points[3].y + "))",
"format correctly writes Polygon WKT"); "format correctly writes Polygon WKT");
// test a multipolygon // test a multipolygon
t.eq(format.write(multipolygon), t.eq(format.write(multipolygon),
"MULTIPOLYGON(((" + points[0].geometry.x + " " + points[0].geometry.y + "," + "MULTIPOLYGON(((" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + "," + points[2].x + " " + points[2].y + "," +
points[0].geometry.x + " " + points[0].geometry.y + ")," + points[0].x + " " + points[0].y + ")," +
"(" + points[3].geometry.x + " " + points[3].geometry.y + "," + "(" + points[3].x + " " + points[3].y + "," +
points[4].geometry.x + " " + points[4].geometry.y + "," + points[4].x + " " + points[4].y + "," +
points[5].geometry.x + " " + points[5].geometry.y + "," + points[5].x + " " + points[5].y + "," +
points[3].geometry.x + " " + points[3].geometry.y + "))," + points[3].x + " " + points[3].y + "))," +
"((" + points[6].geometry.x + " " + points[6].geometry.y + "," + "((" + points[6].x + " " + points[6].y + "," +
points[7].geometry.x + " " + points[7].geometry.y + "," + points[7].x + " " + points[7].y + "," +
points[8].geometry.x + " " + points[8].geometry.y + "," + points[8].x + " " + points[8].y + "," +
points[6].geometry.x + " " + points[6].geometry.y + ")," + points[6].x + " " + points[6].y + ")," +
"(" + points[9].geometry.x + " " + points[9].geometry.y + "," + "(" + points[9].x + " " + points[9].y + "," +
points[10].geometry.x + " " + points[10].geometry.y + "," + points[10].x + " " + points[10].y + "," +
points[11].geometry.x + " " + points[11].geometry.y + "," + points[11].x + " " + points[11].y + "," +
points[9].geometry.x + " " + points[9].geometry.y + ")))", points[9].x + " " + points[9].y + ")))",
"format correctly writes MultiPolygon WKT"); "format correctly writes MultiPolygon WKT");
// test a geometrycollection // test a geometrycollection
t.eq(format.write(collection), t.eq(format.write(collection),
"GEOMETRYCOLLECTION(POINT(" + points[0].geometry.x + " " + points[0].geometry.y + ")," + "GEOMETRYCOLLECTION(POINT(" + points[0].x + " " + points[0].y + ")," +
"LINESTRING(" + points[0].geometry.x + " " + points[0].geometry.y + "," + "LINESTRING(" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + "))", points[2].x + " " + points[2].y + "))",
"format correctly writes GeometryCollection WKT"); "format correctly writes GeometryCollection WKT");
} }
@@ -150,35 +134,35 @@
*/ */
// test a point // test a point
t.ok(points[0].geometry.equals(format.read(format.write(points[0])).geometry), t.ok(points[0].equals(format.read(format.write(points[0]))),
"format correctly reads Point WKT"); "format correctly reads Point WKT");
// test a multipoint // test a multipoint
t.ok(multipoint.geometry.equals(format.read(format.write(multipoint)).geometry), t.ok(multipoint.equals(format.read(format.write(multipoint))),
"format correctly reads MultiPoint WKT"); "format correctly reads MultiPoint WKT");
// test a linestring // test a linestring
t.ok(linestrings[0].geometry.equals(format.read(format.write(linestrings[0])).geometry), t.ok(linestrings[0].equals(format.read(format.write(linestrings[0]))),
"format correctly reads LineString WKT"); "format correctly reads LineString WKT");
// test a multilinestring // test a multilinestring
t.ok(multilinestring.geometry.equals(format.read(format.write(multilinestring)).geometry), t.ok(multilinestring.equals(format.read(format.write(multilinestring))),
"format correctly reads MultiLineString WKT"); "format correctly reads MultiLineString WKT");
// test a polygon // test a polygon
t.ok(polygons[0].geometry.equals(format.read(format.write(polygons[0])).geometry), t.ok(polygons[0].equals(format.read(format.write(polygons[0]))),
"format correctly reads Polygon WKT"); "format correctly reads Polygon WKT");
// test a multipolygon // test a multipolygon
t.ok(multipolygon.geometry.equals(format.read(format.write(multipolygon)).geometry), t.ok(multipolygon.equals(format.read(format.write(multipolygon))),
"format correctly reads MultiPolygon WKT"); "format correctly reads MultiPolygon WKT");
// test a geometrycollection // test a geometrycollection
t.eq(format.write(collection), t.eq(format.write(collection),
"GEOMETRYCOLLECTION(POINT(" + points[0].geometry.x + " " + points[0].geometry.y + ")," + "GEOMETRYCOLLECTION(POINT(" + points[0].x + " " + points[0].y + ")," +
"LINESTRING(" + points[0].geometry.x + " " + points[0].geometry.y + "," + "LINESTRING(" + points[0].x + " " + points[0].y + "," +
points[1].geometry.x + " " + points[1].geometry.y + "," + points[1].x + " " + points[1].y + "," +
points[2].geometry.x + " " + points[2].geometry.y + "))", points[2].x + " " + points[2].y + "))",
"format correctly writes GeometryCollection WKT"); "format correctly writes GeometryCollection WKT");
} }

View File

@@ -187,9 +187,8 @@
layer = new OpenLayers.Layer.WMS(name, url, params); layer = new OpenLayers.Layer.WMS(name, url, params);
map.addLayer(layer); map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 10); map.setCenter(new OpenLayers.LonLat(0,0), 5);
//grab a reference to one of the tiles //grab a reference to one of the tiles
var tile = layer.grid[1][1]; var tile = layer.grid[1][1];
t.eq( tile.imgDiv.className, "olTileImage", "Tile has an image" ); t.eq( tile.imgDiv.className, "olTileImage", "Tile has an image" );

View File

@@ -188,14 +188,13 @@
map.setCenter(new OpenLayers.LonLat(0,0), 5); map.setCenter(new OpenLayers.LonLat(0,0), 5);
var tile = layer.grid[0][0]; var tile = layer.grid[0][0];
t.ok(tile.layer.imageSize.equals(tile.size), t.ok(tile.layer.imageSize.equals(tile.size),
"zero size gutter doesn't change image size"); "zero size gutter doesn't change image size");
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(0, 0)), t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(0, 0)),
"zero size gutter doesn't affect image offset"); "zero size gutter doesn't affect image offset");
var zero_gutter_bounds = tile.bounds;
map.destroy(); map.destroy();
var gutter = 15; var gutter = 15;
@@ -210,7 +209,8 @@
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)), t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)),
"gutter properly sets image offset"); "gutter properly sets image offset");
t.ok(tile.bounds.equals(zero_gutter_bounds),
t.ok(tile.bounds.equals(new OpenLayers.Bounds(-33.75, 33.75, -22.5, 45)),
"gutter doesn't affect tile bounds"); "gutter doesn't affect tile bounds");
map.destroy(); map.destroy();

View File

@@ -17,7 +17,6 @@
<li>Geometry/test_Rectangle.html</li> <li>Geometry/test_Rectangle.html</li>
<li>Geometry/test_Surface.html</li> <li>Geometry/test_Surface.html</li>
<li>test_Format.html</li> <li>test_Format.html</li>
<li>Format/test_GeoRSS.html</li>
<li>Format/test_GML.html</li> <li>Format/test_GML.html</li>
<li>Format/test_WKT.html</li> <li>Format/test_WKT.html</li>
<li>test_Icon.html</li> <li>test_Icon.html</li>
@@ -39,7 +38,7 @@
<li>Layer/test_Image.html</li> <li>Layer/test_Image.html</li>
<li>Layer/test_KaMap.html</li> <li>Layer/test_KaMap.html</li>
<li>Layer/test_Markers.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.html</li>
<li>Layer/test_MapServer_Untiled.html</li> <li>Layer/test_MapServer_Untiled.html</li>
<li>Layer/test_Text.html</li> <li>Layer/test_Text.html</li>
@@ -59,5 +58,6 @@
<li>Control/test_PanZoomBar.html</li> <li>Control/test_PanZoomBar.html</li>
<li>Control/test_Permalink.html</li> <li>Control/test_Permalink.html</li>
<li>Control/test_Scale.html</li> <li>Control/test_Scale.html</li>
<li>test_Format.html</li>
<li>test_Map.html</li> <li>test_Map.html</li>
</ul> </ul>

View File

@@ -336,48 +336,34 @@
function test_01_Map_defaultTheme(t) { function test_01_Map_defaultTheme(t) {
t.plan(5); t.plan(5);
var links = document.getElementsByTagName('link'); var head = document.getElementsByTagName('head')[0];
map = new OpenLayers.Map('map'); var nodeCount = head.childNodes.length;
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");
// reconstruct the map to prove that another link is not added
map = new OpenLayers.Map('map'); map = new OpenLayers.Map('map');
t.eq(links.length, document.getElementsByTagName('link').length, var lastNode = head.childNodes[head.childNodes.length - 1];
"calling the map constructor twice with the same theme doesn't add duplicate link nodes");
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");
} }
function test_01_Map_customTheme(t) { function test_01_Map_customTheme(t) {
t.plan(5); t.plan(5);
var customTheme = 'foo'; var head = document.getElementsByTagName('head')[0];
var options = {theme: customTheme}; var nodeCount = head.childNodes.length;
var options = {theme: 'foo'};
map = new OpenLayers.Map('map', options); map = new OpenLayers.Map('map', options);
var links = document.getElementsByTagName('link'); var lastNode = head.childNodes[head.childNodes.length - 1];
var gotNodes = 0;
var themeNode = null; t.eq(nodeCount + 1, head.childNodes.length, "with custom theme, a node is added to document head" );
for(var i=0; i<links.length; ++i) { t.eq(lastNode.tagName, "LINK", "node added is a link element");
if(OpenLayers.Util.isEquivalentUrl(map.theme, links.item(i).href)) { t.eq(lastNode.rel, "stylesheet", "node added has rel set to stylesheet");
gotNodes += 1; t.eq(lastNode.type, "text/css", "node added has type set to text/css");
themeNode = links.item(i); 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) { function test_01_Map_noTheme(t) {
t.plan(1); t.plan(1);

View File

@@ -80,7 +80,7 @@
t.eq(popup.div.style.width, w + "px", "width position of popup.div set correctly"); 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"); t.eq(popup.div.style.height, h + "px", "heightposition of popup.div set correctly");
var contentDiv = popup.div.childNodes[0].childNodes[0]; var contentDiv = popup.div.childNodes[0];
t.eq(contentDiv.className, "olPopupContent", "correct content div className"); t.eq(contentDiv.className, "olPopupContent", "correct content div className");
t.eq(contentDiv.id, "chicken_contentDiv", "correct content div id"); t.eq(contentDiv.id, "chicken_contentDiv", "correct content div id");