<template><div class="coordinate"><div class="toolbar"><div>坐标: [ {{ lng }} , {{ lat }} ]</div><div>地址: {{ address }}</div></div><div style="width: 100%;height: 300px;"><div id="coordinateMap" class="coordinateMap" /></div></div>
</template><script>
export default {name: 'MapDialog',props: {},data() {return {overlays: [],lng: '',lat: '',address: '',marker: '',geocoder: null,mouseTool: null}},created() {},mounted() {localStorage.clear()this.MapInit()},methods: {MapInit() {const that = thisthat.map = new AMap.Map('coordinateMap', {center: [113.274041, 23.141222],resizeEnable: true,expandZoomRange: true,zoom: 13,zooms: [3, 21]})that.drawBounds(that.map)// 异步同时加载多个插件AMap.plugin(['AMap.Scale'], function() {that.scale = new AMap.Scale()that.map.addControl(that.scale)})that.mouseTool = new AMap.MouseTool(that.map)// 监听draw事件可获取画好的覆盖物that.mouseTool.on('draw', function(e) {that.overlays.push(e.obj)that.mouseTool.close()})that.geocoder = new AMap.Geocoder({radius: 1000,extensions: 'all'})that.marker = new AMap.Marker()// 点击获取坐标const clickHandler = function(e) {that.lng = e.lnglat.getLng()that.lat = e.lnglat.getLat()const lnglat = [that.lng, that.lat]that.map.add(that.marker)that.marker.setPosition(lnglat)that.getAddress(that.lng, that.lat)}that.map.on('click', clickHandler)},// 获取地址getAddress(lng, lat) {const that = thisthat.geocoder.getAddress([lng, lat], function(status, result) {if (status === 'complete' && result.info === 'OK') {if (result && result.regeocode) {that.address = result.regeocode.formattedAddressthat.$nextTick()}}})},// 限制地图区域drawBounds(map) {const opts = {subdistrict: 0,extensions: 'all',level: 'city'}const district = new AMap.DistrictSearch(opts)district.setLevel('广州市')district.search('广州市', (status, result) => {const outer = [new AMap.LngLat(-360, 90, true),new AMap.LngLat(-360, -90, true),new AMap.LngLat(360, -90, true),new AMap.LngLat(360, 90, true)]const holes = result.districtList[0].boundariesconst pathArray = [outer]pathArray.push.apply(pathArray, holes)const polygon = new AMap.Polygon({pathL: pathArray,strokeColor: '#001826',strokeWeight: 1,strokeOpacity: 0.5,fillColor: '#ffffff',fillOpacity: 1,strokeStyle: 'dashed',strokeDasharray: [10, 2, 10]})polygon.setPath(pathArray)map.add(polygon)})},// 限制地图区域ENDclose() {this.mouseTool.close(true)},}
}
</script><style lang="scss" scoped>
.coordinate {width: 100%;height: 100%;.coordinateMap {width: 100%;height: 100%;}
}
</style>

vue 高德地图点击获取坐标与地理位置相关推荐

  1. 高德地图 点击获取坐标

    <link href="<?=Yii::getAlias('@resUrl/css/manage.css');?>" rel="stylesheet&q ...

  2. 高德地图点击获取经纬度并标记

    官网api: https://lbs.amap.com/api/javascript-api/summary 引入js: <script type="text/javascript&q ...

  3. vue高德地图点击放大Maker

    lizuncong (lizuncong) · GitHubI am a strong believer in reverse engineering. lizuncong has 42 reposi ...

  4. 自己收藏的高德地图批量标点获取坐标工具

    直接上代码!!! <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...

  5. 通过腾讯地图、高德地图、百度地图开发接口获取坐标对应的周边相关信息

    通过腾讯地图.高德地图.百度地图开发接口获取坐标对应的周边相关信息 更新: 以前出于好意暴露了个人的KEY,现已被烂用.为不影响您的业务,请使用我的KEY的朋友去申请自己的KEY,我的KEY将在不久后 ...

  6. vue+高德地图绘制路径

    一.vue+高德地图开发 最近开发项目地图用的比较频繁,比如高德地图.百度地图或者echars地图,而且大都是用来做路径展示,所以今天说说高德地图的使用(非全面的高德地图使用) 使用的是vue cli ...

  7. vue+高德地图实现多边形范围内标点

    vue+高德地图实现多边形范围内标点 具体实现: 一.安装并引入高德地图: 二.创建一个aMap地图文件: 三.aMap上创建多边形围栏: 四.配置围栏.地图点击事件: 五.地图点击标点事件: 本篇文 ...

  8. 大屏页面使用transform属性scale进行缩放,高德地图点击事件失效,地图展示模糊

    这里写自定义目录标题 大屏页面使用transform属性scale进行缩放,高德地图点击事件失效,地图展示模糊 1.大屏缩放自适应时使用tansform scale 缩放 1.1.window.res ...

  9. vue 给圆遮盖物添加文字 高德地图_通过 Vue + 高德地图 JS API 在地图上标记咖啡店...

    通过 Vue + 高德地图 JS API 在地图上标记咖啡店 由 学院君 创建于2年前, 最后更新于 2年前 版本号 #1 在上一篇教程中我们为咖啡店地址进行了地理编码,这样,就可以调用高德地图支持的 ...

最新文章

  1. java I/O
  2. svn教程----TortoiseSVN常用操作
  3. python之字符串的切片操作
  4. PMcaff-干货| 产品经理应该了解的服务设计那些事儿
  5. 启明云端分享|在使用sigmastar SSD201/SSD202D核心板时,应该注意的事项
  6. 【机器视觉】 halcon中图像获取
  7. ASCII中关于大小写字母间隔为32的思考
  8. spring boot 实现发送邮箱验证码
  9. 云HBase内核解析
  10. CUDA精进之路(三):图像处理——图像灰度化、灰度直方图统计
  11. H3C 单路径网络中环路产生过程(3)
  12. SpringBoot分页组件PageHelper介绍及使用
  13. Hbase 深度使用分析
  14. 深入理解设计模式-建造者模式(生成器模式)
  15. 小米手机计算机usb连接,小米5手机怎么连接电脑 USB调试方法教程
  16. java 函数 throw_java为什么有些异常throw出去需要在函数头用throws声明,一些就不用。...
  17. 【C++入门学习】——MainWindow
  18. Error starting stream. VIDIOC_STREAMON: Protocol error Unable to use mmap. Using read instead. Unabl
  19. 7-3 降价提醒机器人 (10 分)小 T 想买一个玩具很久了,但价格有些高,他打算等便宜些再买。但天天盯着购物网站很麻烦,请你帮小 T 写一个降价提醒机器人,当玩具的当前价格比他设定的价格便宜时发
  20. 简单配置让您的无线小路由变成无线交换机

热门文章

  1. 测开学习篇-html
  2. 等保安全计算环境之Windows(身份鉴别+访问控制)(二级)
  3. 程序员泪流满面的图片
  4. 语音助手(基于v3s开源啦)
  5. Deepin 20.5 安装nvidia驱动
  6. Deepin安装dotnet
  7. 速营社怎么赚钱,可以当副业吗
  8. 搞笑新闻联播之老公岗位制度(上)铃声 搞笑新闻联播之老公岗...
  9. imx6ul rtc 驱动修改
  10. Python练习:简单的登陆注册的信息管理;模块化;密码安全判断(没有用数据库和文件)