Openlayers 4: mouse click to draw a point, make mouse stick to the screen and causes the drag of the map

Asked

Viewed 46 times

0

Hello, I am studying the development of a map with the help of Openlayers 4, watching video lessons, I am at the stage where I created a routine with 3 buttons (Pan, Draw, Erase) to draw on the map. However, when I click the Draw button, to create a Point type Feature, instead of the click, the cursor sticks to the map, as if I had double-clicking to start the Drag-and-drop function. Only I just clicked, wanting to put the point there. Does anyone know why this is happening?.

1 answer

0

Look, I got the solution! It is that I was looking at a code in a tutorial that used only ol.interaction.Draw, with the event nameDraw.on('drawend', Function(e){ ... etc. Well, in the official documentation of Openlayers.org, there is an example that satisfied my research, where the Snap method is used: var snap = new ol.interaction.Snap({source:source}). And after this method is applied, again, the map.addInteraction(snap) command. And it seems that this is more current for version 4. Works great now. Grateful to those who took an interest.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.