Change map cursor

Hi,

Is there a way to change the mouse pointer when hovering over an entity?

Eg: on Google Maps and Esri, if you hover over the marker the mouse pointer changes.

Thanks,
Gowtham.

Hello,

You can use a ScreenSpaceEventHander to detect if you are hovering over an entity on mouse move, and use CSS to change the cursor style to pointer.

Here is a code example:

var element = document.getElementById(‘cesiumContainer’);
var viewer = new Cesium.Viewer(‘cesiumContainer’);

var scene = viewer.scene;
var handler;

var entity = viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
billboard : {
image : ‘…/images/Cesium_Logo_overlay.png’
}
});

// If the mouse is over the billboard, change its scale and color
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var pickedObject = scene.pick(movement.endPosition);
if (Cesium.defined(pickedObject)) {
element.style.cursor = ‘pointer’;
} else {
element.style.cursor = ‘default’;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);

``

Best,

Hannah

Thanks Hannah.