make it possible to pan the map while drawing geometries, r=tschaub (closes #3052)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11381 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-02-24 09:00:49 +00:00
parent f8db509725
commit 30aeab365a
11 changed files with 1665 additions and 309 deletions

View File

@@ -75,6 +75,9 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
* feature.
*/
createFeature: function(pixel) {
if(!pixel) {
pixel = new OpenLayers.Pixel(-50, -50);
}
var lonlat = this.control.map.getLonLatFromPixel(pixel);
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)
@@ -82,13 +85,27 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
this.line = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.LinearRing([this.point.geometry])
);
// check for hole digitizing
var polygon;
if (this.holeModifier && (this.evt[this.holeModifier])) {
this.polygon = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon([this.line.geometry])
);
this.callback("create", [this.point.geometry, this.getSketch()]);
this.point.geometry.clearBounds();
this.layer.addFeatures([this.polygon, this.point], {silent: true});
},
/**
* Method: addPoint
* Add point to geometry.
*
* Parameters:
* pixel - {<OpenLayers.Pixel>} The pixel location for the new point.
*/
addPoint: function(pixel) {
if(!this.drawingHole && this.holeModifier &&
this.evt && this.evt[this.holeModifier]) {
var geometry = this.point.geometry;
var features = this.control.layer.features;
var candidate;
var candidate, polygon;
// look for intersections, last drawn gets priority
for (var i=features.length-1; i>=0; --i) {
candidate = features[i].geometry;
@@ -110,15 +127,7 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
}
}
}
if (!polygon) {
this.polygon = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon([this.line.geometry])
);
}
this.callback("create", [this.point.geometry, this.getSketch()]);
this.point.geometry.clearBounds();
this.layer.addFeatures([this.polygon, this.point], {silent: true});
OpenLayers.Handler.Path.prototype.addPoint.apply(this, arguments);
},
/**