当前位置:网站首页>Baidu map - introductory tutorial
Baidu map - introductory tutorial
2022-06-25 06:37:00 【Nanchen_ forty-two】
Catalog
One 、 Log in to your account and get your secret key
3、 ... and 、 Create a map container
5、 ... and 、 Set map detail style
One 、 Log in to your account and get your secret key
Get the secret key
A new... Will appear after submission AK That is the so-called secret key
At this time, it can be directly used to call
Two 、 Bring in the map
<script type="text/javascript" src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak= Your secret key ">
3、 ... and 、 Create a map container
Then create a box
<div id="container"></div>
Four 、 Define box size
Set the box size and hide logo And copyright
#container {
margin: 100px auto;
width: 500px;
height: 300px
}
/* Baidu maps copyright */
.BMap_cpyCtrl {
display: none;
}
/* Baidu Maps logo */
.anchorBL {
/* display: none; */
}
5、 ... and 、 Set map detail style
<script type="text/javascript">
var map = new BMapGL.Map("container");
// Allow zooming in and out
map.enableScrollWheelZoom(true);
// Create a map instance
var point = new BMapGL.Point(121.467406, 31.411477, 20);
// Create tag location
var marker = new BMapGL.Marker(new BMapGL.Point(121.467406, 31.411477));
// Default magnification
map.centerAndZoom(point, 20);
function addOverlay() {
map.addOverlay(marker); // Add points
}
addOverlay()
var opts = {
width: 200, // Information window width
height: 100, // Information window height
title: " Exclusive zone for children ", // Message window title
message: " This is an apartment "
}
var infoWindow = new BMapGL.InfoWindow(" Address : Shanghai xx District xx road xxxxx", opts); // Create information window object
marker.addEventListener("click", function () {
map.openInfoWindow(infoWindow, point); // Open the message window
});
// Initialize map , Set center point coordinates and map level
var geolocation = new BMapGL.Geolocation();
var geoc = new BMapGL.Geocoder();
console.log(geoc);
</script>
The effect is as follows :
If you want to get the coordinate position by yourself, you can use Pick the coordinate system
边栏推荐
- Global and Chinese medical protective clothing market supply and demand research and investment value proposal report 2022-2028
- What is VLAN
- Wechat applet simply realizes chat room function
- [从零开始学习FPGA编程-43]:视野篇 - 后摩尔时代”芯片设计的技术演进-2-演进方向
- JD 7 head search navigation layout
- China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
- Global and China chemical mechanical polishing abrasive materials market demand outlook and investment scale forecast report 2022 Edition
- Go language library management restful API development practice
- Record of friend guide
- Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
猜你喜欢
BGP - basic concept
[road of system analyst] collection of wrong questions in the chapters of Applied Mathematics and economic management
Cs8683 (120W mono class D power amplifier IC)
TCP BBR as rate based
ACWING/2004. Misspelling
sin(a+b)=sina*cosb+sinb*cosa的推导过程
Uncaught TypeError: Cannot read properties of undefined (reading ‘prototype‘)
Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop
IQ debugging of Hisilicon platform ISP and image (1)
Ht81293 built in adaptive dynamic boost 20W mono class D power amplifier IC solution
随机推荐
Vegetables sklearn - xgboost (2)
Monitoring access: how to grant minimum WMI access to the monitoring service account
System dilemma and software complexity: Why are our systems so complex?
Research Report on brand strategic management and marketing trends in the global and Chinese preserved fruit market 2022
cos(a-b)=cosa*cosb+sina*sinb的推导过程
Sword finger offer II 095 Longest common subsequence
ACWING/2004. 錯字
@The difference between notempty, @notnull and @notblank
With a younger brother OCR, say no to various types of verification codes!
Is it safe to open a stock account on the Internet in Beijing?
ARM processor operating mode
JD 7 head search navigation layout
An interview question record about where in MySQL
十大券商公司哪个佣金最低,最安全可靠?有知道的吗
Personal blog system graduation project opening report
Talk about TCP and UDP
Single lithium battery 3.7V power supply 2x12w stereo boost audio power amplifier IC combination solution
How to record a database [closed] - how to document a database [closed]
[no title] dream notes 2022-02-20
You can see the classification of SQL injection. SQL injection point /sql injection type /sql injection has several /sql injection point classifications