Separate appendCoordinates function from extend

This commit is contained in:
Otto Pellinen
2019-09-13 14:14:58 +03:00
committed by Olivier Guyot
parent 25a5e83910
commit 83c0a258e6
3 changed files with 38 additions and 19 deletions

View File

@@ -1,12 +1,12 @@
---
layout: example.html
title: Draw and Extend Features
shortdesc: Example of using the extend function of ol/interaction/Draw interaction.
title: Draw and Append Features
shortdesc: Example of using the appendCoordinates function of ol/interaction/Draw interaction.
docs: >
Example of using the the extend function of Draw interaction. Select a geometry type from the
dropdown above to start drawing. To finish drawing, click the last
point. Click the green LineString Feature to extend coordinates to your drawing.
Extending is supported for drawing LineStrings and Polygons.
Example of using the the appendCoordinates function of Draw interaction. Select a geometry type from the
dropdown above to start drawing. To finish drawing, click the last point.
Click the green LineString Feature to append its coordinates to your drawing.
Appending is supported for drawing LineStrings and Polygons.
tags: "draw, edit, freehand, vector"
---
<div id="map" class="map"></div>

View File

@@ -21,7 +21,7 @@ sampleFeatures.push(
[-12000000, 4600000],
[-12000000, 4000000],
[-10000000, 5600000],
[-9000000, 3000000],
[-9000000, 3000000],
[-10000000, 4000000],
[-11000000, 3000000],
[-13000000, 4000000],
@@ -77,7 +77,7 @@ map.on('click', (event) => {
// In this demo we remove the new point that was clicked,
// and add the whole feature instead:
draw.removeLastPoint();
draw.extend(clickedFeature);
draw.appendCoordinates(clickedFeature.getGeometry().getCoordinates());
}
});