Rectangle Drawing service for creating and editing Rectangles.
You must provide RectanglesEditorService
yourself:
@Component({selector: 'my-map',templateUrl: './my-map.component.html',providers: [RectanglesEditorService],})export class MyMapComponent {}
<ac-map id="my-map"></ac-map>
The service is a part of AngularCesiumWidgetsModule
therefor you must import it.
RectanglesEditorService
works together with <rectangles-editor>
component. Therefor you need to create <rectangles-editor>
for each RectanglesEditorService
of course somewhere under <ac-map>
<ac-map id="my-map"><rectangles-editor></rectangles-editor></ac-map>​
Thats it! just Inject the service and use the create()
and edit()
methods:
@Component({...})export class MyMapComponent {editing$: RectangleEditorObserver;constructor(private rectangleEditor: RectanglesEditorService) {}startDraw() {this.editing$ = this.rectangleEditor.create();});}}
create(options?: RectangleEditOptions, priority?: number)
Start a creating a Rectangle over the map, Returns: RectangleEditorObservable
// Start creatingconst editing$ = rectangleEditor.create();this.editing$.subscribe(editResult => {console.log(editResult.positions);});
edit(positions: Cartesian3[], options: RectangleEditOptions, priority?: number)
Start editing a Rectangle over the map from a given positions, minimum 2 positions.
Returns: RectangleEditorObservable
const editing$ = this.rectangleEditor.edit(initialPositions);
The editor is fully customisable with RectangleEditOptions
:
addPointEvent
- Set Cesium event for adding last point, default: LEFT_CLICK
addPointModifier
- Set Cesium event modifier for adding point, default: none
dragPointModifier
- Set Cesium event modifier for draging a point, default: LEFT_DRAG
In edit mode only
dragPointModifier
- Set Cesium event modifier for removing a point, default: none
In edit mode only
rectangleProps
- Rectangle customisation properties
allowDrag
- allow shape drag, default: false
In edit mode only
pickConfiguration
- configure pick behaviour with: pick height and width and drill pick limit
setLabelsRenderFn
- receives a callback that is called every time the shape is redrawn (except when the shape is being dragged). The callback is called with the last shape state and with an array of the current labels.
The callback should return LabelProps[]