Pullup r2999:3087 for RC2.

svn merge trunk/openlayers/@2999 trunk/openlayers/@HEAD branches/openlayers/2.4/



git-svn-id: http://svn.openlayers.org/branches/openlayers/2.4@3088 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-04-20 01:10:43 +00:00
parent b6fb16153c
commit b5103eb8ce
58 changed files with 1399 additions and 503 deletions
+4 -1
View File
@@ -15,8 +15,11 @@ OpenLayers.Layer.Boxes.prototype =
/**
* @constructor
*
* @param {String} name
* @param {Object} options Hashtable of extra options to tag onto the layer
*/
initialize: function () {
initialize: function (name, options) {
OpenLayers.Layer.Markers.prototype.initialize.apply(this, arguments);
},
+1 -2
View File
@@ -15,8 +15,7 @@ OpenLayers.Layer.HTTPRequest.prototype =
/** Used to hash URL param strings for multi-WMS server selection.
* Set to the Golden Ratio per Knuth's recommendation.
*
* @type Numeric
* @private
* @final @type Numeric
*/
URL_HASH_FACTOR: (Math.sqrt(5) - 1) / 2,
+36 -15
View File
@@ -24,17 +24,23 @@ OpenLayers.Layer.Image.prototype =
/** @type String */
url: null,
/** @type OpenLayers.Bounds */
/**
* The image bounds in map units
* @type OpenLayers.Bounds
*/
extent: null,
/** @type OpenLayers.Size */
/**
* The image size in pixels
* @type OpenLayers.Size
*/
size: null,
/** @type OpenLayers.Tile.Image */
tile: null,
/** The ratio of height/width represented by a single pixel in the graphic
*
/**
* The ratio of height/width represented by a single pixel in the graphic
* @type Float */
aspectRatio: null,
@@ -94,10 +100,16 @@ OpenLayers.Layer.Image.prototype =
* @param {OpenLayers.Map} map
*/
setMap: function(map) {
// If nothing to do with resolutions has been set, assume a single
// resolution determined by extent/size
/**
* If nothing to do with resolutions has been set, assume a single
* resolution determined by ratio*extent/size - if an image has a
* pixel aspect ratio different than one (as calculated above), the
* image will be stretched in one dimension only.
*/
if( this.options.maxResolution == null ) {
this.options.maxResolution = this.extent.getWidth() / this.size.w;
this.options.maxResolution = this.aspectRatio *
this.extent.getWidth() /
this.size.w;
}
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
},
@@ -116,11 +128,8 @@ OpenLayers.Layer.Image.prototype =
if(zoomChanged || firstRendering) {
//determine new tile size
var tileWidth = this.extent.getWidth() / this.map.getResolution();
var tileHeight = this.extent.getHeight() /
(this.map.getResolution() * this.aspectRatio);
var tileSize = new OpenLayers.Size(tileWidth, tileHeight);
this.setTileSize();
//determine new position (upper left corner of new bounds)
var ul = new OpenLayers.LonLat(this.extent.left, this.extent.top);
var ulPx = this.map.getLayerPxFromLonLat(ul);
@@ -128,16 +137,28 @@ OpenLayers.Layer.Image.prototype =
if(firstRendering) {
//create the new tile
this.tile = new OpenLayers.Tile.Image(this, ulPx, this.extent,
this.url, tileSize);
this.url, this.tileSize);
} else {
//just resize the tile and set it's new position
this.tile.size = tileSize.clone();
this.tile.size = this.tileSize.clone();
this.tile.position = ulPx.clone();
}
this.tile.draw();
}
},
/**
* Set the tile size based on the map size. This also sets layer.imageSize
* and layer.imageOffset for use by Tile.Image.
*/
setTileSize: function() {
var tileWidth = this.extent.getWidth() / this.map.getResolution();
var tileHeight = this.extent.getHeight() / this.map.getResolution();
this.tileSize = new OpenLayers.Size(tileWidth, tileHeight);
this.imageSize = this.tileSize;
this.imageOffset = new OpenLayers.Pixel(0, 0);
},
/**
* @param {String} newUrl
*/
+30
View File
@@ -145,6 +145,36 @@ OpenLayers.Layer.KaMap.prototype =
this.spiralTileLoad();
},
/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.Grid
* @type OpenLayers.Layer.Grid
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer.KaMap(this.name,
this.url,
this.params,
this.options);
}
//get all additions from superclasses
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
// copy/set any non-init, non-simple values here
if (this.tileSize != null) {
obj.tileSize = this.tileSize.clone();
}
// we do not want to copy reference to grid, so we make a new array
obj.grid = new Array();
return obj;
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.KaMap"
+63 -52
View File
@@ -7,6 +7,7 @@
*
* @requires OpenLayers/Layer.js
* @requires OpenLayers/Renderer.js
* @requires OpenLayers/Feature/Vector.js
*/
OpenLayers.Layer.Vector = OpenLayers.Class.create();
OpenLayers.Layer.Vector.prototype =
@@ -21,17 +22,11 @@ OpenLayers.Layer.Vector.prototype =
/** @type Boolean */
isVector: true,
/** @type {Array(OpenLayer.Feature.Vector)} */
/** @type Array(OpenLayer.Feature.Vector) */
features: null,
/** @type {Array(OpenLayers.Feature.Vector)} */
selectedFeatures: [],
/** @type {Boolean} */
editing: false,
/** @type {Boolean} */
editable: false,
/** @type Array(OpenLayers.Feature.Vector) */
selectedFeatures: null,
/** @type {Boolean} */
reportError: true,
@@ -75,6 +70,10 @@ OpenLayers.Layer.Vector.prototype =
* Options renderer {Object}: Typically SVGRenderer or VMLRenderer.
*/
initialize: function(name, options) {
var defaultStyle = OpenLayers.Feature.Vector.style['default'];
this.style = OpenLayers.Util.extend({}, defaultStyle);
OpenLayers.Layer.prototype.initialize.apply(this, arguments);
// allow user-set renderer, otherwise assign one
@@ -102,8 +101,6 @@ OpenLayers.Layer.Vector.prototype =
// calling feature[i].destroy() here.
this.features = null;
this.selectedFeatures = null;
this.editing = null;
this.editable = null;
if (this.renderer) {
this.renderer.destroy();
}
@@ -172,7 +169,7 @@ OpenLayers.Layer.Vector.prototype =
/** Reset the vector layer's div so that it once again is lined up with
* the map. Notify the renderer of the change of extent, and in the
* case of a change of zoom level (resolution), have the
* renderer reproject.
* renderer redraw features.
*
* If the layer has not yet been drawn, cycle through the layer's
* features and draw each one.
@@ -191,15 +188,11 @@ OpenLayers.Layer.Vector.prototype =
this.renderer.setExtent(extent);
}
if (zoomChanged) {
this.renderer.reproject();
}
if (!this.drawn) {
if (!this.drawn || zoomChanged) {
this.drawn = true;
for(var i = 0; i < this.features.length; i++) {
var feature = this.features[i];
this.renderer.drawGeometry(feature.geometry, feature.style);
this.drawFeature(feature);
}
}
},
@@ -228,17 +221,13 @@ OpenLayers.Layer.Vector.prototype =
feature.layer = this;
if (!feature.style) {
if (this.style) {
feature.style = OpenLayers.Util.extend({}, this.style);
} else {
feature.style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
}
feature.style = OpenLayers.Util.extend({}, this.style);
}
this.preFeatureInsert(feature);
if (this.drawn) {
this.renderer.drawGeometry(feature.geometry, feature.style);
this.drawFeature(feature);
}
this.onFeatureInsert(feature);
@@ -254,7 +243,7 @@ OpenLayers.Layer.Vector.prototype =
features = [features];
}
for (var i = 0; i < features.length; i++) {
for (var i = features.length - 1; i >= 0; i--) {
var feature = features[i];
this.features = OpenLayers.Util.removeItem(this.features, feature);
@@ -263,53 +252,76 @@ OpenLayers.Layer.Vector.prototype =
},
/**
* Destroy all features on the layer and empty the selected features array.
*/
destroyFeatures: function () {
this.selectedFeatures = new Array();
for (var i = this.features.length - 1; i >= 0; i--) {
this.features[i].destroy();
}
},
/**
* @param {String} fid
* Draw (or redraw) a feature on the layer. If the optional style argument
* is included, this style will be used. If no style is included, the
* feature's style will be used. If the feature doesn't have a style,
* the layer's style will be used.
*
* @param {OpenLayers.Feature.Vector} feature
* @param {Object} style
*/
redrawFeature: function(fid, style) {
for (var i = 0; i < this.features.length; i++) {
var feature = this.features[i];
if (feature.fid == fid) {
this.renderer.drawGeometry(feature.geometry, style);
drawFeature: function(feature, style) {
if(style == null) {
if(feature.style) {
style = feature.style;
} else {
style = this.style;
}
}
this.renderer.drawFeature(feature, style);
},
/**
* Start editing the layer
* Erase features from the layer.
*
* @returns Whether or not the layer is editable
* @type Boolean
* @param {Array(OpenLayers.Feature.Vector)} features
*/
unlock: function() {
if(this.editable) {
this.editing = true;
}
return this.editable;
eraseFeatures: function(features) {
this.renderer.eraseFeatures(features);
},
/**
* Stop editing the layer
*
* @return Whether or not the layer *was* editing
* HACK HACK This return value seems wierd to me.
* @type Boolean
* Given an event, return a feature if the event occurred over one.
* Otherwise, return null.
*
* @param {Event}
* @type OpenLayers.Feature.Vector
* @return A feature if one was under the event
*/
lock: function() {
if(this.editing) {
this.editing = false;
}
return this.editing;
getFeatureFromEvent: function(evt) {
var featureId = this.renderer.getFeatureIdFromEvent(evt);
return this.getFeatureById(featureId);
},
/**
* Given a feature id, return the feature if it exists in the features array
*
* @param String featureId
* @type OpenLayers.Feature.Vector
* @return A feature corresponding to the given featureId
*/
getFeatureById: function(featureId) {
//TBD - would it be more efficient to use a hash for this.features?
var feature = null;
for(var i=0; i<this.features.length; ++i) {
if(this.features[i].id == featureId) {
feature = this.features[i];
break;
}
}
return feature;
},
/**
* Unselect the selected features
* i.e. clears the featureSelection array
@@ -319,8 +331,7 @@ OpenLayers.Layer.Vector.prototype =
var vectorLayer = this.map.vectorLayer;
for (var i = 0; i < this.map.featureSelection.length; i++) {
var featureSelection = this.map.featureSelection[i];
vectorLayer.renderer.drawGeometry(featureSelection.geometry,
vectorLayer.style);
vectorLayer.drawFeature(featureSelection, vectorLayer.style);
}
this.map.featureSelection = [];
},
+12 -1
View File
@@ -202,7 +202,18 @@ OpenLayers.Layer.WFS.prototype =
}
}
},
/**
* Call the onMapResize method of the appropriate parent class.
*/
onMapResize: function() {
if(this.vectorMode) {
OpenLayers.Layer.Vector.prototype.onMapResize.apply(this, arguments);
} else {
OpenLayers.Layer.Markers.prototype.onMapResize.apply(this, arguments);
}
},
/**
* @param {Object} obj
*