Pullup changes since RC2. Fixes:

* WorldWind layer working again
 * Popup.destroy() complaints
 * Decompose marker destruction code for easier subclassing.
 * Error catching for better layerPx error in Map.js
 * Several eamples, including getFeatureInfo, fullScreen, worldwind,
   layer-opacity


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1501 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-09-26 20:24:00 +00:00
parent 5f8dc06823
commit c7c21ea08a
12 changed files with 400 additions and 45 deletions

View File

@@ -63,7 +63,7 @@ OpenLayers.Feature.prototype= {
this.lonlat = null;
this.data = null;
if (this.marker != null) {
this.marker.destroy();
this.destroyMarker(this.marker);
this.marker = null;
}
if (this.popup != null) {
@@ -89,6 +89,10 @@ OpenLayers.Feature.prototype= {
return this.marker;
},
destroyMarker: function() {
this.marker.destroy();
},
/**
*
*/

View File

@@ -409,15 +409,19 @@ OpenLayers.Layer.prototype = {
* @type OpenLayers.LonLat
*/
getLonLatFromViewPortPx: function (viewPortPx) {
var size = this.map.getSize();
var center = this.map.getCenter();
var res = this.map.getResolution();
var delta_x = viewPortPx.x - (size.w / 2);
var delta_y = viewPortPx.y - (size.h / 2);
var lonlat = null;
if (viewPortPx != null) {
var size = this.map.getSize();
var center = this.map.getCenter();
var res = this.map.getResolution();
return new OpenLayers.LonLat(center.lon + delta_x * res ,
center.lat - delta_y * res);
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);
}
return lonlat;
},
/**
@@ -428,12 +432,16 @@ OpenLayers.Layer.prototype = {
* @type OpenLayers.Pixel
*/
getViewPortPxFromLonLat: function (lonlat) {
var resolution = this.map.getResolution();
var extent = this.map.getExtent();
return new OpenLayers.Pixel(
Math.round(1/resolution * (lonlat.lon - extent.left)),
Math.round(1/resolution * (extent.top - lonlat.lat))
);
var px = null;
if (lonlat != null) {
var resolution = this.map.getResolution();
var extent = this.map.getExtent();
px = new OpenLayers.Pixel(
Math.round(1/resolution * (lonlat.lon - extent.left)),
Math.round(1/resolution * (extent.top - lonlat.lat))
);
}
return px;
},
/**

View File

@@ -46,19 +46,16 @@ OpenLayers.Layer.WorldWind.prototype =
return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize);
} else {
var tile = new Object();
tile.draw = function() {};
tile.destroy = function() {};
tile.bounds = bounds;
tile.bounds = position;
return tile;
return new OpenLayers.Tile.Image(this, position, bounds,
OpenLayers.Util.getImagesLocation() + "blank.gif",
this.tileSize);
}
},
getZoom: function () {
var zoom = this.map.getZoom();
var extent = this.map.getMaxExtent();
zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2);
zoom = zoom - Math.log(this.maxResolution / (this.lzd/512))/Math.log(2);
return zoom;
},
@@ -71,14 +68,21 @@ OpenLayers.Layer.WorldWind.prototype =
* @type String
*/
getURL: function (bounds) {
var zoom = this.getZoom();
var extent = this.map.getMaxExtent();
var deg = this.lzd/Math.pow(2,this.getZoom());
var x = Math.floor((bounds.left - extent.left)/deg);
var y = Math.floor((bounds.bottom - extent.bottom)/deg);
return this.getFullRequestString(
if (this.map.getResolution() <= (this.lzd/512)
&& this.getZoom() <= this.zoomLevels) {
return this.getFullRequestString(
{ L: zoom,
X: x,
Y: y
});
} else {
return OpenLayers.Util.getImagesLocation() + "blank.gif";
}
},

View File

@@ -438,7 +438,9 @@ OpenLayers.Map.prototype = {
removePopup: function(popup) {
this.popups.remove(popup);
if (popup.div) {
this.layerContainerDiv.removeChild(popup.div);
try { this.layerContainerDiv.removeChild(popup.div); }
catch (e) { } // Popups sometimes apparently get disconnected
// from the layerContainerDiv, and cause complaints.
}
popup.map = null;
},
@@ -475,17 +477,20 @@ OpenLayers.Map.prototype = {
for(var i=0; i < this.layers.length; i++) {
this.layers[i].onMapResize();
}
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
var zoom = this.getZoom();
this.zoom = null;
this.setCenter(center, zoom);
// store the new size
this.size = newSize;
// the div might have moved on the page, also
this.events.element.offsets = null;
if (this.baseLayer != null) {
var center = new OpenLayers.Pixel(newSize.w /2, newSize.h / 2);
var centerLL = this.getLonLatFromViewPortPx(center);
var zoom = this.getZoom();
this.zoom = null;
this.setCenter(this.getCenter(), zoom);
}
}
},
@@ -992,11 +997,11 @@ OpenLayers.Map.prototype = {
var dX = -parseInt(this.layerContainerDiv.style.left);
var dY = -parseInt(this.layerContainerDiv.style.top);
layerPx = viewPortPx.add(dX, dY);
if (isNaN(layerPx.x) || isNaN(layerPx.y)) {
layerPx = null;
}
}
if (!isNaN(layerPx.x) && !isNaN(layerPx.y)) {
return layerPx;
}
return null;
return layerPx;
},
//

View File

@@ -30,7 +30,16 @@ OpenLayers.Marker.prototype = {
initialize: function(lonlat, icon) {
if (arguments.length > 0) {
this.lonlat = lonlat;
this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
var newIcon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
if (this.icon == null) {
this.icon = newIcon;
} else {
this.icon.url = newIcon.url;
this.icon.size = newIcon.size;
this.icon.offset = newIcon.offset;
this.icon.calculateOffset = newIcon.calculateOffset;
}
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
}
},

View File

@@ -148,6 +148,7 @@ OpenLayers.Util.onImageLoadErrorColor = "pink";
OpenLayers.Util.onImageLoadError = function() {
this.style.backgroundColor = OpenLayers.Util.onImageLoadErrorColor;
this.style.display = "";
};