Compare commits
1 Commits
release-2.
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
044368664f |
@@ -1,7 +1,6 @@
|
||||
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: 45%;
|
||||
width: 512px;
|
||||
height: 350px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
@@ -42,8 +42,8 @@
|
||||
</head>
|
||||
<body onload="init()">
|
||||
<h1>OpenLayers Draw Point Example</h1>
|
||||
<div style="float:right;width:50%">
|
||||
<textarea id="gml" style="width:100%" rows="30"></textarea>
|
||||
<div style="float:right">
|
||||
<textarea id="gml" cols="80" 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", true);
|
||||
"example popup");
|
||||
|
||||
map.addPopup(popup);
|
||||
}
|
||||
@@ -69,17 +69,8 @@
|
||||
}
|
||||
|
||||
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(true);
|
||||
popup = feature.createPopup();
|
||||
popup.setContentHTML("<a href='http://www.somethingconstructive.net' target='_blank'>click me</a>");
|
||||
popup.setBackgroundColor("yellow");
|
||||
popup.setOpacity(0.7);
|
||||
|
||||
@@ -17,23 +17,11 @@
|
||||
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,null,style_blue);
|
||||
var pointFeature = new OpenLayers.Feature.Vector(point);
|
||||
|
||||
// create a line feature from a list of points
|
||||
var pointList = [];
|
||||
@@ -44,7 +32,7 @@
|
||||
pointList.push(newPoint);
|
||||
}
|
||||
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
|
||||
var pointList = [];
|
||||
@@ -71,9 +59,5 @@
|
||||
</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);
|
||||
var str = wkt.write(feature.geometry);
|
||||
// not a good idea in general, just for this demo
|
||||
str = str.replace(/,/g, ', ');
|
||||
document.getElementById('info').innerHTML = str;
|
||||
@@ -86,18 +86,19 @@
|
||||
|
||||
function parseWKT() {
|
||||
var element = document.getElementById('wkt');
|
||||
var features = wkt.read(element.value);
|
||||
var collection = wkt.read(element.value);
|
||||
var bounds;
|
||||
if(features) {
|
||||
if(features.constructor != Array) {
|
||||
features = [features];
|
||||
if(collection) {
|
||||
if(collection.constructor != Array) {
|
||||
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) {
|
||||
bounds = features[i].geometry.getBounds();
|
||||
} else {
|
||||
bounds.extend(features[i].geometry.getBounds());
|
||||
bounds = collection[i].getBounds();
|
||||
}
|
||||
bounds.extend(collection[i].getBounds());
|
||||
|
||||
}
|
||||
vectors.addFeatures(features);
|
||||
|
||||
@@ -31,9 +31,8 @@ OpenLayers.Class = {
|
||||
// so the util.extend() doesnt copy it over. we do it manually.
|
||||
//
|
||||
// to be revisited in 3.0
|
||||
//
|
||||
if((arguments[i].hasOwnProperty && arguments[i].hasOwnProperty('toString')) ||
|
||||
(!arguments[i].hasOwnProperty && arguments[i].toString)) {
|
||||
//
|
||||
if (arguments[i].hasOwnProperty('toString')) {
|
||||
proto.toString = arguments[i].toString;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,8 +180,7 @@ OpenLayers.Control.OverviewMap.prototype =
|
||||
this.elementEvents.register('dblclick', this, function(e) {
|
||||
OpenLayers.Event.stop(e);
|
||||
});
|
||||
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle,
|
||||
null, true);
|
||||
this.rectEvents = new OpenLayers.Events(this, this.extentRectangle);
|
||||
this.rectEvents.register('mouseout', this, this.rectMouseOut);
|
||||
this.rectEvents.register('mousedown', this, this.rectMouseDown);
|
||||
this.rectEvents.register('mousemove', this, this.rectMouseMove);
|
||||
|
||||
@@ -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',
|
||||
* and 'popupContentHTML' properties set in this.data. It uses
|
||||
* this.marker.icon as default anchor.
|
||||
@@ -133,7 +132,7 @@ OpenLayers.Feature.prototype= {
|
||||
*
|
||||
* @type OpenLayers.Popup.AnchoredBubble
|
||||
*/
|
||||
createPopup: function(closeBox) {
|
||||
createPopup: function() {
|
||||
|
||||
if (this.lonlat != null) {
|
||||
|
||||
@@ -144,7 +143,7 @@ OpenLayers.Feature.prototype= {
|
||||
this.lonlat,
|
||||
this.data.popupSize,
|
||||
this.data.popupContentHTML,
|
||||
anchor, closeBox);
|
||||
anchor);
|
||||
}
|
||||
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].y + " " + points[i].x + " ";
|
||||
path += points[i].lat + " " + points[i].lon + " ";
|
||||
}
|
||||
} else {
|
||||
path += geometry.y + " " + geometry.x + " ";
|
||||
path += geometry.lat + " " + geometry.lon + " ";
|
||||
}
|
||||
return document.createTextNode(path);
|
||||
},
|
||||
|
||||
@@ -25,41 +25,38 @@ OpenLayers.Format.WKT.prototype =
|
||||
},
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
* @param {String} wkt A WKT string
|
||||
* @returns {OpenLayers.Feature.Vector|Array} A feature or array of
|
||||
* features for
|
||||
* GEOMETRYCOLLECTION WKT.
|
||||
* @returns {OpenLayers.Geometry|Array} A geometry or array of geometries
|
||||
* for GEOMETRYCOLLECTION WKT.
|
||||
*/
|
||||
read: function(wkt) {
|
||||
var features, type, str;
|
||||
var geometry, type, str;
|
||||
var matches = this.regExes.typeStr.exec(wkt);
|
||||
if(matches) {
|
||||
type = matches[1].toLowerCase();
|
||||
str = matches[2];
|
||||
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.
|
||||
* @param {OpenLayers.Feature.Vector|Array} features A feature or array of
|
||||
* features
|
||||
* Serialize a geometry or array of geometries into a WKT string.
|
||||
* @param {OpenLayers.Geometry|Array} geom A geometry or array of geometries
|
||||
* @returns {String} The WKT string representation of the input geometries
|
||||
*/
|
||||
write: function(features) {
|
||||
write: function(geom) {
|
||||
var collection, geometry, type, data, isCollection;
|
||||
if(features.constructor == Array) {
|
||||
collection = features;
|
||||
if(geom.constructor == Array) {
|
||||
collection = geom;
|
||||
isCollection = true;
|
||||
} else {
|
||||
collection = [features];
|
||||
collection = [geom];
|
||||
isCollection = false;
|
||||
}
|
||||
var pieces = [];
|
||||
@@ -70,7 +67,7 @@ OpenLayers.Format.WKT.prototype =
|
||||
if(isCollection && i>0) {
|
||||
pieces.push(',');
|
||||
}
|
||||
geometry = collection[i].geometry;
|
||||
geometry = collection[i];
|
||||
type = geometry.CLASS_NAME.split('.')[2].toLowerCase();
|
||||
if(!this.extract[type]) {
|
||||
return null;
|
||||
@@ -181,57 +178,47 @@ OpenLayers.Format.WKT.prototype =
|
||||
*/
|
||||
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
|
||||
* @returns {OpenLayers.Feature.Vector} A point feature
|
||||
* @private
|
||||
* @returns {OpenLayers.Geometry.Point} A point geometry
|
||||
*/
|
||||
'point': function(str) {
|
||||
var coords = str.trim().split(this.regExes.spaces);
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(coords[0], coords[1])
|
||||
);
|
||||
return 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
|
||||
* @returns {OpenLayers.Feature.Vector} A multipoint feature
|
||||
* @private
|
||||
* @returns {OpenLayers.Geometry.MultiPoint} A multipoint geometry
|
||||
*/
|
||||
'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]]).geometry);
|
||||
components.push(this.parse.point.apply(this, [points[i]]));
|
||||
}
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPoint(components)
|
||||
);
|
||||
return 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
|
||||
* @returns {OpenLayers.Feature.Vector} A linestring feature
|
||||
* @private
|
||||
* @returns {OpenLayers.Geometry.LineString} A linestring geometry
|
||||
*/
|
||||
'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]]).geometry);
|
||||
components.push(this.parse.point.apply(this, [points[i]]));
|
||||
}
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.LineString(components)
|
||||
);
|
||||
return 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
|
||||
* @returns {OpenLayers.Feature.Vector} A multilinestring feature
|
||||
* @private
|
||||
* @returns {OpenLayers.Geometry.LineString} A multilinestring geometry
|
||||
*/
|
||||
'multilinestring': function(str) {
|
||||
var line;
|
||||
@@ -239,18 +226,15 @@ 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]).geometry);
|
||||
components.push(this.parse.linestring.apply(this, [line]));
|
||||
}
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiLineString(components)
|
||||
);
|
||||
return 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
|
||||
* @returns {OpenLayers.Feature.Vector} A polygon feature
|
||||
* @private
|
||||
* @returns {OpenLayers.Geometry.Polygon} A polygon geometry
|
||||
*/
|
||||
'polygon': function(str) {
|
||||
var ring, linestring, linearring;
|
||||
@@ -258,20 +242,17 @@ 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]).geometry;
|
||||
linearring = new OpenLayers.Geometry.LinearRing(linestring.components)
|
||||
linestring = this.parse.linestring.apply(this, [ring]);
|
||||
linearring = new OpenLayers.Geometry.LinearRing(linestring.components);
|
||||
components.push(linearring);
|
||||
}
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon(components)
|
||||
);
|
||||
return 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
|
||||
* @returns {OpenLayers.Feature.Vector} A multipolygon feature
|
||||
* @private
|
||||
* @returns {OpenLayers.Geometry.MultiPolygon} A multipolygon geometry
|
||||
*/
|
||||
'multipolygon': function(str) {
|
||||
var polygon;
|
||||
@@ -279,18 +260,15 @@ 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]).geometry);
|
||||
components.push(this.parse.polygon.apply(this, [polygon]));
|
||||
}
|
||||
return new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPolygon(components)
|
||||
);
|
||||
return 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
|
||||
* @returns {Array} An array of OpenLayers.Feature.Vector
|
||||
* @private
|
||||
* @returns {Array} An array of OpenLayers.Geometry
|
||||
*/
|
||||
'geometrycollection': function(str) {
|
||||
// separate components of the collection with |
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
/**
|
||||
* @class
|
||||
* @requires OpenLayers/Format/WKT.js
|
||||
* @requires OpenLayers/Feature/Vector.js
|
||||
*/
|
||||
OpenLayers.Geometry = OpenLayers.Class.create();
|
||||
OpenLayers.Geometry.prototype = {
|
||||
@@ -151,9 +150,7 @@ OpenLayers.Geometry.prototype = {
|
||||
* @type String
|
||||
*/
|
||||
toString: function() {
|
||||
return OpenLayers.Format.WKT.prototype.write(
|
||||
new OpenLayers.Feature.Vector(this)
|
||||
);
|
||||
return OpenLayers.Format.WKT.prototype.write(this);
|
||||
},
|
||||
|
||||
/** @final @type String */
|
||||
|
||||
@@ -608,15 +608,13 @@ OpenLayers.Layer.prototype = {
|
||||
if (viewPortPx != null) {
|
||||
var size = this.map.getSize();
|
||||
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_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);
|
||||
} // else { DEBUG STATEMENT }
|
||||
lonlat = new OpenLayers.LonLat(center.lon + delta_x * res ,
|
||||
center.lat - delta_y * res);
|
||||
}
|
||||
return lonlat;
|
||||
},
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
* @class
|
||||
*
|
||||
* @requires OpenLayers/Layer.js
|
||||
* @requires OpenLayers/Tile/Image.js
|
||||
*/
|
||||
OpenLayers.Layer.Image = OpenLayers.Class.create();
|
||||
OpenLayers.Layer.Image.prototype =
|
||||
|
||||
@@ -97,7 +97,8 @@ OpenLayers.Layer.Vector.prototype =
|
||||
destroy: function() {
|
||||
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.selectedFeatures = null;
|
||||
if (this.renderer) {
|
||||
@@ -246,10 +247,8 @@ OpenLayers.Layer.Vector.prototype =
|
||||
var feature = features[i];
|
||||
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,
|
||||
// remove it from that array as well.
|
||||
if (OpenLayers.Util.indexOf(this.selectedFeatures, feature) != -1){
|
||||
|
||||
@@ -92,9 +92,7 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
||||
obj = OpenLayers.Layer.HTTPRequest.prototype.clone.apply(this, [obj]);
|
||||
|
||||
// copy/set any non-init, non-simple values here
|
||||
|
||||
obj.tile = null;
|
||||
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
|
||||
@@ -199,25 +199,11 @@ OpenLayers.Map.prototype = {
|
||||
|
||||
// only append link stylesheet if the theme property is set
|
||||
if(this.theme) {
|
||||
// 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);
|
||||
}
|
||||
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 = [];
|
||||
|
||||
@@ -45,9 +45,6 @@ OpenLayers.Popup.prototype = {
|
||||
|
||||
/** @type DOMElement */
|
||||
contentDiv:null,
|
||||
|
||||
/** @type DOMElement */
|
||||
groupDiv:null,
|
||||
|
||||
/** @type int */
|
||||
padding: 5,
|
||||
@@ -87,18 +84,13 @@ OpenLayers.Popup.prototype = {
|
||||
this.div = OpenLayers.Util.createDiv(this.id, null, null,
|
||||
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.groupDiv.appendChild(this.contentDiv);
|
||||
this.div.appendChild(this.groupDiv);
|
||||
this.div.appendChild(this.contentDiv);
|
||||
|
||||
if (closeBox == true) {
|
||||
// close icon
|
||||
@@ -110,7 +102,7 @@ OpenLayers.Popup.prototype = {
|
||||
img);
|
||||
closeImg.style.right = this.padding + "px";
|
||||
closeImg.style.top = this.padding + "px";
|
||||
this.groupDiv.appendChild(closeImg);
|
||||
this.div.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.groupDiv, options);
|
||||
OpenLayers.Rico.Corner.reRound(this.contentDiv, options);
|
||||
//set the popup color and opacity
|
||||
this.setBackgroundColor();
|
||||
this.setOpacity();
|
||||
|
||||
@@ -50,9 +50,7 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
*/
|
||||
supported: function() {
|
||||
var svgFeature = "http://www.w3.org/TR/SVG11/feature#SVG";
|
||||
var supported = (document.implementation &&
|
||||
(document.implementation.hasFeature("org.w3c.svg", "1.0") ||
|
||||
document.implementation.hasFeature(svgFeature, "1.1")));
|
||||
var supported = (document.implementation.hasFeature("org.w3c.svg", "1.0") || document.implementation.hasFeature(svgFeature, "1.1"));
|
||||
return supported;
|
||||
},
|
||||
|
||||
@@ -284,7 +282,9 @@ OpenLayers.Renderer.SVG.prototype =
|
||||
node.setAttributeNS(null, "cy", y);
|
||||
node.setAttributeNS(null, "r", radius);
|
||||
} 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 = [];
|
||||
for(var i = 0; i < components.length; i++) {
|
||||
var component = this.getShortString(components[i]);
|
||||
if (component) {
|
||||
strings.push(component);
|
||||
}
|
||||
if (!component) { return false; }
|
||||
strings.push(component);
|
||||
}
|
||||
return strings.join(",");
|
||||
},
|
||||
|
||||
21
readme.txt
21
readme.txt
@@ -20,30 +20,17 @@ Installing OpenLayers
|
||||
---------------------
|
||||
|
||||
You can use OpenLayers as-is by copying build/OpenLayers.js and the
|
||||
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:
|
||||
entire lib/ directory up to your webserver, putting them in the same
|
||||
directory. To include the OpenLayers library in your web page, use:
|
||||
|
||||
<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 ./
|
||||
<script type="text/javascript" src="OpenLayers.js" />
|
||||
|
||||
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" />
|
||||
|
||||
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 ./
|
||||
|
||||
<script type="text/javascript" src="lib/OpenLayers.js" />
|
||||
|
||||
------------------------------------
|
||||
Using OpenLayers in Your Own Website
|
||||
|
||||
@@ -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>
|
||||
@@ -5,53 +5,37 @@
|
||||
|
||||
var points = [];
|
||||
for(var i=0; i<12; ++i) {
|
||||
points.push(new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Point(Math.random() * 100,
|
||||
Math.random() * 100))
|
||||
);
|
||||
points.push(new OpenLayers.Geometry.Point(Math.random() * 100,
|
||||
Math.random() * 100));
|
||||
}
|
||||
var multipoint = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPoint([
|
||||
points[0].geometry, points[1].geometry, points[2].geometry
|
||||
])
|
||||
);
|
||||
var multipoint = new OpenLayers.Geometry.MultiPoint([
|
||||
points[0], points[1], points[2]
|
||||
]);
|
||||
|
||||
var linestrings = [
|
||||
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])
|
||||
)
|
||||
new OpenLayers.Geometry.LineString([points[0], points[1], points[2]]),
|
||||
new OpenLayers.Geometry.LineString([points[3], points[4], points[5]])
|
||||
];
|
||||
|
||||
var multilinestring = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiLineString([
|
||||
linestrings[0].geometry, linestrings[1].geometry
|
||||
])
|
||||
);
|
||||
var multilinestring = new OpenLayers.Geometry.MultiLineString([
|
||||
linestrings[0], linestrings[1]
|
||||
]);
|
||||
|
||||
var rings = [
|
||||
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])
|
||||
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]])
|
||||
];
|
||||
|
||||
var polygons = [
|
||||
new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon([rings[0], rings[1]])
|
||||
),
|
||||
new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.Polygon([rings[2], rings[3]])
|
||||
)
|
||||
new OpenLayers.Geometry.Polygon([rings[0], rings[1]]),
|
||||
new OpenLayers.Geometry.Polygon([rings[2], rings[3]])
|
||||
];
|
||||
|
||||
var multipolygon = new OpenLayers.Feature.Vector(
|
||||
new OpenLayers.Geometry.MultiPolygon([
|
||||
polygons[0].geometry, polygons[1].geometry
|
||||
])
|
||||
);
|
||||
var multipolygon = new OpenLayers.Geometry.MultiPolygon([
|
||||
polygons[0], polygons[1]
|
||||
]);
|
||||
|
||||
var collection = [points[0], linestrings[0]];
|
||||
|
||||
@@ -69,74 +53,74 @@
|
||||
function test_Format_WKT_write(t) {
|
||||
t.plan(7);
|
||||
var format = new OpenLayers.Format.WKT();
|
||||
|
||||
|
||||
// test a point
|
||||
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");
|
||||
|
||||
// test a multipoint
|
||||
t.eq(format.write(multipoint),
|
||||
"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 + ")",
|
||||
"MULTIPOINT(" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + ")",
|
||||
"format correctly writes MultiPoint WKT");
|
||||
|
||||
// test a linestring
|
||||
t.eq(format.write(linestrings[0]),
|
||||
"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 + ")",
|
||||
"LINESTRING(" + points[0].x + " " + points[0].y + "," +
|
||||
points[1].x + " " + points[1].y + "," +
|
||||
points[2].x + " " + points[2].y + ")",
|
||||
"format correctly writes LineString WKT");
|
||||
|
||||
// test a multilinestring
|
||||
t.eq(format.write(multilinestring),
|
||||
"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 + "))",
|
||||
"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 + "))",
|
||||
"format correctly writes MultiLineString WKT");
|
||||
|
||||
// test a polygon
|
||||
t.eq(format.write(polygons[0]),
|
||||
"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 + "))",
|
||||
"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 + "))",
|
||||
"format correctly writes Polygon WKT");
|
||||
|
||||
// test a multipolygon
|
||||
t.eq(format.write(multipolygon),
|
||||
"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 + ")))",
|
||||
"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 + ")))",
|
||||
"format correctly writes MultiPolygon WKT");
|
||||
|
||||
// test a geometrycollection
|
||||
t.eq(format.write(collection),
|
||||
"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 + "))",
|
||||
"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 + "))",
|
||||
"format correctly writes GeometryCollection WKT");
|
||||
|
||||
}
|
||||
@@ -150,35 +134,35 @@
|
||||
*/
|
||||
|
||||
// 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");
|
||||
|
||||
|
||||
// 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");
|
||||
|
||||
// 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");
|
||||
|
||||
// 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");
|
||||
|
||||
// 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");
|
||||
|
||||
// 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");
|
||||
|
||||
// test a geometrycollection
|
||||
t.eq(format.write(collection),
|
||||
"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 + "))",
|
||||
"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 + "))",
|
||||
"format correctly writes GeometryCollection WKT");
|
||||
|
||||
}
|
||||
|
||||
@@ -187,9 +187,8 @@
|
||||
layer = new OpenLayers.Layer.WMS(name, url, params);
|
||||
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
|
||||
var tile = layer.grid[1][1];
|
||||
t.eq( tile.imgDiv.className, "olTileImage", "Tile has an image" );
|
||||
|
||||
@@ -188,14 +188,13 @@
|
||||
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;
|
||||
@@ -210,7 +209,8 @@
|
||||
|
||||
t.ok(tile.layer.imageOffset.equals(new OpenLayers.Pixel(-gutter, -gutter)),
|
||||
"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");
|
||||
|
||||
map.destroy();
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<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>
|
||||
@@ -39,7 +38,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>
|
||||
@@ -59,5 +58,6 @@
|
||||
<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,48 +336,34 @@
|
||||
function test_01_Map_defaultTheme(t) {
|
||||
t.plan(5);
|
||||
|
||||
var links = document.getElementsByTagName('link');
|
||||
map = new OpenLayers.Map('map');
|
||||
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");
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var nodeCount = head.childNodes.length;
|
||||
|
||||
// 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");
|
||||
var lastNode = head.childNodes[head.childNodes.length - 1];
|
||||
|
||||
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) {
|
||||
t.plan(5);
|
||||
|
||||
var customTheme = 'foo';
|
||||
var options = {theme: customTheme};
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var nodeCount = head.childNodes.length;
|
||||
|
||||
var options = {theme: 'foo'};
|
||||
map = new OpenLayers.Map('map', options);
|
||||
|
||||
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(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");
|
||||
var lastNode = head.childNodes[head.childNodes.length - 1];
|
||||
|
||||
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");
|
||||
}
|
||||
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].childNodes[0];
|
||||
var contentDiv = popup.div.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