Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the common map events in Cesium development

Shulou Source: shulou.com Published: 2022-06-01 03:41:32 09月16日 Update

Editor to share with you what are commonly used map events in Cesium development, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

In map development, a series of events such as map movement and mouse operation will be used, while in the map package API, it will generally be provided.

Some corresponding events are used in Cesium development. Here are some commonly used events and their use.

Cesium camera movement end event, which is used in judging whether the map scene has been moved or not. After moving, the camera coordinates of the map or other coordinate information are obtained.

Viewer.scene.camera.moveEnd.addEventListener (function () {

/ / implement the corresponding mobile end operation

});

Mouse movement event, which determines the location of the mouse in the current map, obtains the coordinates of the mouse position, and can determine whether there are objects in the map at the current mouse.

Var handler = new Cesium.ScreenSpaceEventHandler (scene.canvas)

Handler.setInputAction (function (movement) {

/ / the end coordinates of the mouse movement, as well as the starting coordinates

Var pickedObject = scene.pick (movement.endPosition)

/ / determine whether there is an object at the current mouse

If (

Cesium.defined (pickedObject) & &

PickedObject.id instanceof Cesium.Entity

) {

/ / processing of entity objects

}, Cesium.ScreenSpaceEventType.MOUSE_MOVE)

/ / mouse click event. This is to determine the location of the data click.

Var handler.setInputAction (function (movement) {

/ / here is only the click position of the mouse.

Var pickedObject = scene.pick (movement.position)

If (

/ / it is also the object information at the place where the click is judged.

Cesium.defined (pickedObject) & &

PickedObject.id instanceof Cesium.Entity

) {

}

}, Cesium.ScreenSpaceEventType.LEFT_CLICK)

After the use is complete, remove unwanted events in the following ways. / / remove mouse click event

Handler.removeInputAction (

Cesium.ScreenSpaceEventType.LEFT_CLICK

);

/ / remove mouse movement event

Handler.removeInputAction (

Cesium.ScreenSpaceEventType.MOUSE_MOVE

);

The following is the real-time rendering event of the Cesium scene, which is executed at short intervals, which can determine some real-time objects in the scene.

Viewer.scene.preRender.addEventListener (function () {

});

Others, such as mouse wheel events, mouse press or lift events, can be found and used in Cesium's API documentation. These are all the contents of the article "what are the common map events in Cesium development?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Event mouse map movement coordinates object development location scene article Zhong Chang information content real-time location camera not much only at the same time most Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker Linux Redmi macOS