Name | Type | Description |
---|---|---|
viewer |
Viewer | The Cesium Viewer instance. |
options |
DraggableEntities.Options | optional Configuration options for the drag and drop handler. |
Examples:
// Make a single entity draggable
const handler = new DraggableEntities(viewer, {
entities: singleEntity,
dragDelay: 200,
onDrag: function(context) {
console.log('Drag started at', context.screenPosition);
},
onDragging: function(context) {
console.log('Dragging at', context.screenPosition);
},
onDrop: function(context) {
console.log('Dropped at', context.screenPosition);
}
});
// Make multiple entities draggable
const handler = new DraggableEntities(viewer, {
entities: [entity1, entity2, entity3],
onDrag: function(context) { /* ... *\/ },
onDragging: function(context) { /* ... *\/ },
onDrop: function(context) { /* ... *\/ }
});
// Make all entities in a collection draggable
const collection = new Cesium.EntityCollection();
// Add entities to the collection
const handler = new DraggableEntities(viewer, {
entities: collection,
onDrag: function(context) { /* ... *\/ },
onDragging: function(context) { /* ... *\/ },
onDrop: function(context) { /* ... *\/ }
});
Members
_callbackProperty : CallbackProperty
_ellipsoid : Ellipsoid|undefined
_entity : Entity|undefined
_handler : ScreenSpaceEventHandler|undefined
_initialPositionCartesian : Cartesian3|undefined
_initialScreenPosition : Cartesian2|undefined
_position : Cartesian3|undefined
Check if the handler is active.
Check if dragging is currently active.
Methods
static Cesium.DraggableEntities.enlargeEllipsoid(e, m) → Ellipsoid
Enlarge an ellipsoid by a given amount.
Name | Type | Description |
---|---|---|
e |
Ellipsoid | The original ellipsoid. |
m |
number | The amount to enlarge each radius. |
Returns:
The enlarged ellipsoid.
_convertCartesian2ToPosition(position) → Cartesian3|undefined
Convert a screen position to a Cartesian3 position based on the dragMode.
Name | Type | Description |
---|---|---|
position |
Cartesian2 | The screen position. |
Returns:
The Cartesian3 position or undefined.
_createContext(position, screenPosition) → DraggableEntities.Context|undefined
Create a context object for the current drag/drop operation.
Name | Type | Description |
---|---|---|
position |
Cartesian3 | undefined | The current position. |
screenPosition |
Cartesian2 | The current screen position. |
Returns:
The context object or undefined.
Handle the drag start event.
Name | Type | Description |
---|---|---|
e |
Object | The event object containing the position. |
Handle the dragging event.
Name | Type | Description |
---|---|---|
e |
Object | The event object containing start and end positions. |
Handle the drop event.
Name | Type | Description |
---|---|---|
e |
Object | The event object containing the position. |
_pick(position) → Entity|undefined
Pick a draggable entity at the given screen position.
Name | Type | Description |
---|---|---|
position |
Cartesian2 | The screen position to pick. |
Returns:
The picked entity or undefined.
_resetHeight(position) → Cartesian3|undefined
Reset the height of the position based on the initial height.
Name | Type | Description |
---|---|---|
position |
Cartesian3 | undefined | The position to reset. |
Returns:
The position with reset height or the original position.
Cancel the current dragging operation.
Disable the drag and drop functionality.
Enable the drag and drop functionality.
Type Definitions
Context object used during drag and drop operations.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
position |
Cartesian3 |
<optional> |
The current position in Cartesian3 coordinates. |
screenPosition |
Cartesian2 | The current screen position. | |
initialPositionCartesian |
Cartesian3 |
<optional> |
The initial position in Cartesian3 coordinates. |
initialScreenPosition |
Cartesian2 | The initial screen position. |
Options for configuring the DragDropHandler.
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
initialDisabled |
boolean |
<optional> |
false | If `true`, prevents drag and drop from being automatically enabled. |
dragMode |
'2D' | '3D' |
<optional> |
'2D' | The dragging mode. Use '2D' for camera.pickEllipsoid or '3D' for scene.pickPosition. |
dragDelay |
number |
<optional> |
0 | The number of milliseconds to wait before starting the drag. |
dragInputType |
ScreenSpaceEventType |
<optional> |
ScreenSpaceEventType.LEFT_DOWN | The event type to initiate dragging. |
draggingInputType |
ScreenSpaceEventType |
<optional> |
ScreenSpaceEventType.MOUSE_MOVE | The event type during dragging. |
dropInputType |
ScreenSpaceEventType |
<optional> |
ScreenSpaceEventType.LEFT_UP | The event type to drop. |
onDrag |
function |
<optional> |
Callback invoked when dragging starts. Receives a single `Context` object. | |
onDragging |
function |
<optional> |
Callback invoked during dragging. Receives a single `Context` object. | |
onDrop |
function |
<optional> |
Callback invoked when dragging ends (drop). Receives a single `Context` object. | |
entities |
Entity | Array.<Entity> | EntityCollection |
<optional> |
The entity or entities to make draggable. If not specified, all entities in the viewer's default collection are draggable. |