1.首先,注册高德地图开发者,这个直接在官网上注册,输入必要信息就行,如下: 2.注册完成后,进入个人中心,依次点击“应用管理”->“我的应用”->“创建新应用”,如下,这里输入应用名称,选择类型就行:
3 接着就需要为应用添加key值,点击右上角的+号,就会弹出添加窗口,这里我们选择“Web端(JS API)”,如下: 4 添加key值成功后,就会在应用列表中看到刚才添加的key值,如下,后面的代码中需要用到这个key值: 5.最后就是编写代码,在html页面中引入3D地图了,如下,代码很简单,主要是创建div容器,然后通过JS引入地图到这个容器中,这里需要JS API版本在1.4.0以上,指定地图模式为3D,key值替换成自己应用的key值:
<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"> <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" /> <style> html, body, #container { width: 100%; height: 100%; } </style> <title>地图加载完成</title> </head> <body> <div id="container"></div> <script src="https://webapi.amap.com/maps?v=1.4.13&key=你的key值"></script> <script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script> <script> var map = map = new AMap.Map('container', { resizeEnable: true, viewMode:'3D' }); map.on("complete", function(){ log.success("地图加载完成!"); }); </script> </body> </html>
6 浏览效果如图: