When trying to deactivate a control from within that control's featureAdded
event, a null exception is encountered. A null check fixes this bug. (Closes #1143) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5433 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -79,7 +79,9 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
|
|||||||
*/
|
*/
|
||||||
destroyFeature: function() {
|
destroyFeature: function() {
|
||||||
OpenLayers.Handler.Point.prototype.destroyFeature.apply(this);
|
OpenLayers.Handler.Point.prototype.destroyFeature.apply(this);
|
||||||
|
if(this.line) {
|
||||||
this.line.destroy();
|
this.line.destroy();
|
||||||
|
}
|
||||||
this.line = null;
|
this.line = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,9 @@ OpenLayers.Handler.Point = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
* Destroy the temporary geometries
|
* Destroy the temporary geometries
|
||||||
*/
|
*/
|
||||||
destroyFeature: function() {
|
destroyFeature: function() {
|
||||||
|
if(this.point) {
|
||||||
this.point.destroy();
|
this.point.destroy();
|
||||||
|
}
|
||||||
this.point = null;
|
this.point = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ OpenLayers.Handler.Polygon = OpenLayers.Class(OpenLayers.Handler.Path, {
|
|||||||
*/
|
*/
|
||||||
destroyFeature: function() {
|
destroyFeature: function() {
|
||||||
OpenLayers.Handler.Path.prototype.destroyFeature.apply(this);
|
OpenLayers.Handler.Path.prototype.destroyFeature.apply(this);
|
||||||
|
if(this.polygon) {
|
||||||
this.polygon.destroy();
|
this.polygon.destroy();
|
||||||
|
}
|
||||||
this.polygon = null;
|
this.polygon = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -237,8 +237,6 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
if ( !(newCenter.equals(oldCenter)) ||
|
if ( !(newCenter.equals(oldCenter)) ||
|
||||||
!(newZoom == oldZoom) ) {
|
!(newZoom == oldZoom) ) {
|
||||||
|
|
||||||
var center = this.getMapObjectLonLatFromOLLonLat(newCenter);
|
|
||||||
|
|
||||||
if (dragging && this.dragPanMapObject &&
|
if (dragging && this.dragPanMapObject &&
|
||||||
this.smoothDragPan) {
|
this.smoothDragPan) {
|
||||||
var resolution = this.map.getResolution();
|
var resolution = this.map.getResolution();
|
||||||
@@ -246,6 +244,7 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
var dY = (newCenter.lat - oldCenter.lat) / resolution;
|
var dY = (newCenter.lat - oldCenter.lat) / resolution;
|
||||||
this.dragPanMapObject(dX, dY);
|
this.dragPanMapObject(dX, dY);
|
||||||
} else {
|
} else {
|
||||||
|
var center = this.getMapObjectLonLatFromOLLonLat(newCenter);
|
||||||
var zoom = this.getMapObjectZoomFromOLZoom(newZoom);
|
var zoom = this.getMapObjectZoomFromOLZoom(newZoom);
|
||||||
this.setMapObjectCenter(center, zoom, dragging);
|
this.setMapObjectCenter(center, zoom, dragging);
|
||||||
}
|
}
|
||||||
@@ -280,6 +279,18 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, {
|
|||||||
var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx);
|
var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx);
|
||||||
var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel);
|
var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel);
|
||||||
lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat);
|
lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat);
|
||||||
|
var xrem = this.map.size.w % 2;
|
||||||
|
var yrem = this.map.size.h % 2;
|
||||||
|
if(xrem != 0 || yrem != 0) {
|
||||||
|
// odd sized viewport
|
||||||
|
var olPx = viewPortPx.add(xrem, yrem);
|
||||||
|
var moPx = this.getMapObjectPixelFromOLPixel(olPx);
|
||||||
|
var moLoc = this.getMapObjectLonLatFromMapObjectPixel(moPx);
|
||||||
|
var olLoc = this.getOLLonLatFromMapObjectLonLat(moLoc);
|
||||||
|
// adjust by half a pixel in odd dimension(s)
|
||||||
|
lonlat.lon += (olLoc.lon - lonlat.lon) / 2;
|
||||||
|
lonlat.lat += (olLoc.lat - lonlat.lat) / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return lonlat;
|
return lonlat;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user