当前位置:网站首页>Baidu API map is not displayed in the middle, but in the upper left corner. What's the matter? Resolved!
Baidu API map is not displayed in the middle, but in the upper left corner. What's the matter? Resolved!
2022-06-26 05:09:00 【You are sexy!】
Baidu map was introduced into the project , Run to find that the position of the dimension is offset ?

According to the principle, it is located according to the coordinates , Why did you run to the upper left corner , At first, I couldn't understand it .
I don't say much nonsense , Code that can be handled directly .
Just join this line :map.panBy(580, 150);
//map.panBy(580, 150);
// The first parameter is the width
// The second parameter is height
// Basic settings for you id = "allmap" Of div Half of , It's in the middle .
<script type="text/javascript">
// Baidu Maps API function
var map = new BMap.Map("allmap");
var point = new BMap.Point(114.236412,22.691258);
map.centerAndZoom(point, 18);
map.enableScrollWheelZoom(true); // Turn on mouse wheel zoom
var marker = new BMap.Marker(point); // Create annotations
map.addOverlay(marker); // Add annotations to the map
marker.setAnimation(BMAP_ANIMATION_BOUNCE); // Dancing animation
// Add navigation control with positioning
var navigationControl = new BMap.NavigationControl({
// In the upper left corner
anchor: BMAP_ANCHOR_TOP_LEFT,
// LARGE type
type: BMAP_NAVIGATION_CONTROL_LARGE,
// Enable display positioning
enableGeolocation: true
});
map.addControl(navigationControl);
// Solve the problem that dimension points are not centered
map.panBy(580, 150);// How many pixels is the center point offset (width,height) by div Wide and high 1/2;
</script>

Perfect solution ! salute , And the flower .

边栏推荐
- Transport layer TCP protocol and UDP protocol
- LeetCode 19. 删除链表的倒数第 N 个结点
- Illustration of ONEFLOW's learning rate adjustment strategy
- 递归遍历目录结构和树状展现
- 6.1 - 6.2 Introduction à la cryptographie à clé publique
- Vie procédurale
- 5. <tag-栈和常规问题>补充: lt.946. 验证栈序列(同剑指 Offer 31. 栈的压入、弹出序列)
- 5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)
- 出色的学习能力,才是你唯一可持续的竞争优势
- ssh连win10报错:Permission denied (publickey,keyboard-interactive).
猜你喜欢

A company crawling out of its grave

5. < tag stack and general problems > supplement: lt.946 Verify the stack sequence (the same as the push in and pop-up sequence of offer 31. stack)

AD教程系列 | 4 - 创建集成库文件

超高精度定位系统中的UWB是什么

【Unity3D】刚体组件Rigidbody

Learn from small samples and run to the sea of stars

Use fill and fill in Matplotlib_ Between fill the blank area between functions

天才制造者:獨行俠、科技巨頭和AI|深度學習崛起十年

【Latex】错误类型总结(持更)

FastAdmin Apache下设置伪静态
随机推荐
Protocol selection of mobile IM system: UDP or TCP?
UWB超高精度定位系统架构图
FastAdmin Apache下设置伪静态
MySql如何删除所有多余的重复数据
Resample
【红队】要想加入红队,需要做好哪些准备?
Create a binary response variable using the cut sub box operation
tensorlow:cifar100_ train
Use fill and fill in Matplotlib_ Between fill the blank area between functions
Sentimentin tensorflow_ analysis_ layer
Implementation of IM message delivery guarantee mechanism (II): ensure reliable delivery of offline messages
Zuul 實現動態路由
Generalized linear model (logistic regression, Poisson regression)
Cookie and session Basics
LSTM in tensorflow_ Layers actual combat
Ai+ remote sensing: releasing the value of each pixel
Use to_ Numeric to numeric type
6.1 - 6.2 Introduction à la cryptographie à clé publique
【上采样方式-OpenCV插值】
Tensorflow visualization tensorboard "no graph definition files were found." error