Hi all, I’m trying to follow after a map coordinates I’ve imported from geoServer to Cesium on the general globe,
I’ve found the pickedPostion method but seems it doesn’t work for me very well…
so far I’m getting by the console this message:
here is the code example:
import * as Cesium from "cesium";
import "cesium/Source/Widgets/widgets.css";
import "./DrawHelper.css";
import "./moreStyle.css";
import DrawHelper from "./DrawHelper";
const {
defaultAccessToken,
layersFromGeoServer,
baseLayersFromGeoServer,
tilesetFromGeoServer,
} = window["runConfig"];
class MapManager {
constructor() {
this._Viewer;
this._drawHelper;
this._scene;
this.ellipsoid;
this._homeLocation;
this._contaner;
this._entities;
this._initializeCesium();
}
_initializeCesium() {
Cesium.Ion.defaultAccessToken = defaultAccessToken;
var layer = this.createWebMapServiceImageryProvider({
url: baseLayersFromGeoServer.url,
layers: baseLayersFromGeoServer.name,
});
this._Viewer = new Cesium.Viewer("cesiumContaner", {
//sceneMode: Cesium.SceneMode.COLUMBUS_VIEW, // Make the worldmap 2D
terrainProvider: Cesium.createWorldTerrain(),
scene3DOnly: false, //new
imageryProvider: layer, //
baseLayerPicker: false,
geocoder: true,
timeline: true,
infoBox: true,
navigationHelpButton: false,
shouldAnimate: false,
animation: false,
});
this._drawHelper = new DrawHelper(this._Viewer);
this._scene = this._Viewer.scene;
this._entities = this._Viewer.entities;
var handler = new Cesium.ScreenSpaceEventHandler(this._Viewer.canvas);
handler.setInputAction(function (event) {
console.log(event.position);
var pickedPosition = this._scene.pickPosition(event.position);
console.log(Cesium.defined(pickedPosition));
console.log(pickedPosition);
// if (Cesium.defined(pickedPosition)) {
// console.log(pickedPosition);
// }
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);