# How to draw interactively a line on a layer?

**URL:** <https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236>\
**Category:** MapWinGIS\
**Created:** [August 28, 2019, 8:31pm UTC](https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236 "2019-08-28T20:31:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gilles](https://avatars.discourse-cdn.com/v4/letter/g/ce7236/32.png) [@Gilles](https://mapwindow.discourse.group/u/Gilles)\
**Post date:** [August 28, 2019, 8:31pm UTC](https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236/1 "2019-08-28T20:31:07Z")

</div>

Could you show me an example of code to get the positions of user clicks (two points) on map in order to draw then a line ? I suppose I have to use SHP\_POLYLINE as shapefile type and “AddShape” as cursor mode. But I don’t succeed to draw interactively a line on the created layer.

(Morever, I would like to create a point/arrowhead with the good rotation on a second layer at the end of this segment as jerryfaust suggested here : [https://github.com/MapWindow/MapWinGIS/issues/122](https://github.com/MapWindow/MapWinGIS/issues/122))

Thank you in advance for your help  
Gilles

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [August 29, 2019, 6:53am UTC](https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236/2 "2019-08-29T06:53:12Z")

</div>

If you want to draw on an existing layer you can use the [Shape Editor](https://www.mapwindow.org/documentation/mapwingis4.9/class_shape_editor.html)  
or look at this example [‘Add points to map’](https://www.mapwindow.org/documentation/mapwingis4.9/_mark_points_8cs-example.html).

If you want to draw on another layer you can use [Drawing layers](https://www.mapwindow.org/documentation/mapwingis4.9/group __map__ drawing__layers.html). Drawing layers don’t have an option to draw an arrowhead but you can create one using [DrawPolygonEx()](https://www.mapwindow.org/documentation/mapwingis4.9/group__map __drawing__ layers.html#gac5ec79138f75fdfdcab2e7ae6ae12a6f).

---

<div class="post-metadata">

**Author:** ![tiennguyen](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@tiennguyen](https://mapwindow.discourse.group/u/tiennguyen)\
**Post date:** [December 30, 2019, 8:45am UTC](https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236/4 "2019-12-30T08:45:48Z")

</div>

Hj pmees. Currently, I am writing code to add and edit shape using shapeEditor. However, I have not used shapeEditor. Can you help me?. if you had an example about it. Can you give me. Thanks a lot

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 15, 2020, 11:56am UTC](https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236/5 "2020-01-15T11:56:59Z")

</div>

Sorry for the late reply.  
Are you still locked?

The example I was talking about is the link in my previous comment.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 3:08pm UTC](https://mapwindow.discourse.group/t/how-to-draw-interactively-a-line-on-a-layer/236/6 "2022-01-05T15:08:57Z")

</div>


