index.html
<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.6&key=8692185c8954a7ed79ea5b6dabd7d8ba&plugin=AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocoder"></script>
a.vue

<el-input v-model="city" auto-complete="off" id="tipinput" @input='clear'></el-input>
<div class="map" style="width:1300px; height:500px">
  <div id="container" style="width:1300px; height:500px"></div>
</div>
  mounted() {
    this.maps();
  }
 
methods:{
clear() {
this.lng = ''
this.lat = ''
},
maps() {
//地图加载
let that = this;
this.map = new AMap.Map("container", {
resizeEnable: true,
zoom: 10
});
// 添加左上角缩放控件
AMap.plugin(["AMap.ToolBar"], function () {
that.map.addControl(new AMap.ToolBar());
});
//输入提示
var autoOptions = {
input: "tipinput"
};
var auto = new AMap.Autocomplete(autoOptions);
var placeSearch = new AMap.PlaceSearch({
map: this.map
}); //构造地点查询类
placeSearch.search(this.city1); //默认查询广州
AMap.event.addListener(auto, "select", select); //注册监听,当选中某条记录时会触发
function select(e) {
placeSearch.setCity(e.poi.adcode);
placeSearch.search(e.poi.name); //关键字查询查询
that.lat = e.poi.location.lat; //经度
that.lng = e.poi.location.lng; //纬度
that.selectAdree(); //经纬度转为中文,实时保持名称与经纬度一致
}
this.clickMap();
},
clickMap() {
// 点击地图获取经纬度与名称,并标点
let that = this;
//为地图注册click事件获取鼠标点击出的经纬度坐标
var clickEventListener = this.map.on("click", function (e) {
that.lng = e.lnglat.getLng();
that.lat = e.lnglat.getLat();
that.selectAdree();
});
},
selectAdree() {
// 经纬度转为中文
let that = this;
var lnglatXY = [that.lng, that.lat]; //已知点坐标
regeocoder(); function regeocoder() {
//逆地理编码
var geocoder = new AMap.Geocoder({
radius: 1000,
extensions: "all"
});
geocoder.getAddress(lnglatXY, function (status, result) {
if (status === "complete" && result.info === "OK") {
geocoder_CallBack(result);
}
});
// 删除现有的点
if (that.marker) {
that.marker.setMap(null);
that.marker = null;
}
that.marker = new AMap.Marker({
//加点
map: that.map,
position: lnglatXY
});
that.map.setFitView();
} function geocoder_CallBack(data) {
var address = data.regeocode.formattedAddress; //返回地址描述
that.city = address;
}
},
}

vue 高德地图的更多相关文章

  1. vue 高德地图之玩转周边

    前言:在之前的博客中,有成功引入高德地图,这是以前的地址  vue 调用高德地图. 因为一些需求,需要使用到地图的周边功能. 完整的项目代码请查看  我的github 一 .先看要实现的结果,参考了链 ...

  2. VUE 高德地图选取地址组件开发

    高德地图文档地址 http://lbs.amap.com/api/lightmap/guide/picker/ 结合步骤: 1.通过iframe内嵌引入高德地图组件 key就选你自己申请的key &l ...

  3. Vue 高德地图 路径规划 画点

    CDN 方式 <!--引入高德地图JSAPI --> <script src="//webapi.amap.com/maps?v=1.4.13&key=您申请的ke ...

  4. js/vue 高德地图绘制驾车路线图

    地图容器: // css要给此容器设置宽高 <div class="map_container"></div> 画图 data{ return { Clng ...

  5. vue 高德地图使用 vue-amap

    此插件文档及使用还不错 https://elemefe.github.io/vue-amap/ <template> <div class="amap-page-conta ...

  6. vue 调用高德地图

    一. vue-amap,一个基于 Vue 2.x 和高德地图的地图组件 https://elemefe.github.io/vue-amap/#/ 这个就不细说了,按照其文档,就能够安装下来. 二. ...

  7. 基于vue 2.X和高德地图的vue-amap组件获取经纬度

    今天我就讲了一下怎么通过vue和高德地图开发的vue-amap组件来获取经纬度. 这是vue-amap的官网文档:https://elemefe.github.io/vue-amap/#/ 这是我的码 ...

  8. vue中使用vue-amap(高德地图)

    因为项目要求调用高德地图,就按照官方文档按部就班的捣鼓,这一路上出了不少问题. 前言: vue-cli,node环境什么的自己安装设置推荐一个博客:https://blog.csdn.net/wula ...

  9. vue调用高德地图:vue-amap

    前言:之前没有接触过页面调用地图的项目,某次面试,老板要求我用vue-amap调用高德地图,回家以后,我去网上查了一些案例和教程,看似很简单的引入调用,我却整整弄了一宿,还没弄出来!!!百般无奈之下, ...

随机推荐

  1. 06 Windows编程——设备句柄 和 WM_PAINT消息

    windows程序在现实方式上属于图形方式,和文字方式的显示,有显著的不同. 什么是设备句柄,如何获取 使用统一的数据结构表示某一设备,这个结构就是设备句柄. 源码 #include<Windo ...

  2. bloomberg bulkfile 在oracle的存储

    文章导航 bloomberg bulkfile 解析 bloomberg bulkfile 在oracle的存储 一 表名和字段名称的命名规则 1.1. 表名以文件名称直接命名,将文件名中的" ...

  3. mysql中对表操作----为所有列插入数据

         为所有列插入数据 通常情况下,向数据表中插入数据应包含表中所有字段,也就是为表中所有字段添加数据,为表中所有字段添加数据有以下两种方式. 1.INSERT语句中指定所有字段名 使用INSER ...

  4. Python+request 登录接口reponse的返回值token跨py文件的传递《二》

    主要使用场景: 一般我们在进行接口测试时,依赖登录接口后reponse中的某些返回值,因此需要将login接口单独写一个py文件,另外的py文件均可调用login的reponse返回值使用.共用登录接 ...

  5. c语言1博客作业09

    一.本周作业头 这个作业属于那个课程 C语言程序设计II 这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/SE2019-3/homework/10033 ...

  6. python大战EXCEL--xlwings

    xlwings的特色 xlwings能够非常方便的读写Excel文件中的数据,并且能够进行单元格格式的修改 可以和matplotlib以及pandas无缝连接 可以调用Excel文件中VBA写好的程序 ...

  7. [2019牛客多校第四场][G. Tree]

    题目链接:https://ac.nowcoder.com/acm/contest/884/G 题目大意:给定一个树\(A\),再给出\(t\)次询问,问\(A\)中有多少连通子图与树\(B_i\)同构 ...

  8. go html 转字符串存mysql表中

    func HTMLMarshal(str string) (returnStr string) { bf := bytes.NewBuffer([]byte{}) jsonEncoder := jso ...

  9. [Google Guava] 排序: Guava强大的”流畅风格比较器”

    原文链接 译者: 沈义扬 排序器[Ordering]是Guava流畅风格比较器[Comparator]的实现,它可以用来为构建复杂的比较器,以完成集合排序的功能. 从实现上说,Ordering实例就是 ...

  10. npm install命令

    1. --save-prod/-P 使用该命令后,会在package.json的dependencies中出现,是生产环境依赖: 该命令是默认命令. npm install react // 等同于 ...