目录
小编都是在vue项目中使用高德地图的,每一个功能都会亲测可用之后才会留下笔记,而且会用通俗的语言让看到小编的笔记的大家也能熟练使用高德地图在项目中的使用,如有不同的理解也欢迎大家在评论留言。








-- 解释一下不要被刚进来的填写方式吓到了,这个填写内容是针对uniapp项目的app安卓端的,至于上面的名称怎么获取,小编也有自己的uniapp完整开发流程,如下:
app软件开发、uniapp、uni-admin使用,独立开发app,相关技术一体化(很完整,小编实践过的一这套uniapp相关技术)_❆VE❆的博客-CSDN博客

-- 说明一下:不同的平台获取key的方式也不是不同的

-- 填写好信息之后提交即可



(官方文档基本上都是js用法,用法类似,但是还是有区别的,为了大家能直接上手,就在项目中实践了)
npm i @amap/amap-jsapi-loader --save

- <template>
- <div>
- <div id="container" ref="amap">div>
- div>
- template>
- #container {
- padding: 0px;
- margin: 0px;
- width: 100%;
- height: 900px;
- }
- import AMapLoader from '@amap/amap-jsapi-loader'
- methods:{
- initAMap() {
- const _this = this
- AMapLoader.load({
- key: '365c***********155b', // 申请好的Web端开发者Key,首次调用 load 时必填
- version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
- plugins: [] // 需要使用的的插件列表,如比例尺'AMap.Scale'等,如果是地图控件,必须再 map.addControl添加
- })
- .then((AMap) => {
- const map = new AMap.Map('container', {
- // 设置地图容器id
- viewMode: '3D', // 默认2d地图模式
- zoom: 12, // 初始化地图级别
- zooms: [5, 30], // 地图缩放范围
- // 可以设置初始化当前位置
- center: [116.397428, 39.90923] // 初始化地图位置
- })
- // 添加控件
- AMap.plugin(
- [
- 'AMap.ElasticMarker',
- 'AMap.Scale',
- 'AMap.ToolBar',
- 'AMap.HawkEye',
- 'AMap.MapType',
- 'AMap.Geolocation',
- ],
- () => {
- map.addControl(new AMap.ElasticMarker()) // map.addControl为地图添加对应的控件
- map.addControl(new AMap.Scale())
- map.addControl(new AMap.ToolBar())
- map.addControl(new AMap.HawkEye())
- map.addControl(new AMap.MapType())
- map.addControl(new AMap.Geolocation())
- }
- )
- _this.map = map
- })
- .catch((e) => {
- console.log(e)
- })
- },
- }





谷歌、火狐浏览器: 
IE浏览器: 

-180度到+180度,纬度大约-85度到+85度。- const position = new AMap.LngLat(116, 39);//标准写法
-
- const position = [116, 39]; //简写
-
- var map = new AMap.Center('conatiner',{
- center:position
- })
- var path = [new AMap.LngLat(116,39), new AMap.LngLat(116,40), new AMap.LngLat(117,39)] //标准写法
-
- var path = [ [116,39], [116,40], [117,39] ]; //简写
-
- var polyline = new AMap.Polyline({
- path : path,
- })
- map.add(polyline);
- var lnglat1 = new AMap.LngLat(116, 39);
- var lnglat2 = new AMap.LngLat(117, 39);
- var distance = lnglat1.distance(lnglat2);//计算lnglat1到lnglat2之间的实际距离(m)
-
- // offset(w:Number,s:Number) 当前经纬度坐标值经度移动w,纬度移动s,得到新的坐标。经度向右移为正值,纬度向上移为正值,单位为米。
- var lnglat3 = lnglat1.offset(100,50)//lnglat1向东100m,向北50m的位置的经纬度
x和y两个分量组成,通常用来描述地图的容器坐标、地理像素坐标 (平面像素坐标)、点标记和信息窗体的的锚点等。使用方式如下:- var offset = new AMap.Pixel(-16,-30);
- var marker = new AMap.Marker({
- offset:offset,
- icon:'xxx.png',
- });
- map.add(marker);
width和height两个分量构成,通常用来描述具有一定大小的对象,比如地图的尺寸,图标的尺寸- var mapSize = map.getSize();//获取地图大小,返回的是地图容器的像素大小
- var width = mapSize.width;
- var height = mapSize.height;
-
- var marker = new AMap.Marker({
- position: [116.405467, 39.907761],
- icon: new AMap.Icon({
- size: new AMap.Size(40, 50), //图标的大小
- image: "https://webapi.amap.com/theme/v1.3/images/newpc/way_btn2.png",
- imageOffset: new AMap.Pixel(0, -60)
- })
- });
- map.add(marker)
参数列表查看: