Remove default double click behavior in Cesium

Cesium allows us to easily zoom and track an entity, by double clicking on that entity.

But sometimes you wouldn’t necessarily want that behavior, as double clicking is a very common UI ability.

There are 2 easy ways to remove/disable this default behavior:

  1. Remove the original event handler from the Cesium Widget ScreenSpaceEventHandler:
  2. Another, probably less intrusive way, is to add an additional event handler to our own ScreenSpaceEventHandler, which will set the Viewer’s trackedEntity to undefined:
    var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
    handler.setInputAction(function(movement) {
        viewer.trackedEntity = undefined;
    }, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);

One thought on “Remove default double click behavior in Cesium

Leave a Reply