Merge bugfixes and test improvements for rc4 release.

git-svn-id: http://svn.openlayers.org/branches/openlayers/2.1@1513 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-09-28 13:05:36 +00:00
parent c7c21ea08a
commit 6edb290f1b
10 changed files with 163 additions and 12 deletions

View File

@@ -424,6 +424,30 @@ OpenLayers.Bounds.prototype = {
this.right + x, this.top + y);
},
/**
* @param {OpenLayers.LonLat} ll
* @param {Boolean} inclusive Whether or not to include the border.
* Default is true
*
* @return Whether or not the passed-in lonlat is within this bounds
* @type Boolean
*/
containsLonLat:function(ll, inclusive) {
return this.contains(ll.lon, ll.lat, inclusive);
},
/**
* @param {OpenLayers.Pixel} px
* @param {Boolean} inclusive Whether or not to include the border.
* Default is true
*
* @return Whether or not the passed-in pixel is within this bounds
* @type Boolean
*/
containsPixel:function(px, inclusive) {
return this.contains(px.x, px.y, inclusive);
},
/**
* @param {float} x
* @param {float} y

View File

@@ -67,16 +67,34 @@ OpenLayers.Feature.prototype= {
this.marker = null;
}
if (this.popup != null) {
this.popup.destroy();
this.destroyPopup(this.popup);
this.popup = null;
}
},
/**
* @returns Whether or not the feature is currently visible on screen
* (based on its 'lonlat' property)
* @type Boolean
*/
onScreen:function() {
var onScreen = false;
if ((this.layer != null) && (this.layer.map != null)) {
var screenBounds = this.layer.map.getExtent();
onScreen = screenBounds.containsLonLat(this.lonlat);
}
return onScreen;
},
/**
* @returns A Marker Object created from the 'lonlat' and 'icon' properties
* set in this.data. If no 'lonlat' is set, returns null. If no
* 'icon' is set, OpenLayers.Marker() will load the default image
* 'icon' is set, OpenLayers.Marker() will load the default image.
*
* Note: this.marker is set to return value
*
* @type OpenLayers.Marker
*/
createMarker: function() {
@@ -89,12 +107,24 @@ OpenLayers.Feature.prototype= {
return this.marker;
},
/** If user overrides the createMarker() function, s/he should be able
* to also specify an alternative function for destroying it
*/
destroyMarker: function() {
this.marker.destroy();
},
/**
* @returns A Popup Object created from the 'lonlat', 'popupSize',
* and 'popupContentHTML' properties set in this.data. It uses
* this.marker.icon as default anchor.
*
* If no 'lonlat' is set, returns null.
* If no this.marker has been created, no anchor is sent.
*
* Note: this.popup is set to return value
*
* @type OpenLayers.Popup.AnchoredBubble
*/
createPopup: function() {
@@ -112,5 +142,13 @@ OpenLayers.Feature.prototype= {
return this.popup;
},
/** As with the marker, if user overrides the createPopup() function, s/he
* should also be able to override the destruction
*/
destroyPopup: function() {
this.popup.destroy()
},
CLASS_NAME: "OpenLayers.Feature"
};

View File

@@ -393,7 +393,7 @@ OpenLayers.Layer.prototype = {
*/
getZoomForResolution: function(resolution) {
for(var i=1; i <= this.resolutions.length; i++) {
for(var i=1; i < this.resolutions.length; i++) {
if ( this.resolutions[i] < resolution) {
break;
}

View File

@@ -354,8 +354,7 @@ OpenLayers.Map.prototype = {
if (newBaseLayer != this.baseLayer) {
// is newBaseLayer an already loaded layer?
var foundLayer = (this.layers.indexOf(newBaseLayer) != -1);
if (foundLayer) {
if (this.layers.indexOf(newBaseLayer) != -1) {
// make the old base layer invisible
if (this.baseLayer != null) {
@@ -455,10 +454,20 @@ OpenLayers.Map.prototype = {
/********************************************************/
/**
* @returns {OpenLayers.Size}
* @returns An OpenLayers.Size object that represents the size, in pixels,
* of the div into which OpenLayers has been loaded.
*
* Note: A clone() of this locally cached variable is returned, so
* as not to allow users to modify it.
*
* @type OpenLayers.Size
*/
getSize: function () {
return this.size;
var size = null;
if (this.size != null) {
size = this.size.clone();
}
return size;
},
/**
@@ -669,7 +678,7 @@ OpenLayers.Map.prototype = {
var valid = false;
if (lonlat != null) {
var maxExtent = this.getMaxExtent();
valid = maxExtent.contains(lonlat.lon, lonlat.lat);
valid = maxExtent.containsLonLat(lonlat);
}
return valid;
},

View File

@@ -82,7 +82,7 @@ OpenLayers.Marker.prototype = {
var onScreen = false;
if (this.map) {
var screenBounds = this.map.getExtent();
onScreen = screenBounds.contains(this.lonlat.lon, this.lonlat.lat);
onScreen = screenBounds.containsLonLat(this.lonlat);
}
return onScreen;
},