Monday 25 April 2016

openlayers - Change OL3 drawing cursor (blue circle)


i'm looking to change the cursor of ol3 during drawing from blue circle to crosshair, i've tried this answer, but it changes only OS cursor not ol3 cursor, is there any idea ?



Answer



You can use the Draw interaction's style property to change the default appeal of the cursor. To change the style, you have to provide all of the appropriate properties for the type of the drawn geometry (e.g. stroke, fill, image for polygon).


As you can see in this example, the ol.style.Icon does not work on the draw interaction. This might be a bug, I didn't check the source code. The other two image styles, ol.style.Circle and ol.style.RegularShape work like a charm.


Your best bet for now would be to use a regular shape, and create a star with 4 points, a big outer radius, and a very small inner radius. This way the resulting star could represent a crosshair.


PS: Other option would be not setting the image property of the interaction's style, just altering the browser's cursor over the map while the drawing interaction is active.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...