2

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 ?

  • My Draw interaction doesn't have a style property. Why is this? – user70817 Apr 7 '16 at 18:13
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – AndreJ Apr 7 '16 at 18:33
3

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.

0

As for the ol.style.Icon you need to specify the correct size of the linked image in order to see the whole part of it. At the same time you can use the scale property to downsample the original image. As in this example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.