Cmen
3 years ago
8 changed files with 135 additions and 19 deletions
@ -1,11 +1,23 @@ |
|||||||
import { OverlayTypes } from "@types"; |
import { OverlayTypes } from "@types"; |
||||||
|
import { IOverlay } from "@store"; |
||||||
import { BaseOverlayEditor } from "./BaseOverlayEditor"; |
import { BaseOverlayEditor } from "./BaseOverlayEditor"; |
||||||
|
|
||||||
export class CircleEditor extends BaseOverlayEditor<AMap.CircleEditor> { |
export class CircleEditor extends BaseOverlayEditor<AMap.CircleEditor> { |
||||||
getType(): OverlayTypes { |
|
||||||
return OverlayTypes.Circle; |
|
||||||
} |
|
||||||
initEditor(map: AMap.Map) { |
initEditor(map: AMap.Map) { |
||||||
return new AMap.CircleEditor(this.map); |
return new AMap.CircleEditor(this.map); |
||||||
} |
} |
||||||
|
|
||||||
|
build(circle: IOverlay): AMap.MapOverlay { |
||||||
|
const { lngLat, radius } = circle; |
||||||
|
const [lng, lat] = lngLat!; |
||||||
|
const circleOverlay = new AMap.Circle({ |
||||||
|
center: new AMap.LngLat(lng, lat), |
||||||
|
radius: radius!, |
||||||
|
}); |
||||||
|
return circleOverlay; |
||||||
|
} |
||||||
|
|
||||||
|
getType(): OverlayTypes { |
||||||
|
return OverlayTypes.Circle; |
||||||
|
} |
||||||
} |
} |
||||||
|
@ -1,11 +1,21 @@ |
|||||||
import { OverlayTypes } from "@types"; |
import { OverlayTypes } from "@types"; |
||||||
|
import { IOverlay } from "../../store/type"; |
||||||
import { BaseOverlayEditor } from "./BaseOverlayEditor"; |
import { BaseOverlayEditor } from "./BaseOverlayEditor"; |
||||||
|
|
||||||
export class PolygonEditor extends BaseOverlayEditor<AMap.PolygonEditor> { |
export class PolygonEditor extends BaseOverlayEditor<AMap.PolygonEditor> { |
||||||
getType(): OverlayTypes { |
|
||||||
return OverlayTypes.Polygon; |
|
||||||
} |
|
||||||
initEditor(map: AMap.Map) { |
initEditor(map: AMap.Map) { |
||||||
return new AMap.PolygonEditor(map); |
return new AMap.PolygonEditor(map); |
||||||
} |
} |
||||||
|
|
||||||
|
build(polygon: IOverlay): AMap.MapOverlay { |
||||||
|
const { path } = polygon; |
||||||
|
const polygonOverlay = new AMap.Polygon({ |
||||||
|
path: (path || []).map(([lng, lat]) => new AMap.LngLat(lng, lat)), |
||||||
|
}); |
||||||
|
return polygonOverlay; |
||||||
|
} |
||||||
|
|
||||||
|
getType(): OverlayTypes { |
||||||
|
return OverlayTypes.Polygon; |
||||||
|
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue