vue 高德地图
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>
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 高德地图的更多相关文章
- vue 高德地图之玩转周边
前言:在之前的博客中,有成功引入高德地图,这是以前的地址 vue 调用高德地图. 因为一些需求,需要使用到地图的周边功能. 完整的项目代码请查看 我的github 一 .先看要实现的结果,参考了链 ...
- VUE 高德地图选取地址组件开发
高德地图文档地址 http://lbs.amap.com/api/lightmap/guide/picker/ 结合步骤: 1.通过iframe内嵌引入高德地图组件 key就选你自己申请的key &l ...
- Vue 高德地图 路径规划 画点
CDN 方式 <!--引入高德地图JSAPI --> <script src="//webapi.amap.com/maps?v=1.4.13&key=您申请的ke ...
- js/vue 高德地图绘制驾车路线图
地图容器: // css要给此容器设置宽高 <div class="map_container"></div> 画图 data{ return { Clng ...
- vue 高德地图使用 vue-amap
此插件文档及使用还不错 https://elemefe.github.io/vue-amap/ <template> <div class="amap-page-conta ...
- vue 调用高德地图
一. vue-amap,一个基于 Vue 2.x 和高德地图的地图组件 https://elemefe.github.io/vue-amap/#/ 这个就不细说了,按照其文档,就能够安装下来. 二. ...
- 基于vue 2.X和高德地图的vue-amap组件获取经纬度
今天我就讲了一下怎么通过vue和高德地图开发的vue-amap组件来获取经纬度. 这是vue-amap的官网文档:https://elemefe.github.io/vue-amap/#/ 这是我的码 ...
- vue中使用vue-amap(高德地图)
因为项目要求调用高德地图,就按照官方文档按部就班的捣鼓,这一路上出了不少问题. 前言: vue-cli,node环境什么的自己安装设置推荐一个博客:https://blog.csdn.net/wula ...
- vue调用高德地图:vue-amap
前言:之前没有接触过页面调用地图的项目,某次面试,老板要求我用vue-amap调用高德地图,回家以后,我去网上查了一些案例和教程,看似很简单的引入调用,我却整整弄了一宿,还没弄出来!!!百般无奈之下, ...
随机推荐
- 用cef Python打造自己的浏览器
背景 项目需要做一个客户端的壳,内置浏览器,访问指定 的url 采用技术 python3.5 cefpython https://github.com/cztomczak/cefpython#inst ...
- SQL Server CET 通用表表达式 之 精典递归
SQL2005 Common Table Expressions(CET)即通用表表达式. SQLSERVER CET递归使用案例: 1.普通案例 表结构如下: ;WITH cet_depart ...
- flask参数传递
一. 参数传递两种方式: 1.get请求 request.args.get("key") 获取get请求参数 2.post请求request.form.get("key& ...
- hi 北京
一 . 感慨 借着参加北京物联网展会的这次机会,提前找老师批了大概两周的假期.当然也借着这次机会,尝试了第一次坐飞机.第一次来北京.心里也有点小激动,在路上甚至会想,我是不是要重新规划一下我的人生了呢 ...
- 5-修改windows的远程桌面端口3389
一.注意点 1.Windows远程桌面端口默认是3389,是一个高危端口,所以需要改为其他的: 2.修改完注册表后,要重启机器,才能生效: 二.操作步骤 1.打开注册表 命令:regedit 2.进入 ...
- 22-系统SQL整理
1.查看内存使用情况 select * from sys.dm_os_sys_memory 2.查看当前进程的情况 select * from sys.sysprocesses 3.查看非系统进程的 ...
- BZOJ 1299: [LLH邀请赛]巧克力棒 【SG函数/博弈分析/高斯消元】
因为太懒,放个博客 我只写了O(2n)O(2^n)O(2n)的 CODE #include <cstdio> int n, x[15]; int main () { for(int T = ...
- vue 配置CDN加速
1.首先index.html 中配置cdn 引入 <!-- 引入样式 --> <link rel="stylesheet" href="//cdn.bo ...
- HTMl5的存储方式sessionStorage和localStorage区别及联系
localStorage 和 sessionStorage 属性允许在浏览器中存储 key/value 对的数据. localStorage 用于长久保存整个网站的数据,保存的数据没有过期时间,直到手 ...
- 【题解】[Nwerc 2006]escape -C++
Description 给出数字N(1<=N<=10000),X(1<=x<=1000),Y(1<=Y<=1000),代表有N个敌人分布一个X行Y列的矩阵上 矩形的 ...