#628 - a feature has a geometry - a geometry doesn't have a feature - features are rendered, selected, moved, modified, etc - down in the renderer, expando properties on nodes are limited to _featureId, _style, and _options - this removes expandos that created circular references back through the map and to other dom elements - when the renderer is involved in selecting features, it returns a featureId (instead of a geometry or feature) and the layer is responsible for fetching the appropriate feature
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3043 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -21,9 +21,9 @@ OpenLayers.Handler.Feature.prototype =
|
||||
layerIndex: null,
|
||||
|
||||
/**
|
||||
* @type {OpenLayers.Geometry}
|
||||
* @type {OpenLayers.Feature.Vector}
|
||||
*/
|
||||
geometry: null,
|
||||
feature: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -33,7 +33,7 @@ OpenLayers.Handler.Feature.prototype =
|
||||
* @param {Array} callbacks An object with a 'over' property whos value is
|
||||
* a function to be called when the mouse is over
|
||||
* a feature. The callback should expect to recieve
|
||||
* a single argument, the geometry.
|
||||
* a single argument, the feature.
|
||||
* @param {Object} options
|
||||
*/
|
||||
initialize: function(control, layer, callbacks, options) {
|
||||
@@ -75,7 +75,7 @@ OpenLayers.Handler.Feature.prototype =
|
||||
|
||||
/**
|
||||
* Capture double-clicks. Let the event continue propagating if the
|
||||
* double-click doesn't hit a geometry. Otherwise call the dblclick
|
||||
* double-click doesn't hit a feature. Otherwise call the dblclick
|
||||
* callback.
|
||||
*
|
||||
* @param {Event} evt
|
||||
@@ -92,26 +92,26 @@ OpenLayers.Handler.Feature.prototype =
|
||||
* @type {Boolean} A feature was selected
|
||||
*/
|
||||
select: function(type, evt) {
|
||||
var geometry = this.layer.renderer.getGeometryFromEvent(evt);
|
||||
if(geometry) {
|
||||
var feature = this.layer.getFeatureFromEvent(evt);
|
||||
if(feature) {
|
||||
// three cases:
|
||||
// over a new, out of the last and over a new, or still on the last
|
||||
if(!this.geometry) {
|
||||
// over a new geometry
|
||||
this.callback('over', [geometry]);
|
||||
} else if(this.geometry != geometry) {
|
||||
if(!this.feature) {
|
||||
// over a new feature
|
||||
this.callback('over', [feature]);
|
||||
} else if(this.feature != feature) {
|
||||
// out of the last and over a new
|
||||
this.callback('out', [this.geometry]);
|
||||
this.callback('over', [geometry]);
|
||||
this.callback('out', [this.feature]);
|
||||
this.callback('over', [feature]);
|
||||
}
|
||||
this.geometry = geometry;
|
||||
this.callback(type, [geometry]);
|
||||
this.feature = feature;
|
||||
this.callback(type, [feature]);
|
||||
return true;
|
||||
} else {
|
||||
if(this.geometry) {
|
||||
if(this.feature) {
|
||||
// out of the last
|
||||
this.callback('out', [this.geometry]);
|
||||
this.geometry = null;
|
||||
this.callback('out', [this.feature]);
|
||||
this.feature = null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user