ghettovoice / vuelayers

Web map Vue components with the power of OpenLayers
https://vuelayers.github.io/
MIT License
682 stars 230 forks source link

Triggering a drawstart/drawened event without clicking on a map #465

Closed HrvojeCosic closed 2 years ago

HrvojeCosic commented 2 years ago

Hello, I'm trying to find a way to trigger interaction-draw's listeners drawstart and drawend with javascript, in order to allow users to simulate clicks on a map using the button instead of clicking on the map directly

I tried using olObject's startDrawing function, however, it requires an event object which is not available doing it this way(?). It doesn't seem like a very clean way to do this either.

I'd have an access to coordinates where on the map the click happened, type of the shape (polygon, linestring etc.), perhaps other things if needed. If this is not enough info for you to understand what I'm trying to achieve, let me know!

HrvojeCosic commented 2 years ago

In the end I couldn't find a way to do this through vuelayers so I went with creating a new Openlayer's Vector, giving it feature with the geometry that was gathered and adding that vector/layer to the map using maps' addLayer method, and going from there.