[OpenLayers-Commits] r12043 - in sandbox/tschaub/editing: examples
lib/OpenLayers/Control
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Sun Jun 5 19:27:04 EDT 2011
Author: tschaub
Date: 2011-06-05 16:27:04 -0700 (Sun, 05 Jun 2011)
New Revision: 12043
Modified:
sandbox/tschaub/editing/examples/editing-methods.html
sandbox/tschaub/editing/examples/editing-methods.js
sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js
Log:
Add cancel method to draw control.
Modified: sandbox/tschaub/editing/examples/editing-methods.html
===================================================================
--- sandbox/tschaub/editing/examples/editing-methods.html 2011-06-05 23:17:09 UTC (rev 12042)
+++ sandbox/tschaub/editing/examples/editing-methods.html 2011-06-05 23:27:04 UTC (rev 12043)
@@ -8,12 +8,6 @@
<link rel="stylesheet" href="../theme/default/style.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="../lib/OpenLayers.js"></script>
- <style>
- .olControlAttribution {
- font-size: 9px;
- bottom: 5px;
- }
- </style>
</head>
<body>
<h1 id="title">Editing Methods</h1>
@@ -28,6 +22,7 @@
<li><a href="#" id="insertDirectionLength">insert direction/length</a></li>
<li><a href="#" id="insertDeflectionLength">insert deflection/length</a></li>
<li><a href="#" id="finishSketch">finish sketch</a></li>
+ <li><a href="#" id="cancel">cancel sketch</a></li>
</ul>
<div id="docs">
@@ -47,6 +42,8 @@
The <code>control.finishSketch</code> method completes the current
sketch without adding the point under the user's mouse. This
allows a sketch to be finished without a double-click.
+ The <code>control.cancel</code> method discards the current
+ sketch and leaves the control active.
The <code>control.insertXY</code> method may be called before
any points are digitized manually. The other methods have no
effect until at least one point has been added to the sketch.
@@ -57,8 +54,5 @@
</div>
<script src="editing-methods.js"></script>
-
-
-
</body>
</html>
Modified: sandbox/tschaub/editing/examples/editing-methods.js
===================================================================
--- sandbox/tschaub/editing/examples/editing-methods.js 2011-06-05 23:17:09 UTC (rev 12042)
+++ sandbox/tschaub/editing/examples/editing-methods.js 2011-06-05 23:27:04 UTC (rev 12043)
@@ -60,6 +60,9 @@
draw.insertDeflectionLength(values[0], values[1]);
}
}
+$("cancel").onclick = function() {
+ draw.cancel();
+}
$("finishSketch").onclick = function() {
draw.finishSketch();
}
Modified: sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js
===================================================================
--- sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js 2011-06-05 23:17:09 UTC (rev 12042)
+++ sandbox/tschaub/editing/lib/OpenLayers/Control/DrawFeature.js 2011-06-05 23:27:04 UTC (rev 12043)
@@ -244,6 +244,15 @@
},
/**
+ * APIMethod: cancel
+ * Cancel the current sketch. This removes the current sketch and keeps
+ * the drawing control active.
+ */
+ cancel: function() {
+ this.handler.cancel();
+ },
+
+ /**
* APIMethod: deactivate
* Deactivates a control and it's associated handler.
*
More information about the Commits
mailing list