make the drawing handlers create the sketch feature at an appropriate time, when we can actually derive geographic coordinates from a pixel, r=ahocevar (References #3327)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@12046 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-06-06 07:12:52 +00:00
parent 9dcdbac238
commit 9b361ef35d
9 changed files with 116 additions and 208 deletions

View File

@@ -75,13 +75,10 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
* feature.
*/
createFeature: function(pixel) {
var geometry;
if(pixel) {
var lonlat = this.map.getLonLatFromPixel(pixel);
geometry = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
} else {
geometry = new OpenLayers.Geometry.Point();
}
var lonlat = this.map.getLonLatFromPixel(pixel);
var geometry = new OpenLayers.Geometry.Point(
lonlat.lon, lonlat.lat
);
this.point = new OpenLayers.Feature.Vector(geometry);
this.line = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LinearRing([this.point.geometry])
@@ -251,9 +248,13 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
/**
* Method: destroyFeature
* Destroy temporary geometries
*
* Parameters:
* force - {Boolean} Destroy even if persist is true.
*/
destroyFeature: function() {
OpenLayers.Handler.Path.prototype.destroyFeature.apply(this);
destroyFeature: function(force) {
OpenLayers.Handler.Path.prototype.destroyFeature.call(
this, force);
this.polygon = null;
},