useEffect(() => {
if (cesiumViewer.current && selectedCountry) {
var geocoderService = new CesiumJs.IonGeocoderService({
scene: cesiumViewer.current.scene,
});
geocoderService.geocode(selectedCountry.split("-")[0]).then(function (result) {
if (CesiumJs.defined(result) && CesiumJs.defined(result[0])) {
if (cesiumViewer.current && selectedCountry) {
console.log(result[0].destination);
cesiumViewer.current.camera.flyTo({
destination: result[0].destination,
});
}
}
});
}
}, [selectedCountry]);
You can see this solution