android绘制矢量图地图,绘制矢量图形-矢量图形-示例中心-JS API 2.0 示例 | 高德地图API...

html,

body,

#container {

width: 100%;

height: 100%;

}

椭圆的绘制和编辑
利用mouseTool绘制覆盖物

绘制线段

绘制多边形

绘制矩形

绘制圆形

var map = new AMap.Map("container", {

center: [116.434381, 39.898515],

zoom: 14

});

var mouseTool = new AMap.MouseTool(map)

function drawPolyline () {

mouseTool.polyline({

strokeColor: "#3366FF",

strokeOpacity: 1,

strokeWeight: 6,

// 线样式还支持 'dashed'

strokeStyle: "solid",

// strokeStyle是dashed时有效

// strokeDasharray: [10, 5],

})

}

function drawPolygon () {

mouseTool.polygon({

strokeColor: "#FF33FF",

strokeOpacity: 1,

strokeWeight: 6,

strokeOpacity: 0.2,

fillColor: '#1791fc',

fillOpacity: 0.4,

// 线样式还支持 'dashed'

strokeStyle: "solid",

// strokeStyle是dashed时有效

// strokeDasharray: [30,10],

})

}

function drawRectangle () {

mouseTool.rectangle({

strokeColor:'red',

strokeOpacity:0.5,

strokeWeight: 6,

fillColor:'blue',

fillOpacity:0.5,

// strokeStyle还支持 solid

strokeStyle: 'solid',

// strokeDasharray: [30,10],

})

}

function drawCircle () {

mouseTool.circle({

strokeColor: "#FF33FF",

strokeOpacity: 1,

strokeWeight: 6,

strokeOpacity: 0.2,

fillColor: '#1791fc',

fillOpacity: 0.4,

strokeStyle: 'solid',

// 线样式还支持 'dashed'

// strokeDasharray: [30,10],

})

}

mouseTool.on('draw', function(event) {

// event.obj 为绘制出来的覆盖物对象

log.info('覆盖物对象绘制完成')

})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 高德地图 API 提供了 `AMap.MouseTool` 类,可以用来绘制矢量图。下面是一个简单的示例: ``` <template> <div id="map-container" style="height: 500px;"></div> </template> <script> export default { data() { return { map: null, mouseTool: null }; }, mounted() { // 加载地图 this.map = new AMap.Map('map-container', { zoom: 13, // 缩放级别 center: [116.397428, 39.90923] // 地图中心点 }); // 创建 MouseTool 实例 this.mouseTool = new AMap.MouseTool(this.map); // 监听绘制事件 AMap.event.addListener(this.mouseTool, 'draw', e => { // 获取绘制矢量图对象 const shape = e.obj; // 在地图上显示矢量图 this.map.add(shape); }); }, methods: { // 开始绘制矢量图 startDraw(type) { this.mouseTool[type](); } } }; </script> ``` 在上面的示例中,我们首先创建了一个地图实例并将其渲染到页面上。然后,我们创建了一个 MouseTool 实例,并在绘制事件中获取绘制矢量图对象并将其添加到地图上。最后,我们提供了一个 `startDraw` 方法,用于开始绘制不同类型的矢量图。 可以通过调用 `startDraw` 方法来开始绘制矢量图。例如,要绘制一个圆,可以在模板中添加一个按钮并将其与 `startDraw` 方法关联: ``` <template> <div> <div id="map-container" style="height: 500px;"></div> <button @click="startDraw('circle')">绘制</button> </div> </template> ``` 这将在地图上启动圆绘制工具。其他可用的绘制工具包括 `rectangle`(矩)、`polygon`(多边)和 `polyline`(折线)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值