Circle Editor

Circle Drawing service for creating and editing Circles.

Usage:

You must provide CirclesEditorService yourself:

my-map.component.ts
my-map.component.html
my-map.component.ts
@Component({
selector: 'my-map',
templateUrl: './my-map.component.html',
providers: [CirclesEditorService],
})
export class MyMapComponent {}
my-map.component.html
<ac-map id="my-map"></ac-map>

The service is a part of AngularCesiumWidgetsModule therefor you must import it.

CirclesEditorService works together with <circles-editor> component. Therefor you need to create <circles-editor>for each CirclesEditorService of course somewhere under <ac-map>

<ac-map id="my-map">
<circles-editor></circles-editor>
</ac-map>

Thats it! just Inject the service and use the create() and edit() methods:

@Component({...})
export class MyMapComponent {
editing$: CirclesEditorObserver;
constructor(private circleEditor: CirclesEditorService) {}
startDraw() {
this.editing$ = this.circleEditor.create();
// Or Edit from existing points
const center = Cesium.Cartesian3.fromDegrees(-70, 0);
this.editing$ = this.circlesEditor.edit(center, 800000);
});
}
}

Api

  • create(options?: CircleEditOptions, priority?: number)

Start a creating a Circle over the map, Returns: CircleEditorObservable

// Start creating
const editing$ = circleEditor.create();
this.editing$.subscribe(editResult => {
console.log(editResult.positions);
});
  • edit(center: Cartesian3, radius: number, options?: CircleEditOptions, priority?: number)

Start editing a Circle over the map from a given positions, Returns: CircleEditorObservable

const editing$ = this.circleEditor.edit(initialCenterPos, 800000, 20, 400000);
  • The editor is fully customisable with CircleEditOptions :

    • 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

    • circleProps - Circle 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[]

Example