当前位置:网站首页>百度地图——入门教程
百度地图——入门教程
2022-06-25 06:32:00 【Nanchen_42】
目录
一、登录账号以及获取秘钥
获取秘钥


提交之后会出现一个新增的AK也就是所谓的秘钥

这时候就可以直接用来调用了
二、引入地图
<script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=你的秘钥">三、创建地图容器
之后创建一个盒子
<div id="container"></div>四、定义盒子大小
设置盒子大小以及隐藏logo和版权
#container {
margin: 100px auto;
width: 500px;
height: 300px
}
/* 百度地图版权 */
.BMap_cpyCtrl {
display: none;
}
/* 百度地图logo */
.anchorBL {
/* display: none; */
}五、设置地图详细样式
<script type="text/javascript">
var map = new BMapGL.Map("container");
// 允许放大缩小
map.enableScrollWheelZoom(true);
// 创建地图实例
var point = new BMapGL.Point(121.467406, 31.411477, 20);
// 创建标记位置
var marker = new BMapGL.Marker(new BMapGL.Point(121.467406, 31.411477));
// 默认放大倍数
map.centerAndZoom(point, 20);
function addOverlay() {
map.addOverlay(marker); // 增加点
}
addOverlay()
var opts = {
width: 200, // 信息窗口宽度
height: 100, // 信息窗口高度
title: "小朋友专属区", // 信息窗口标题
message: "这里是公寓"
}
var infoWindow = new BMapGL.InfoWindow("地址:上海市xx区xx路xxxxx", opts); // 创建信息窗口对象
marker.addEventListener("click", function () {
map.openInfoWindow(infoWindow, point); //开启信息窗口
});
// 初始化地图,设置中心点坐标和地图级别
var geolocation = new BMapGL.Geolocation();
var geoc = new BMapGL.Geocoder();
console.log(geoc);
</script>效果如下:

如果想要自己获取坐标位置可以使用拾取坐标系统

边栏推荐
- Forecast report on output demand and supply scale of global and Chinese structural ceramics market for semiconductor equipment (2022 Edition)
- CTFSHOW
- Exercise: completion
- Research Report on demand and Competitive Prospect of global and Chinese welding personal protective equipment industry 2022-2027
- Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
- [data visualization application] draw spatial map (with R language code)
- [network security] sharing of experience and ideas of an emergency battle
- 2022-02-19: fence installation. In a two-dimensional garden, there are some trees represented by (x, y) coordinates. As the installation cost is very expensive, your task is to enclose all the trees w
- MV command – move or rename files
- Optimal Parking
猜你喜欢

Location object

Three tier architecture experiment

Es11 new methods: dynamic import(), bigint, globalthis, optional chain, and null value merging operator

Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things

With a younger brother OCR, say no to various types of verification codes!

Sleep quality today 67 points

What elements are indispensable for the development of the character? What are the stages
![[Suanli network] problems and challenges faced by the development of Suanli network](/img/90/1d537de057113e2b4754e76746f256.jpg)
[Suanli network] problems and challenges faced by the development of Suanli network

Personal blog system graduation project opening report
![[hand torn STL] Stack & queue](/img/db/d05c52f8e3fb0aade51460e86cf623.jpg)
[hand torn STL] Stack & queue
随机推荐
The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse
DNS domain name system
DF command – displays disk space usage
Drosophila played VR and entered nature. It was found that there were attention mechanisms and working memory. The insect brain was no worse than that of mammals
Cve-2022-23131 - bypass SAML SSO authentication
Analysis report on production and sales demand and sales prospect of global and Chinese phosphating solution Market 2022-2028
@Detailed explanation of valid annotation usage
Fdisk command – disk partition
证券如何在线开户?在线开户是安全么?
JD 8 fleet stores search history, deletes history, clears history (not finished)
VMware virtual machine prompt: the virtual device ide1:0 cannot be connected because there is no corresponding device on the host.
SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-
Report on the application prospect and investment potential of global and Chinese cell therapy industry 2022-2028
Go language library management restful API development practice
China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
Arm register (cortex-a), coprocessor and pipeline
Socket, network model notes
BGP - basic concept
Introduction to sap ui5 tools
Report on strategic suggestions on investment direction and Prospect of global and Chinese marine biological industry (2022 Edition)