| | |
| | | |
| | | export function useMouseTool () { |
| | | const root = getRoot() |
| | | const AMap = root.$aMapObj |
| | | |
| | | const state = reactive({ |
| | | pinNum: 0, |
| | | polylineNum: 0, |
| | | PolygonNum: 0, |
| | | currentType: '', |
| | | }) |
| | | |
| | | function drawPin (type:MapDoodleType, getDrawCallback:Function) { |
| | | root?.$mouseTool.marker({ |
| | | title: type + state.pinNum, |
| | |
| | | state.pinNum++ |
| | | root?.$mouseTool.on('draw', getDrawCallback) |
| | | } |
| | | |
| | | function drawPolyline (type:MapDoodleType, getDrawCallback:Function) { |
| | | root?.$mouseTool.polyline({ |
| | | strokeColor: '#2d8cf0', |
| | |
| | | }) |
| | | root?.$mouseTool.on('draw', getDrawCallback) |
| | | } |
| | | |
| | | function drawPolygon (type:MapDoodleType, getDrawCallback:Function) { |
| | | root?.$mouseTool.polygon({ |
| | | strokeColor: '#2d8cf0', |
| | |
| | | }) |
| | | root?.$mouseTool.on('draw', getDrawCallback) |
| | | } |
| | | |
| | | function drawOff (type:MapDoodleType) { |
| | | root?.$mouseTool.close() |
| | | root?.$mouseTool.off('draw') |
| | | } |
| | | |
| | | function mouseTool (type: MapDoodleType, getDrawCallback: Function) { |
| | | state.currentType = type |
| | | switch (type) { |
| | |
| | | break |
| | | } |
| | | } |
| | | |
| | | return { |
| | | mouseTool |
| | | } |