赞
踩
不加会报错: amap is not defined
<script src="http://webapi.amap.com/maps?v=1.4.15&key= 你申请的key &plugin=AMap.ControlBar"></script>
- configureWebpack: {
- externals: {
- 'AMap': 'AMap' // 高德地图配置
- }
- },
- <template>
- <div class="box">
- <div id="container" style="width:1500px; height:600px"></div>
- </div>
- </template>
-
- <script>
- import AMap from 'AMap' // 引入高德地图
- export default {
- mounted () {
- this.init()
- },
- methods: {
- init () {
- let map = new AMap.Map('container', {
- resizeEnable: true,
- rotateEnable:true,
- pitchEnable:true,
- zoom: 17,
- pitch:80,
- rotation:-15,
- viewMode:'3D',//开启3D视图,默认为关闭
- buildingAnimation:true,//楼块出现是否带动画
-
- expandZoomRange:true,
- zooms:[3,20],
- center:[116.333926,39.997245]
- })
- }
- }
- }
- </script>
到这里步骤就结束了,在页面上是可以看到的;
- <!DOCTYPE HTML>
- <html>
- <head>
- <meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=0">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>3D地图</title>
- <style>
- body,html{ margin:0;padding:0;font:12px/16px Verdana,Helvetica,Arial,sans-serif;width: 100%;height: 100%}
- .container{
- height: 100%
- }
- </style>
- <script language="javascript" src="http://webapi.amap.com/maps?v=1.4.15&key=
- 你的高德key &plugin=AMap.ControlBar"></script>
- </head>
- <body >
- <div id="container" style="width:100%; height:100%;resize:both;"></div>
- <script language="javascript">
- var map;
- function mapInit(){
- map = new AMap.Map('container', {
- resizeEnable: true,
- rotateEnable:true,
- pitchEnable:true,
- zoom: 17,
- pitch:80,
- rotation:-15,
- viewMode:'3D',//开启3D视图,默认为关闭
- buildingAnimation:true,//楼块出现是否带动画
-
- expandZoomRange:true,
- zooms:[3,20],
- center:[116.333926,39.997245]
- });
-
- map.addControl(new AMap.ControlBar({
- showZoomBar:false,
- showControlButton:true,
- position:{
- right:'10px',
- top:'10px'
- }
- }))
- }
- mapInit()
- </script>
- </body>
- </html>
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。