【vue | 您所在的位置:网站首页 › 百度地图绘制多边形标题设置 › 【vue |
点击获取坐标集
官网链接:Vue Baidu Map 需求 1. 绘制多边形 ![]() 实现 第一步:设置打开弹窗的地方 坐标集第二步:设置初始值 data() { return { center: { lng: 118.83, lat: 31.95 }, zoom: 13, dialogVisible: false, polygonPath: [] } }第三步:打开弹窗,将中心点清空,如果是编辑状态赋值坐标点 clickAddress() { this.dialogVisible = true; this.polygonPath = this.form.latLng.length > 0 ? this.form.latLng : [] },第四步:设置弹窗 getClickInfo 获取当前点击的经纬度,赋值点给polygonPath。并且将所有经纬度显示出来 设置多边形 经纬度: {{item.lng}},{{item.lat}} 取 消 确 定 handler({ BMap, map }) { console.log(BMap, map); }, getClickInfo(e) { this.polygonPath.push({lng: e.point.lng, lat: e.point.lat}) }, updatePolygonPath (e) { this.polygonPath = e.target.getPath() },第五步:取消就直接关闭弹窗,如果确定就将弹窗中的经纬度赋值给表单中的form.latLng dialogCancel() { this.dialogVisible = false; }, dialogSubmit() { this.form.latLng = this.polygonPath this.dialogVisible = false; } |
CopyRight 2018-2019 实验室设备网 版权所有 |