Disable right click zoom

I am trying to make a simple context menu to be used when you right click in Cesium and wish to disable the right click zoom (but keep mouse wheel zoom). How would I go about this?

The following appear to have no effect:

viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);
            viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_DOWN);
            viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_UP);

I’ve noticed this before but we apparently don’t have an issue on it. The only way to disable zoom right now would be with the following line of code.

viewer.scene.screenSpaceCameraController.enableZoom = false;

I agree with you that instead of this separate variable, the default screen space event handlers should just expose the mapping. I’ll write up an issue on this so we revisit it in the future.

Dang, so it's basically all or nothing then? I can't keep mouse wheel and lose the right click zoom?

Give this a try:

var screenSpaceEventHandler = viewer.screenSpaceEventHandler;

screenSpaceEventHandler.setInputAction(function(){

viewer.scene.screenSpaceCameraController.enableZoom = false;

}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);

screenSpaceEventHandler.setInputAction(function(){

viewer.scene.screenSpaceCameraController.enableZoom = true;

}, Cesium.ScreenSpaceEventType.RIGHT_UP);

The screenSpaceEventHandler does expose the mappings on the zoomEventTypes property. The default is [CameraEventType.RIGHT_DRAG, CameraEventType.WHEEL, CameraEventType.PINCH]. You can set it to an array without CameraEventType.RIGHT_DRAG or, if you aren’t using, a touch interface, use:

Give this a try:

var screenSpaceEventHandler = viewer.screenSpaceEventHandler;

screenSpaceEventHandler.setInputAction(function(){

viewer.scene.screenSpaceCameraController.enableZoom = false;

}, Cesium.ScreenSpaceEventType.RIGHT_DOWN);

screenSpaceEventHandler.setInputAction(function(){

viewer.scene.screenSpaceCameraController.enableZoom = true;

}, Cesium.ScreenSpaceEventType.RIGHT_UP);

Dang, so it’s basically all or nothing then? I can’t keep mouse wheel and lose the right click zoom?

I’ve noticed this before but we apparently don’t have an issue on it. The only way to disable zoom right now would be with the following line of code.

    viewer.scene.screenSpaceCameraController.enableZoom = false;

I agree with you that instead of this separate variable, the default screen space event handlers should just expose the mapping. I’ll write up an issue on this so we revisit it in the future.

I am trying to make a simple context menu to be used when you right click in Cesium and wish to disable the right click zoom (but keep mouse wheel zoom). How would I go about this?

The following appear to have no effect:

viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK);

        viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_DOWN);
        viewer.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_UP);

You received this message because you are subscribed to the Google Groups “cesium-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

You received this message because you are subscribed to the Google Groups “cesium-dev” group.

To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

viewer.screenSpaceEventHandler.zoomEventTypes = CameraEventType.WHEEL;

Thanks Dan, I had no idea that existed. The property is actually on the controller, not the handler. So the final code would be:

viewer.scene.screenSpaceCameraController.zoomEventTypes = Cesium.CameraEventType.WHEEL;

Legendary, thanks guys!

That does exactly what I wanted.