mstahv / v-leaflet

Leaflet add-on for Vaadin
Other
43 stars 38 forks source link

impossible to change mouse cursor? #188

Open moovida opened 6 years ago

moovida commented 6 years ago

I am not sure if this is ok as issue, maybe more a feature request.

I need to change the cursor to crosshair to make the user pick informations on a tiles layer. Teh logic is handled ok by the onClick listener.

I have tried many css things at vaadin and component and window and whatever level, but I have not been able to change the mouse cursor in the map window.

Is there such a possibility?

(tested with vaadin 8)

mstahv commented 6 years ago

This is possible with some CSS today:

VAADIN/customstyles.css:

.v-leaflet.crosshair .leaflet-grab {
    cursor:crosshair;
}

Following annotation to your UI/map component:

@StyleSheet("vaadin://customstyles.css")

And in you Java code if you want to enable the crosshair (or whatever cursor) for the time your click listener is valid:

            map.addStyleName("crosshair");
            mapClickListener = map.addClickListener(e-> {
                    // do your thing

                    // remove listener and crosshair style name
                    mapClickListener.remove();
                    map.removeStyleName("crosshair");
                }
            });

That's pretty easy for me and those who are comfortable with CSS, but I guess a Java API would be nice for most v-leaflet users. Which cursors should be supported?

aybond commented 6 years ago

Hello there.

@mstahv, it would be nice to support at least these type of cursors:

Regards.

moovida commented 5 years ago

I agree that a Java API would be amazing for the non-CSS champs as myself :-)