/*This is my current code*/
var viewer = new Cesium.Viewer('cesiumContainer');
var highlightedEntity;
var highlightColor = Cesium.Color.YELLOW.withAlpha(0.6);
var normalColor = Cesium.Color.SLATEGREY.withAlpha(0.6);
//A property that returns a highlight color if the entity is currently moused over, or a default color otherwise.
function createCallback(entity){
var colorProperty = new Cesium.CallbackProperty(function(time, result){
if(highlightedEntity === entity){
return Cesium.Color.clone(highlightColor, result);
}
return Cesium.Color.clone(normalColor, result);
}, false);
return new Cesium.ColorMaterialProperty(colorProperty);
}
var promise = Cesium.GeoJsonDataSource.load('../../SampleData/ne_10m_admin_0_countries2.json');
promise.then(function(dataSource) {
viewer.dataSources.add(dataSource);
//Get the array of entities
var entities = dataSource.entities.values;
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
entity.polygon.material = createCallback(entity);
}
}).otherwise(function(error){
//Display any errrors encountered while loading.
window.alert(error);
});
var scene = viewer.scene;
var handler = viewer.screenSpaceEventHandler;
handler.setInputAction(function(movement) {
var pickedObject = scene.pick(movement.endPosition);
if (Cesium.defined(pickedObject) && pickedObject.id instanceof Cesium.Entity) {
highlightedEntity = pickedObject.id;
} else{
highlightedEntity = undefined;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
- I want to highlight the country when hovering over the county and appears the country name also.
- I need to load all countries JSON File in GeoJsonDataSource.load.How can I get this source file? Can you please provide the all counties JSON file?
- I have downloaded the ne_10m_admin_0_countries2.json file from forums support but I am getting the below error in console.