Color change hoover GeoJSON

Hi to everyone
I´m new in cesium.
I would like to change the color of a GeoJSON when the mouse hoover it.
I´ve seen a lot of examples, but it´s different when you are loading a GeoJSON.

I would like to get something like this:

Can someone help me?
Thanks

Hi Kevyn,

Please try this:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {
timeline : false,
animation : false,
selectionIndicator : false
});
var scene = viewer.scene;

var pinBuilder = new Cesium.PinBuilder();
var handler;
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var pickedObject = scene.pick(movement.endPosition);
if (Cesium.defined(pickedObject) && (pickedObject.id === questionPin)) {
questionPin.billboard.scale = 1.0;
questionPin.billboard.color = Cesium.Color.RED;
} else {
questionPin.billboard.scale = 1.0;
questionPin.billboard.color = Cesium.Color.WHITE;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
var questionPin = viewer.entities.add({
name : “Name comes here”,
description: “Description”,

                    position : Cesium.Cartesian3.fromDegrees(-75.170726, 39.9208667),
                    billboard : {
                        show : true,
                         
                        image : pinBuilder.fromText('some text', Cesium.Color.ROYALBLUE, 38).toDataURL(),
                        verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
                        horizontalOrigin : Cesium.HorizontalOrigin.BOTTOM
                    },
                 });
                 viewer.entities.add(pinBuilder);

Thanks,
Kulvinder

1 Like

Thanks for your answer.
Can you tell me where I have to add the name of GeoJSON?
I’d load in this way:
var promise = Cesium.IonResource.fromAssetId(90479)
.then(function (resource) {
return Cesium.GeoJsonDataSource.load(resource);
})
.then(function (dataSource) {
return viewer.dataSources.add(dataSource);
})
.then(function (dataSource) {
return viewer.zoomTo(dataSource);
})
.otherwise(function (error) {
console.log(error);
});

Thanks a lot!
The GeoJSON has polygons.

Hi,

Have you check this https://sandcastle.cesium.com/?src=Custom%20DataSource.html

1 Like

Thanks for your answer.
But I could’n get my goal.
The code you show in the first answer, works really fine, but I can’t apply it to my GeoJSON.
Can you tell me how can I do that?
Thanks a lot