Compare commits

...

4 Commits

Author SHA1 Message Date
crschmidt
c71898eb0b Tagging the 2.8 rc3 Release
git-svn-id: http://svn.openlayers.org/tags/openlayers/release-2.8-rc3@9407 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2009-05-22 14:17:39 +00:00
crschmidt
aeff2e62df Pullups for OL 2.8 RC3.
jQuery lib fix (Closes #1391)
  getRenderedSize regression (Closes #1906)
  element.scrolls error with panzoombar (Closes #2054)
  createUrlObject bug (Closes #2060)
  google layer in late rendered maps (Closes #2075)
  IE6/Lang.nb bug (Closes #2093)
  Layer.TMS/TileCache bugs (Closes #2099) (Closes #2100)
  Graphic names issues (Closes #2101)


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.8@9406 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2009-05-22 14:03:17 +00:00
crschmidt
6162cbafec Pullup:
* #1797
 * #1978
 * #2060
 * #2066


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.8@9348 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2009-05-02 21:54:03 +00:00
crschmidt
7884e9527f Branching for the 2.8 Release
git-svn-id: http://svn.openlayers.org/branches/openlayers/2.8@9310 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2009-04-20 15:27:13 +00:00
16 changed files with 194 additions and 83 deletions

View File

@@ -22,7 +22,7 @@
url: "http://publicus.opengeo.org/geoserver/wfs",
featureType: "tasmania_roads",
featureNS: "http://www.openplans.org/topp"
}),
})
});
map.addLayers([wms, layer]);

View File

@@ -435,6 +435,14 @@ OpenLayers.Events = OpenLayers.Class({
*/
includeXY: false,
/**
* Method: clearMouseListener
* A version of <clearMouseCache> that is bound to this instance so that
* it can be used with <OpenLayers.Event.observe> and
* <OpenLayers.Event.stopObserving>.
*/
clearMouseListener: null,
/**
* Constructor: OpenLayers.Events
* Construct an OpenLayers.Events object.
@@ -459,6 +467,11 @@ OpenLayers.Events = OpenLayers.Class({
this.handleBrowserEvent, this
);
// to be used with observe and stopObserving
this.clearMouseListener = OpenLayers.Function.bind(
this.clearMouseCache, this
);
// if eventTypes is specified, create a listeners list for each
// custom application event.
this.eventTypes = [];
@@ -481,6 +494,11 @@ OpenLayers.Events = OpenLayers.Class({
destroy: function () {
if (this.element) {
OpenLayers.Event.stopObservingElement(this.element);
if(this.element.hasScrollEvent) {
OpenLayers.Event.stopObserving(
window, "scroll", this.clearMouseListener
);
}
}
this.element = null;
@@ -773,8 +791,7 @@ OpenLayers.Events = OpenLayers.Class({
if (!this.includeXY) {
this.clearMouseCache();
} else if (!this.element.hasScrollEvent) {
OpenLayers.Event.observe(window, 'scroll',
OpenLayers.Function.bind(this.clearMouseCache, this));
OpenLayers.Event.observe(window, "scroll", this.clearMouseListener);
this.element.hasScrollEvent = true;
}

View File

@@ -93,8 +93,7 @@ OpenLayers.Lang["nb"] = {
"Denne innstillingen er foreldet, den var ment for <20> st<73>tte " +
"visning av kartdata over kommersielle bakgrunnskart, men det " +
"b<>r n<> gj<67>res med st<73>tten for Spherical Mercator. Mer informasjon " +
"finnes p<> " +
"http://trac.openlayers.org/wiki/SphericalMercator.",
"finnes p<> http://trac.openlayers.org/wiki/SphericalMercator.",
// console message
'methodDeprecated':

View File

@@ -212,22 +212,24 @@ OpenLayers.Layer.Google = OpenLayers.Class(
* evt - {Event}
*/
onMapResize: function() {
this.windowResized = true;
if(this.visibility) {
this.checkResize();
}
},
/**
* APIMethod: checkResize
* Check if the map has been resized, and if the Google Maps object is ready for checkResize.
* If the mapObject.getSize() equals the layer div's offset size, or if mapObject.getCenter()
* is null, the mapObject.checkResize() will fail.
*/
checkResize: function() {
if (this.windowResized && this.div.style.display != "none" && this.mapObject.getCenter()) {
// workaround for resizing of invisible or not yet fully loaded layers
// where GMap2.checkResize() does not work. We need to load all tiles
// for the old div size, then checkResize(), and then call
// layer.moveTo() to trigger GMap.setCenter() (which will finish
// the GMap initialization).
if(this.visibility && this.mapObject.isLoaded()) {
this.mapObject.checkResize();
this.windowResized = false;
} else {
if(!this._resized) {
var layer = this;
var handle = GEvent.addListener(this.mapObject, "tilesloaded", function() {
GEvent.removeListener(handle);
delete layer._resized;
layer.mapObject.checkResize();
layer.moveTo(layer.map.getCenter(), layer.map.getZoom());
})
}
this._resized = true;
}
},
@@ -240,7 +242,6 @@ OpenLayers.Layer.Google = OpenLayers.Class(
*/
display: function(display) {
OpenLayers.Layer.EventPane.prototype.display.apply(this, arguments);
this.checkResize();
this.termsOfUse.style.display = this.div.style.display;
this.poweredBy.style.display = this.div.style.display;
},
@@ -264,21 +265,6 @@ OpenLayers.Layer.Google = OpenLayers.Class(
OpenLayers.Layer.EventPane.prototype.removeMap.apply(this, arguments);
},
/**
* Method: moveTo
* Handle calls to move the layer.
*
* Parameters:
* bound - {<OpenLayers.Bounds>}
* zoomChanged - {Boolean} Tells when zoom has changed, as layers have to
* do some init work in that case.
* dragging - {Boolean}
*/
moveTo:function(bounds, zoomChanged, dragging) {
OpenLayers.Layer.EventPane.prototype.moveTo.apply(this, arguments);
this.checkResize();
},
/**
* APIMethod: getZoomForExtent
*

View File

@@ -105,7 +105,9 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
var res = this.map.getResolution();
var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
var z = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom();
var z = this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions, res) :
this.map.getZoom();
var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
var url = this.url;
if (url instanceof Array) {

View File

@@ -105,7 +105,9 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
var size = this.tileSize;
var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h));
var tileZ = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom();
var tileZ = this.serverResolutions != null ?
OpenLayers.Util.indexOf(this.serverResolutions, res) :
this.map.getZoom();
/**
* Zero-pad a positive integer.
* number - {Int}

View File

@@ -1661,13 +1661,16 @@ OpenLayers.Map = OpenLayers.Class({
var bounds = this.getExtent();
//send the move call to the baselayer and all the overlays
this.baseLayer.moveTo(bounds, zoomChanged, dragging);
if(dragging) {
this.baseLayer.events.triggerEvent("move");
} else {
this.baseLayer.events.triggerEvent("moveend",
{"zoomChanged": zoomChanged}
);
if(this.baseLayer.visibility) {
this.baseLayer.moveTo(bounds, zoomChanged, dragging);
if(dragging) {
this.baseLayer.events.triggerEvent("move");
} else {
this.baseLayer.events.triggerEvent("moveend",
{"zoomChanged": zoomChanged}
);
}
}
bounds = this.baseLayer.getExtent();

View File

@@ -506,7 +506,7 @@ OpenLayers.Popup = OpenLayers.Class({
// contents into a fake contentDiv (for the CSS) and then measuring it
var preparedHTML = "<div class='" + this.contentDisplayClass+ "'>" +
this.contentDiv.innerHTML +
"<div>";
"</div>";
var containerElement = (this.map) ? this.map.layerContainerDiv
: document.body;

View File

@@ -291,23 +291,28 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
var href = "#" + id;
pos = this.getPosition(node);
widthFactor = this.symbolSize[id] / size;
// Only set the href if it is different from the current one.
// This is a workaround for strange rendering behavior in FF3.
if (node.getAttributeNS(this.xlinkns, "href") != href) {
node.setAttributeNS(this.xlinkns, "href", href);
} else if (size != parseFloat(node.getAttributeNS(null, "width"))) {
// hide the element (and force a reflow so it really gets
// hidden. This workaround is needed for Safari.
node.style.visibility = "hidden";
this.container.scrollLeft = this.container.scrollLeft;
// remove the node from the dom before we modify it. This
// prevents various rendering issues in Safari and FF
var parent = node.parentNode;
var nextSibling = node.nextSibling;
if(parent) {
parent.removeChild(node);
}
node.setAttributeNS(this.xlinkns, "href", href);
node.setAttributeNS(null, "width", size);
node.setAttributeNS(null, "height", size);
node.setAttributeNS(null, "x", pos.x - offset);
node.setAttributeNS(null, "y", pos.y - offset);
// set the visibility back to normal (after the Safari
// workaround above)
node.style.visibility = "";
// now that the node has all its new properties, insert it
// back into the dom where it was
if(nextSibling) {
parent.insertBefore(node, nextSibling);
} else if(parent) {
parent.appendChild(node);
}
} else {
node.setAttributeNS(null, "r", style.pointRadius);
}

View File

@@ -122,7 +122,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
this.imgDiv.map = null;
}
this.imgDiv.urls = null;
this.imgDiv.src = null;
// abort any currently loading image
this.imgDiv.src = OpenLayers.Util.getImagesLocation() + "blank.gif";
}
this.imgDiv = null;
if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) {

View File

@@ -32,10 +32,10 @@ OpenLayers.Util.getElement = function() {
};
/**
* Maintain $() from prototype
* Maintain existing definition of $.
*/
if ($ == null) {
var $ = OpenLayers.Util.getElement;
if(typeof window.$ === "undefined") {
window.$ = OpenLayers.Util.getElement;
}
/**
@@ -1346,7 +1346,21 @@ OpenLayers.Util.isEquivalentUrl = function(url1, url2, options) {
OpenLayers.Util.createUrlObject = function(url, options) {
options = options || {};
var urlObject = {};
// deal with relative urls first
if(!(/^\w+:\/\//).test(url)) {
var loc = window.location;
var port = loc.port ? ":" + loc.port : "";
var fullUrl = loc.protocol + "//" + loc.host + port;
if(url.indexOf("/") === 0) {
// full pathname
url = fullUrl + url;
} else {
// relative to current path
var parts = loc.pathname.split("/");
parts.pop();
url = fullUrl + parts.join("/") + "/" + url;
}
}
if (options.ignoreCase) {
url = url.toLowerCase();
@@ -1355,10 +1369,15 @@ OpenLayers.Util.createUrlObject = function(url, options) {
var a = document.createElement('a');
a.href = url;
var urlObject = {};
//host (without port)
urlObject.host = a.host;
// if we don't have a host (which is the case with URLs starting with "/"
// in IE), take the window location's host to match other browsers that
// fill in the window's location host automatically
urlObject.host = a.host || window.location.host;
var port = a.port;
if (port.length <= 0) {
if (port.length > 0) {
var newHostLength = urlObject.host.length - (port.length);
urlObject.host = urlObject.host.substring(0, newHostLength);
}
@@ -1380,7 +1399,6 @@ OpenLayers.Util.createUrlObject = function(url, options) {
}
urlObject.args = OpenLayers.Util.getParameters(queryString);
//pathname (this part allows for relative <-> absolute comparison)
if ( ((urlObject.protocol == "file:") && (url.indexOf("file:") != -1)) ||
((urlObject.protocol != "file:") && (urlObject.host != "")) ) {
@@ -1538,9 +1556,7 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
// create temp container div with restricted size
var container = document.createElement("div");
container.style.overflow= "";
container.style.position = "absolute";
container.style.left = "-9999px";
container.style.visibility = "hidden";
var containerElement = (options && options.containerElement)
? options.containerElement : document.body;
@@ -1565,12 +1581,40 @@ OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) {
var content = document.createElement("div");
content.innerHTML = contentHTML;
// we need overflow visible when calculating the size
content.style.overflow = "visible";
if (content.childNodes) {
for (var i=0, l=content.childNodes.length; i<l; i++) {
if (!content.childNodes[i].style) continue;
content.childNodes[i].style.overflow = "visible";
}
}
// add content to restricted container
container.appendChild(content);
// append container to body for rendering
containerElement.appendChild(container);
// Opera and IE7 can't handle a node with position:aboslute if it inherits
// position:absolute from a parent.
var parentHasPositionAbsolute = false;
var parent = container.parentNode;
while (parent && parent.tagName.toLowerCase()!="body") {
var parentPosition = OpenLayers.Element.getStyle(parent, "position");
if(parentPosition == "absolute") {
parentHasPositionAbsolute = true;
break;
} else if (parentPosition && parentPosition != "static") {
break;
}
parent = parent.parentNode;
}
if(!parentHasPositionAbsolute) {
container.style.position = "absolute";
}
// calculate scroll width of content and add corners and shadow width
if (!w) {
w = parseInt(content.scrollWidth);

View File

@@ -51,7 +51,7 @@
var testBounds = new OpenLayers.Bounds(1,2,3,4);
t.ok( bounds.equals(testBounds), "getTMSBounds() returns correct bounds")
t.ok( bounds.equals(testBounds), "getTMSBounds() returns correct bounds");
layer.grid = null;
}
@@ -136,7 +136,7 @@
layer = new OpenLayers.Layer.TMS( "TMS",
"http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} );
m.addLayer(layer);
m.zoomToMaxExtent()
m.zoomToMaxExtent();
t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/1.png", "TMS tiles around rounded properly.");
m.destroy();
}
@@ -159,7 +159,9 @@
layer.serverResolutions = [14,13,12,11,10];
tileurl = layer.getURL(new OpenLayers.Bounds(0,0,0,0));
level = parseInt(tileurl.split('/')[2]);
t.eq(layer.serverResolutions.indexOf(map.getResolution()), level, "Tile zoom level is correct with serverResolutions");
var res = map.getResolution();
var gotLevel = OpenLayers.Util.indexOf(layer.serverResolutions, res);
t.eq(gotLevel, level, "Tile zoom level is correct with serverResolutions");
map.destroy();
}
@@ -208,6 +210,6 @@
</script>
</head>
<body>
<div id="map" style="width:500px;height:550px"></div>
<div id="map" style="width:500px;height:550px;"></div>
</body>
</html>

View File

@@ -159,7 +159,8 @@
layer.serverResolutions = [14,13,12,11,10];
tileurl = layer.getURL(new OpenLayers.Bounds(0,0,0,0));
level = parseInt(tileurl.split('/')[2]);
t.eq(layer.serverResolutions.indexOf(map.getResolution()), level, "Tile zoom level is correct with serverResolutions");
var gotLevel = OpenLayers.Util.indexOf(layer.serverResolutions, map.getResolution());
t.eq(gotLevel, level, "Tile zoom level is correct with serverResolutions");
map.destroy();
}

View File

@@ -1212,24 +1212,27 @@
function test_allOverlays(t) {
t.plan(14);
t.plan(16);
var map = new OpenLayers.Map({
div: "map", allOverlays: true
});
var a = new OpenLayers.Layer.Vector("a");
var a = new OpenLayers.Layer.Vector("a", {visibility: true});
var b = new OpenLayers.Layer.Image(
"b",
"http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif",
new OpenLayers.Bounds(-180, -88.759, 180, 88.759),
new OpenLayers.Size(580, 288)
);
var c = new OpenLayers.Layer.WMS(
"c",
"http://labs.metacarta.com/wms/vmap0",
{layers: 'basic'}
);
var d = new OpenLayers.Layer.Vector("d");
map.addLayers([a, b, c, d]);
@@ -1244,6 +1247,14 @@
t.eq(moveCount, 1, "map.moveTo moves the base layer only once");
t.eq(map.getCenter().toString(), "lon=0,lat=0", "a map with all overlays can have a center");
a.setVisibility(false);
var moveend = 0;
a.events.on({"moveend": function() { moveend++; }});
map.zoomToMaxExtent();
t.eq(moveCount, 1, "map.moveTo does not move the base layer if it is invisible");
t.eq(moveend, 0, "map.moveTo does not trigger \"moveend\" in the layer if the layer is invisible");
a.setVisibility(true);
// a, b, c, d
t.eq(map.baseLayer.name, "a", "base layer set to first layer added");
@@ -1282,6 +1293,7 @@
map.setLayerIndex(b, 0);
t.eq(b.visibility, false, "changing layer order doesn't change visibility");
map.destroy();
}

View File

@@ -1,10 +1,19 @@
<html>
<head>
<script>
var custom$ = function() {};
window.$ = custom$;
</script>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
var map;
function test_$(t) {
t.plan(1);
t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $.");
}
function test_Util_getImagesLocation (t) {
t.plan( 1 );
t.ok( OpenLayers.Util.getImagesLocation(), "../img/",
@@ -606,7 +615,7 @@
}
function test_Util_isEquivalentUrl(t) {
t.plan(8);
t.plan(9);
var url1, url2, options;
@@ -664,6 +673,11 @@
url2 = "../tests/../tests/foo.html?bar=now#go";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "relative vs. absolute paths works");
url1 = "/foo/bar";
url2 = new Array(window.location.pathname.split("/").length-1).join("../")+"foo/bar";
t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "absolute and relative path without host works for "+url2)
}
function test_Util_createUniqueIDSeq(t) {

View File

@@ -11,10 +11,33 @@ function run() {
var out = document.getElementById("out");
var size = OpenLayers.Util.getRenderedDimensions("<p>Content</p>");
var bigger = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", null, {displayClass: 'testDims'});
var overflow = OpenLayers.Util.getRenderedDimensions("<p style='overflow:auto'>Content</p>");
var width = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", new OpenLayers.Size(250, null));
var height = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", new OpenLayers.Size(null, 40));
if ((size.w + 40) == bigger.w && (size.h + 40) == bigger.h) {
out.innerHTML = "Pass: " + size + ", " + bigger;
out.innerHTML = "bigger Pass: " + size + ", " + bigger;
} else {
out.innerHTML = "Fail: " + size + ", " + bigger;
out.innerHTML = "bigger Fail: " + size + ", " + bigger;
}
if (size.w == overflow.w && size.h == overflow.h) {
out.innerHTML += "<br/>overflow Pass: " + size + ", " + overflow;
} else {
out.innerHTML += "<br/>overflow Fail: " + size + ", " + overflow;
}
if (width.w == 250 && width.h == size.h) {
out.innerHTML += "<br/>width Pass: " + size + ", " + width;
}
else {
out.innerHTML += "<br/>width Fail: " + size + ", " + width;
}
if (height.h == 40 && height.w == size.w) {
out.innerHTML += "<br/>height Pass: " + size + ", " + height;
}
else {
out.innerHTML += "<br/>height Fail: " + size + ", " + height;
}
}
</script>