[OpenLayers-Commits] r2041 - in sandbox/vector/lib/OpenLayers: . Control Control/EditingTool Layer
commits at openlayers.org
commits at openlayers.org
Wed Dec 13 09:19:41 EST 2006
Author: pgiraud
Date: 2006-12-13 09:19:41 -0500 (Wed, 13 Dec 2006)
New Revision: 2041
Modified:
sandbox/vector/lib/OpenLayers/Control/EditingTool.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/AddPathPoint.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/Commit.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawCurvePath.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLineString.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearPath.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearRing.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawPoint.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/MovePathPoint.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/RemovePathPoint.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/Rotate.js
sandbox/vector/lib/OpenLayers/Control/EditingTool/Selection.js
sandbox/vector/lib/OpenLayers/Control/LayerSwitcher.js
sandbox/vector/lib/OpenLayers/Layer/Vector.js
sandbox/vector/lib/OpenLayers/Map.js
Log:
changed the vector selection management
new member "vectorLayer" added to map object that handles the reference to the currently selected layer
layer switcher radio buttons now call the Map.setVectorLayer() method
the editing tools now use the map.vectorLayer to draw or edit geometries
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/AddPathPoint.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/AddPathPoint.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/AddPathPoint.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -81,8 +81,8 @@
if (newPoint){
evt.targetGeometry.addPoint(newPoint, pathIndex+1);
- this.layer.renderer.drawGeometry(newPoint, "tmpPoint");
- this.layer.renderer.drawGeometry(evt.targetGeometry);
+ this.map.vectorLayer.renderer.drawGeometry(newPoint, "tmpPoint");
+ this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry);
}
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/Commit.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/Commit.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/Commit.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -30,7 +30,7 @@
*/
turnOn: function(){
OpenLayers.Control.EditingTool.prototype.turnOn.apply(this, arguments);
- this.layer.commit();
+ this.map.vectorLayer.commit();
},
/**
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawCurvePath.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawCurvePath.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawCurvePath.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -65,7 +65,7 @@
defaultDblClick: function (evt) {
- var lonlat = this.layer.map.getLonLatFromLayerPx(evt.xy);
+ var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
this.geometry.path[this.geometry.path.length-1] = point;
@@ -73,8 +73,8 @@
var feature = new OpenLayers.Feature();
feature.setGeometry(this.geometry);
- this.layer.addFeatures(feature);
- this.layer.removeTmpFeature();
+ this.map.vectorLayer.addFeatures(feature);
+ this.map.vectorLayer.removeTmpFeature();
this.geometry = new this.geometryClass();
@@ -86,7 +86,7 @@
OpenLayers.Event.stop(evt);
this.mouseDown = true;
- var lonlat = this.layer.map.getLonLatFromLayerPx(evt.xy);
+ var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat)
if(this.geometry.path.length == 0)
@@ -96,13 +96,13 @@
this.geometry.path.push(point);
this.geometry.path.push(point);
- this.layer.setTmpFeature(this.geometry);
+ this.map.vectorLayer.setTmpFeature(this.geometry);
},
defaultMouseMove: function (evt) {
OpenLayers.Control.EditingTool.prototype.defaultMouseMove.apply(this, arguments);
- var lonlat = this.layer.map.getLonLatFromLayerPx(evt.xy);
+ var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
@@ -121,7 +121,7 @@
this.geometry.path[this.geometry.path.length-2] = point;
}
- this.layer.setTmpFeature(this.geometry);
+ this.map.vectorLayer.setTmpFeature(this.geometry);
},
defaultMouseUp: function (evt) {
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLineString.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLineString.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLineString.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -48,17 +48,17 @@
finalizeGeometry: function(){
var feature = new OpenLayers.Feature();
feature.setGeometry(this.geometry);
- this.layer.addFeatures(feature);
+ this.map.vectorLayer.addFeatures(feature);
this.geometry = new OpenLayers.Geometry.LineString();
},
eraseTmpElements: function(){
for(var i = 0; i < this.geometry.path.length; i++) {
- this.layer.renderer.eraseGeometry(this.geometry.path[i]);
+ this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]);
}
- this.layer.renderer.eraseGeometry(this.tmpPoint);
- this.layer.renderer.eraseGeometry(this.tmpSegment);
+ this.map.vectorLayer.renderer.eraseGeometry(this.tmpPoint);
+ this.map.vectorLayer.renderer.eraseGeometry(this.tmpSegment);
},
defaultDblClick: function (evt) {
@@ -81,8 +81,8 @@
OpenLayers.Control.EditingTool.prototype.defaultMouseDown.apply(this, arguments);
this.geometry.addPoint(evt.point);
- this.layer.renderer.drawGeometry(evt.point, this.layer.style);
- this.layer.renderer.drawGeometry(this.geometry, this.layer.style);
+ this.map.vectorLayer.renderer.drawGeometry(evt.point, this.map.vectorLayer.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.map.vectorLayer.style);
},
defaultMouseMove: function (evt) {
@@ -95,10 +95,10 @@
if (this.geometry.path.length > 0) {
this.tmpPoint.x = evt.point.x;
this.tmpPoint.y = evt.point.y;
- this.layer.renderer.drawGeometry(this.tmpPoint, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.tmpPoint, this.style);
this.tmpSegment.path[0] = evt.point;
this.tmpSegment.path[1] = this.geometry.path[this.geometry.path.length-1];
- this.layer.renderer.drawGeometry(this.tmpSegment, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.tmpSegment, this.style);
}
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearPath.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearPath.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearPath.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -41,17 +41,17 @@
finalizeGeometry: function(){
var feature = new OpenLayers.Feature();
feature.setGeometry(this.geometry);
- this.layer.addFeatures(feature);
+ this.map.vectorLayer.addFeatures(feature);
this.geometry = new OpenLayers.Geometry.LineString();
},
eraseTmpElements: function(){
for(var i = 0; i < this.geometry.path.length; i++) {
- this.layer.renderer.eraseGeometry(this.geometry.path[i].id);
+ this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i].id);
}
- this.layer.renderer.eraseGeometry("tmpSegment");
- this.layer.renderer.eraseGeometry("tmpPath");
- this.layer.renderer.eraseGeometry("tmpPoint");
+ this.map.vectorLayer.renderer.eraseGeometry("tmpSegment");
+ this.map.vectorLayer.renderer.eraseGeometry("tmpPath");
+ this.map.vectorLayer.renderer.eraseGeometry("tmpPoint");
},
defaultDblClick: function (evt) {
@@ -77,8 +77,8 @@
evt.point.style = OpenLayers.Style.DefaultRendererTemporaryElementStlyle;
this.geometry.addPoint(evt.point);
- this.layer.renderer.drawGeometry(evt.point);
- this.layer.renderer.drawGeometry(this.geometry, "tmpPath");
+ this.map.vectorLayer.renderer.drawGeometry(evt.point);
+ this.map.vectorLayer.renderer.drawGeometry(this.geometry, "tmpPath");
},
defaultMouseMove: function (evt) {
@@ -88,10 +88,10 @@
this.defaultMouseDown(evt);
} else {
if (this.geometry.path.length > 0) {
- this.layer.renderer.drawGeometry(evt.point, "tmpPoint");
+ this.map.vectorLayer.renderer.drawGeometry(evt.point, "tmpPoint");
var tmpSegment = new OpenLayers.Geometry.LineSegment(this.geometry.path[this.geometry.path.length-1], evt.point);
tmpSegment.style = OpenLayers.Style.DefaultRendererTemporaryElementStlyle;
- this.layer.renderer.drawGeometry(tmpSegment, "tmpSegment");
+ this.map.vectorLayer.renderer.drawGeometry(tmpSegment, "tmpSegment");
}
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearRing.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearRing.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawLinearRing.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -48,17 +48,17 @@
finalizeGeometry: function(){
var feature = new OpenLayers.Feature();
feature.setGeometry(this.geometry);
- this.layer.addFeatures(feature);
+ this.map.vectorLayer.addFeatures(feature);
this.geometry = new OpenLayers.Geometry.LinearRing();
},
eraseTmpElements: function(){
for(var i = 0; i < this.geometry.path.length; i++) {
- this.layer.renderer.eraseGeometry(this.geometry.path[i]);
+ this.map.vectorLayer.renderer.eraseGeometry(this.geometry.path[i]);
}
- this.layer.renderer.eraseGeometry(this.tmpPoint);
- this.layer.renderer.eraseGeometry(this.tmpLineSting);
+ this.map.vectorLayer.renderer.eraseGeometry(this.tmpPoint);
+ this.map.vectorLayer.renderer.eraseGeometry(this.tmpLineSting);
},
defaultDblClick: function (evt) {
@@ -85,8 +85,8 @@
this.finalizeGeometry();
} else {
this.geometry.addPoint(evt.point);
- this.layer.renderer.drawGeometry(evt.point, this.layer.style);
- this.layer.renderer.drawGeometry(this.geometry, this.layer.style);
+ this.map.vectorLayer.renderer.drawGeometry(evt.point, this.map.vectorLayer.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.map.vectorLayer.style);
}
},
@@ -105,11 +105,11 @@
if (this.geometry.path.length > 0) {
this.tmpPoint.x = evt.point.x;
this.tmpPoint.y = evt.point.y;
- this.layer.renderer.drawGeometry(this.tmpPoint, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.tmpPoint, this.style);
this.tmpLineSting.path[0] = this.geometry.path[this.geometry.path.length-2];
this.tmpLineSting.path[1] = evt.point;
this.tmpLineSting.path[2] = this.geometry.path[this.geometry.path.length-1];
- this.layer.renderer.drawGeometry(this.tmpLineSting, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.tmpLineSting, this.style);
}
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawPoint.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawPoint.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/DrawPoint.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -40,8 +40,8 @@
*/
turnOff: function(){
OpenLayers.Control.EditingTool.prototype.turnOff.apply(this, arguments);
- this.layer.removeFeatures(this.geometry.feature);
- this.layer.renderer.eraseGeometry(this.geometry);
+ this.map.vectorLayer.removeFeatures(this.geometry.feature);
+ this.map.vectorLayer.renderer.eraseGeometry(this.geometry);
},
/**
@@ -52,7 +52,7 @@
finalizeGeometry: function(){
var feature = new OpenLayers.Feature();
feature.setGeometry(this.geometry);
- this.layer.addFeatures(feature);
+ this.map.vectorLayer.addFeatures(feature);
},
@@ -71,7 +71,7 @@
this.geometry = new OpenLayers.Geometry.Point();
this.geometry.x = evt.point.x;
this.geometry.y = evt.point.y;
- this.layer.renderer.drawGeometry(this.geometry, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.style);
},
/**
@@ -84,7 +84,7 @@
if (this.mouseDown) {
this.geometry.x = evt.point.x;
this.geometry.y = evt.point.y;
- this.layer.renderer.drawGeometry(this.geometry, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.geometry, this.style);
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/MovePathPoint.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/MovePathPoint.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/MovePathPoint.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -44,7 +44,7 @@
turnOff: function() {
OpenLayers.Control.EditingTool.prototype.turnOff.apply(this, arguments);
for(var i = 0; i < this.selection.length; i ++) {
- this.layer.renderer.eraseGeometry(this.selection[i]);
+ this.map.vectorLayer.renderer.eraseGeometry(this.selection[i]);
}
this.selection = [];
@@ -76,12 +76,12 @@
// user clicked out of a geometry
for(var i=0; i<this.selection.length; i++) {
// clear the selection points on display
- this.layer.renderer.eraseGeometry(this.selection[i], this.layer.style);
+ this.map.vectorLayer.renderer.eraseGeometry(this.selection[i], this.map.vectorLayer.style);
}
// clear the tool selection
this.selection = [];
// clear the layer selection (features selected)
- this.layer.selection = [];
+ this.map.vectorLayer.selection = [];
}
// initialize lastPositionReference wich is use to translate an an array of points
@@ -104,8 +104,8 @@
var tmpPoint = geometry.path[i];
// Calculate screen pixel from segment points and mouseCoordinates
- var pixel = this.layer.map.getPixelFromLonLat(tmpPoint);
- var mousePixel = this.layer.map.getPixelFromLonLat(mouseCoordinates);
+ var pixel = this.map.getPixelFromLonLat(tmpPoint);
+ var mousePixel = this.map.getPixelFromLonLat(mouseCoordinates);
// Compare first segment point pixel to mouse pixel with a tolerance
var currentDistance = OpenLayers.Util.distance2Pts(pixel.x, pixel.y, mousePixel.x, mousePixel.y);
@@ -126,38 +126,38 @@
// Verify if the point is selected
if (OpenLayers.Util.indexOf(this.selection, point) < 0){
this.selection.push(point);
- this.layer.renderer.drawGeometry(point, this.layer.style);
+ this.map.vectorLayer.renderer.drawGeometry(point, this.map.vectorLayer.style);
// UnSelect the point
} else {
this.selection = OpenLayers.Util.removeItem(this.selection, point);
- this.layer.renderer.eraseGeometry(point);
+ this.map.vectorLayer.renderer.eraseGeometry(point);
}
// Reset the point selection
} else {
for(var i = 0; i < this.selection.length; i++) {
- this.layer.renderer.eraseGeometry(this.selection[i]);
+ this.map.vectorLayer.renderer.eraseGeometry(this.selection[i]);
}
this.selection = [point];
- this.layer.renderer.drawGeometry(point, this.layer.style);
+ this.map.vectorLayer.renderer.drawGeometry(point, this.map.vectorLayer.style);
}
} else {
for(var i = 0; i < this.selection.length; i++) {
- this.layer.renderer.eraseGeometry(this.selection[i], this.layer.style);
+ this.map.vectorLayer.renderer.eraseGeometry(this.selection[i], this.map.vectorLayer.style);
}
- this.layer.selection = [];
+ this.map.vectorLayer.selection = [];
}
// Geometry Selection
if (this.shiftDown){
- if (OpenLayers.Util.indexOf(this.layer.selection, geometry.feature) < 0){
- this.layer.selection.push(geometry.feature);
+ if (OpenLayers.Util.indexOf(this.map.vectorLayer.selection, geometry.feature) < 0){
+ this.map.vectorLayer.selection.push(geometry.feature);
} else {
- //this.layer.selection = OpenLayers.Util.removeItem(this.layer.selection, geometry.feature);
+ //this.map.vectorLayer.selection = OpenLayers.Util.removeItem(this.map.vectorLayer.selection, geometry.feature);
}
} else {
- this.layer.selection = geometry.feature?[geometry.feature]:[];
+ this.map.vectorLayer.selection = geometry.feature?[geometry.feature]:[];
}
},
@@ -184,12 +184,12 @@
for(var i=0; i<this.selection.length; i++) {
this.selection[i].setX(this.selection[i].x + xTranslation);
this.selection[i].setY(this.selection[i].y + yTranslation);
- this.layer.renderer.drawGeometry(this.selection[i], this.layer.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.selection[i], this.map.vectorLayer.style);
}
// redraw the modified Geometries
- for(var i = 0; i < this.layer.selection.length; i++) {
- this.layer.renderer.drawGeometry(this.layer.selection[i].geometry, this.layer.style);
+ for(var i = 0; i < this.map.vectorLayer.selection.length; i++) {
+ this.map.vectorLayer.renderer.drawGeometry(this.map.vectorLayer.selection[i].geometry, this.map.vectorLayer.style);
}
}
@@ -202,8 +202,8 @@
defaultMouseUp: function (evt) {
OpenLayers.Control.EditingTool.prototype.defaultMouseUp.apply(this, arguments);
- if (this.layer.selection.length > 0) {
- this.layer.updateFeatures(this.layer.selection);
+ if (this.map.vectorLayer.selection.length > 0) {
+ this.map.vectorLayer.updateFeatures(this.map.vectorLayer.selection);
}
},
@@ -217,7 +217,7 @@
case OpenLayers.Event.KEY_BACKSPACE:
case OpenLayers.Event.KEY_DELETE:
this.eraseTmpElements();
- this.layer.removeFeatures(this.MovePathPoint);
+ this.map.vectorLayer.removeFeatures(this.MovePathPoint);
this.selection.clear();
OpenLayers.Event.stop(evt);
break;
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/RemovePathPoint.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/RemovePathPoint.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/RemovePathPoint.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -47,7 +47,7 @@
var distance = this.tolerance
if (evt.targetGeometry && evt.targetGeometry.path) {
for(var i = 0; i < evt.targetGeometry.path.length; i++) {
- var pixel = this.layer.map.getPixelFromLonLat(evt.targetGeometry.path[i]);
+ var pixel = this.map.getPixelFromLonLat(evt.targetGeometry.path[i]);
var currentDistance = OpenLayers.Util.distance2Pts(pixel.x, pixel.y, evt.xy.x, evt.xy.y);
if (currentDistance < distance) {
@@ -57,8 +57,8 @@
}
evt.targetGeometry.removePoint(evt.targetGeometry.path[closestVertexIndex]);
- this.layer.updateFeatures([evt.targetGeometry.feature]);
- this.layer.renderer.drawGeometry(evt.targetGeometry, this.layer.style);
+ this.map.vectorLayer.updateFeatures([evt.targetGeometry.feature]);
+ this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry, this.map.vectorLayer.style);
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/Rotate.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/Rotate.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/Rotate.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -78,7 +78,7 @@
// set the rotation reference point
var lonlat = this.map.getLonLatFromLayerPx(evt.xy);
this.rotationReference = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
- this.layer.renderer.drawGeometry(this.rotationCenter, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.rotationCenter, this.style);
}
},
@@ -111,7 +111,7 @@
// set and draw the new path
this.tmpGeometry.path = path;
- this.layer.renderer.drawGeometry(this.tmpGeometry, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.tmpGeometry, this.style);
}
},
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool/Selection.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool/Selection.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool/Selection.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -80,30 +80,30 @@
if (this.shiftDown){
// Verify if the geometry is selected
- if (OpenLayers.Util.indexOf(this.layer.selection, evt.targetGeometry.feature) < 0){
- this.layer.selection.push(evt.targetGeometry.feature);
- this.layer.renderer.drawGeometry(evt.targetGeometry, this.style);
+ if (OpenLayers.Util.indexOf(this.map.vectorLayer.selection, evt.targetGeometry.feature) < 0){
+ this.map.vectorLayer.selection.push(evt.targetGeometry.feature);
+ this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry, this.style);
// UnSelect the geometry
} else {
- this.layer.selection = OpenLayers.Util.removeItem(this.layer.selection, evt.targetGeometry.feature);
- this.layer.renderer.drawGeometry(evt.targetGeometry, this.layer.style);
+ this.map.vectorLayer.selection = OpenLayers.Util.removeItem(this.map.vectorLayer.selection, evt.targetGeometry.feature);
+ this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry, this.map.vectorLayer.style);
}
// Reset the geometry selection
} else {
- for(var i=0; i<this.layer.selection.length; i++) {
- this.layer.renderer.drawGeometry(this.layer.selection[i].geometry, this.layer.style);
+ for(var i=0; i<this.map.vectorLayer.selection.length; i++) {
+ this.map.vectorLayer.renderer.drawGeometry(this.map.vectorLayer.selection[i].geometry, this.map.vectorLayer.style);
}
- this.layer.selection = [];
- this.layer.selection = [evt.targetGeometry.feature];
- this.layer.renderer.drawGeometry(evt.targetGeometry.feature.geometry, this.style);
+ this.map.vectorLayer.selection = [];
+ this.map.vectorLayer.selection = [evt.targetGeometry.feature];
+ this.map.vectorLayer.renderer.drawGeometry(evt.targetGeometry.feature.geometry, this.style);
}
} else {
- for(var i=0; i<this.layer.selection.length; i++) {
- this.layer.renderer.drawGeometry(this.layer.selection[i].geometry, this.layer.style);
+ for(var i=0; i<this.map.vectorLayer.selection.length; i++) {
+ this.map.vectorLayer.renderer.drawGeometry(this.map.vectorLayer.selection[i].geometry, this.map.vectorLayer.style);
}
- this.layer.selection = [];
+ this.map.vectorLayer.selection = [];
}
// initialize lastPositionReference wich is use to translate an an array of points
@@ -130,29 +130,29 @@
this.lastPositionReference = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
// translate and draw the points
- for(var i=0; i<this.layer.selection.length; i++) {
+ for(var i=0; i<this.map.vectorLayer.selection.length; i++) {
// Point Geometry
- if (this.layer.selection[i].geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
- this.layer.selection[i].geometry.setX( this.layer.selection[i].geometry.x + xTranslation);
- this.layer.selection[i].geometry.setY( this.layer.selection[i].geometry.y + yTranslation);
+ if (this.map.vectorLayer.selection[i].geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
+ this.map.vectorLayer.selection[i].geometry.setX( this.map.vectorLayer.selection[i].geometry.x + xTranslation);
+ this.map.vectorLayer.selection[i].geometry.setY( this.map.vectorLayer.selection[i].geometry.y + yTranslation);
// Path Geometry
- } else if (this.layer.selection[i].geometry.path) {
- var path = this.layer.selection[i].geometry.path;
+ } else if (this.map.vectorLayer.selection[i].geometry.path) {
+ var path = this.map.vectorLayer.selection[i].geometry.path;
for(var iPath = 0; iPath < path.length; iPath++) {
- if (this.layer.selection[i].geometry.CLASS_NAME != "OpenLayers.Geometry.LinearRing" || iPath != path.length-1) {
+ if (this.map.vectorLayer.selection[i].geometry.CLASS_NAME != "OpenLayers.Geometry.LinearRing" || iPath != path.length-1) {
path[iPath].setX(path[iPath].x + xTranslation);
path[iPath].setY(path[iPath].y + yTranslation);
}
}
- this.layer.selection[i].geometry.path = path;
+ this.map.vectorLayer.selection[i].geometry.path = path;
// Aggregate Geometry
} else {
}
- this.layer.renderer.drawGeometry(this.layer.selection[i].geometry, this.style);
+ this.map.vectorLayer.renderer.drawGeometry(this.map.vectorLayer.selection[i].geometry, this.style);
}
}
},
@@ -164,8 +164,8 @@
OpenLayers.Control.EditingTool.prototype.defaultMouseUp.apply(this, arguments);
// TBD check if this is working
- if (this.layer.selection.length > 0){
- this.layer.updateFeatures(this.layer.selection);
+ if (this.map.vectorLayer.selection.length > 0){
+ this.map.vectorLayer.updateFeatures(this.map.vectorLayer.selection);
}
},
@@ -178,8 +178,8 @@
switch (evt.keyCode){
case OpenLayers.Event.KEY_BACKSPACE:
case OpenLayers.Event.KEY_DELETE:
- this.layer.removeFeatures(this.layer.selection);
- this.layer.selection = []
+ this.map.vectorLayer.removeFeatures(this.map.vectorLayer.selection);
+ this.map.vectorLayer.selection = []
OpenLayers.Event.stop(evt);
break;
}
Modified: sandbox/vector/lib/OpenLayers/Control/EditingTool.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/EditingTool.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/EditingTool.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -48,29 +48,12 @@
this.editingModes.push(new OpenLayers.Control.EditingMode.SegmentSnapping());
this.style = OpenLayers.Style.DefaultRendererTemporaryElementStyle;
},
-
- /**
- * @param {Object.Layer.Vector} layer
- */
- setLayer: function(layer) {
- if (layer) {
- this.layer = layer;
- } else {
- for (var i = 0; i < this.map.layers.length; i++) {
- if (this.map.layers[i].isVector) {
- this.layer = this.map.layers[i];
- }
- }
- }
- },
/**
*
*/
turnOn: function() {
- this.setLayer();
-
this.defaultClick = this.defaultClick.bindAsEventListener(this);
this.defaultDblClick = this.defaultDblClick.bindAsEventListener(this);
this.defaultMouseDown = this.defaultMouseDown.bindAsEventListener(this);
@@ -138,13 +121,13 @@
evt.point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
// the target Geometry is the shape under the mouse
- evt.targetGeometry = this.layer.renderer.getGeometryFromEvent(evt);
+ evt.targetGeometry = this.map.vectorLayer.renderer.getGeometryFromEvent(evt);
// reset evt.point if modes are activated.
if (this.editingModes) {
for (var i = 0; i < this.editingModes.length; i++) {
var snappingCoordinates =
- this.editingModes[i].calculatePoint(evt.point, evt.targetGeometry, this.geometry, this.layer);
+ this.editingModes[i].calculatePoint(evt.point, evt.targetGeometry, this.geometry, this.map.vectorLayer);
if (snappingCoordinates) {
evt.point = snappingCoordinates;
Modified: sandbox/vector/lib/OpenLayers/Control/LayerSwitcher.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Control/LayerSwitcher.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Control/LayerSwitcher.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -26,10 +26,8 @@
/** @type Array */
baseLayerInputs: null,
- selectedVectorLayer: null,
+ oldZIndex: null,
- selectedVectorLayerZIndex: null,
-
/** @type DOMElement */
dataLbl: null,
@@ -162,12 +160,16 @@
// create vector layer selection element
if(vectorLayer) {
+
vectorInputElem = document.createElement("input");
//vectorInputElem.id = "vectorInput_" + layer.name;
vectorInputElem.name = "VectorRadio";
vectorInputElem.type = "radio";
//vectorInputElem.value = layer.name;
- //vectorInputElem.checked = layer.isSelected;
+ if (layer == this.map.vectorLayer) {
+ vectorInputElem.checked = (layer == this.map.vectorLayer);
+ this.switchZindex(layer);
+ }
//vectorInputElem.defaultChecked = false;
vectorInputElem.layer = layer;
//vectorInputElem.control = this;
@@ -212,25 +214,34 @@
/*
* Function
*
- * Use to put the selected vector layer over the others
+ * Handles the radio button check for vector layers
*/
onVectorInputClick: function(e) {
- if(this.selectedVectorLayer){
- this.selectedVectorLayer.div.style.zIndex = this.selectedVectorLayerZIndex;
- }
var vectorInput = e.target || e.srcElement;
- this.selectedVectorLayer = vectorInput.layer;
- this.selectedVectorLayerZIndex = this.selectedVectorLayer.div.style.zIndex;
-
- this.selectedVectorLayer.div.style.zIndex = 850;
+ this.switchZindex(vectorInput.layer);
if (!vectorInput.disabled) {
vectorInput.checked = true;
- }
+ }
+ this.map.setVectorLayer(vectorInput.layer);
},
+ /**
+ * Switches the z-index between the old value and 850
+ * Use to put the selected vector layer over the others
+ *
+ * @param {OpenLayers.Layer.Vector} layer to move to top
+ */
+ switchZindex: function(layer) {
+ if (this.oldZIndex) {
+ this.map.vectorLayer.div.style.zIndex = this.oldZIndex;
+ }
+ this.oldZIndex = layer.div.style.zIndex;
+ layer.div.style.zIndex = 850;
+ },
+
/** Need to update the map accordingly whenever user clicks in either of
* the layers.
*
Modified: sandbox/vector/lib/OpenLayers/Layer/Vector.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Layer/Vector.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Layer/Vector.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -20,8 +20,6 @@
/** @type Boolean */
isVector: true,
- isSelected: false,
-
/**
* @type {Array} An array of {OpenLayer.Feature}.
*/
Modified: sandbox/vector/lib/OpenLayers/Map.js
===================================================================
--- sandbox/vector/lib/OpenLayers/Map.js 2006-12-13 13:22:47 UTC (rev 2040)
+++ sandbox/vector/lib/OpenLayers/Map.js 2006-12-13 14:19:41 UTC (rev 2041)
@@ -71,6 +71,11 @@
* @type OpenLayers.Layer */
baseLayer: null,
+ /** The currently selected vector layer
+ *
+ * @type OpenLayers.Layer.Vector */
+ vectorLayer: null,
+
/** @type OpenLayers.LonLat */
center: null,
@@ -310,6 +315,12 @@
if (this.getCenter() != null) {
layer.moveTo(this.getExtent(), true);
}
+ if (layer.isVector) {
+ if (this.vectorLayer == null) {
+ // set the first vectorlayer we add as the vectorlayer
+ this.setVectorLayer(layer);
+ }
+ }
}
this.events.triggerEvent("addlayer");
@@ -466,7 +477,33 @@
}
}
},
+
+
+ /** Allows user to specify one of the vector layers as the Map's
+ * new vector layer.
+ *
+ * @param {OpenLayers.Layer.Vector} newVectorLayer
+ * @param {Boolean} noEvent
+ */
+ setVectorLayer: function(newVectorLayer, noEvent) {
+ var oldVectorLayer = this.vectorLayer;
+ if (newVectorLayer != oldVectorLayer) {
+
+ // is newVectorLayer an already loaded layer?
+ if (OpenLayers.Util.indexOf(this.layers, newVectorLayer) != -1) {
+ // set new Vectorlayer and make it visible
+ this.vectorLayer = newVectorLayer;
+
+ /* We probably need to trigger a changevectorlayer event
+ if ((noEvent == null) || (noEvent == false)) {
+ this.events.triggerEvent("changevectorlayer");
+ }
+ */
+ }
+ }
+ },
+
/**
* @param {OpenLayers.Control} control
* @param {OpenLayers.Pixel} px
More information about the Commits
mailing list