make it possible to activate a drawing handler before the map is centered, r=ahocevar (closes #3179)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11717 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-03-21 08:28:58 +00:00
parent 96198dee07
commit 04ee616947
2 changed files with 42 additions and 15 deletions

View File

@@ -200,13 +200,14 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
* pixel - {<OpenLayers.Pixel>} A pixel location on the map.
*/
createFeature: function(pixel) {
if(!pixel) {
pixel = new OpenLayers.Pixel(-50, -50);
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);
this.point = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)
);
this.point = new OpenLayers.Feature.Vector(geometry);
this.callback("create", [this.point.geometry, this.point]);
this.point.geometry.clearBounds();
this.layer.addFeatures([this.point], {silent: true});