mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

Draw cursor not set to "crosshair" if default cursor of map is set to "default" or "pointer"

Open dev-aritra opened this issue 6 years ago • 3 comments

Draw cursor not set to "crosshair" if default cursor of map is set to "default" ,"pointer" or anything else maybe.

The draw cursor is set to "crosshair" only when the cursor style is not explicitly set.

For example if I do map.getCanvas().style.cursor = "default" The draw cursor is also set to "default"

But if I just remove the above-mentioned line, the draw cursor is set to "crosshair" upon selecting a draw mode.

mapbox-gl-js 1.0.0: mapbox-gl-draw 1.1.2:

Steps to Trigger Behavior

  1. Set map cursor to anything explicitly, for example map.getCanvas().style.cursor = "default"
  2. Select a shape to draw
  3. See the cursor to be set as "default" instead of "crosshair"

Expected Behavior

Cursor is to be set to crosshair when a draw mode is selected.

Actual Behavior

Cursor is not set to crosshair when a draw mode is selected.

dev-aritra avatar Jul 29 '19 06:07 dev-aritra

I'm not sure I understand this issue. It seems like you're explicitly forcing the cursor to be something else, but then you expect that the cursor still changes? Could you just remove the line that sets the cursor explicitly?

kkaefer avatar Jan 07 '20 13:01 kkaefer

map.getCanvas().style.cursor = "unset";

Sultan-Alrefaei avatar Apr 05 '20 17:04 Sultan-Alrefaei

I had the same problem. It's not as easy as "do not set the cursor then" as the other answers here suggest. Instead of:

map.getCanvas().style.cursor = 'default'

You should override the cursor with CSS:

.mapboxgl-canvas-container.mapboxgl-interactive,
.mapboxgl-canvas-container.mapboxgl-interactive:active {
    cursor: default;
}

This way you can override the default cursor and have the correct drawing cursors.

palhal avatar Feb 07 '22 08:02 palhal