当前位置:网站首页>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 .

边栏推荐
- 出色的学习能力,才是你唯一可持续的竞争优势
- 《财富自由之路》读书之一点体会
- 天才制造者:独行侠、科技巨头和AI|深度学习崛起十年
- Implementation of IM message delivery guarantee mechanism (II): ensure reliable delivery of offline messages
- PowerShell runtime system IO exceptions
- How MySQL deletes all redundant duplicate data
- Illustration of ONEFLOW's learning rate adjustment strategy
- PHP之一句话木马
- 2.< tag-动态规划和常规问题>lt.343. 整数拆分
- Multipass Chinese document - remote use of multipass
猜你喜欢

广和通联合安提国际为基于英伟达 Jetson Xavier NX的AI边缘计算平台带来5G R16强大性能

Second day of deep learning and tensorfow

Guanghetong and anti international bring 5g R16 powerful performance to the AI edge computing platform based on NVIDIA Jetson Xavier nx

Beidou navigation technology and industrial application of "chasing dreams in space and feeling for Beidou"

Genius makers: lone Rangers, technology giants and AI | ten years of the rise of in-depth learning

Ai+ remote sensing: releasing the value of each pixel

-Discrete Mathematics - Analysis of final exercises

Why do many Shopify independent station sellers use chat robots? Read industry secrets in one minute!

Multipass Chinese document - remote use of multipass

Dbeaver installation and configuration of offline driver
随机推荐
PHP one sentence Trojan horse
RESNET practice in tensorflow
Protocol selection of mobile IM system: UDP or TCP?
Practical cases | getting started and mastering tkinter+pyinstaller
One of token passing between microservices @feign's token passing
[quartz] read configuration from database to realize dynamic timing task
ECCV 2020 double champion team, take you to conquer target detection on the 7th
YOLOV5训练结果的解释
Datetime data type - min() get the earliest date and date_ Range() creates a date range, timestamp() creates a timestamp, and tz() changes the time zone
Implementation of IM message delivery guarantee mechanism (II): ensure reliable delivery of offline messages
Procedural life
UWB超高精度定位系统原理图
Douban top250
Technical problems to be faced in mobile terminal im development
Mise en œuvre du routage dynamique par zuul
PHP之一句话木马
出色的学习能力,才是你唯一可持续的竞争优势
Yolov5 super parameter setting and data enhancement analysis
Create a binary response variable using the cut sub box operation
Transport layer TCP protocol and UDP protocol