当前位置:网站首页>使用百度地图API在地图中设置一个覆盖物(InfoWindow),可自定义窗口内容
使用百度地图API在地图中设置一个覆盖物(InfoWindow),可自定义窗口内容
2022-06-25 22:06:00 【langmeng110】
由于主做后台方面的,界面很丑,也没有用bootstrap,vue什么的,就简单的css样式和html,这个内容可以自行发挥咯
话不多说,我就直接上代码了
html代码如下:
<div id="mapDiv" ></div>javaScript代码如下:
var map = new BMap.Map("mapDiv");
var point = new BMap.Point(87.56498774,43.84038035);
map.centerAndZoom(point,19);
var data = {};
data.title="告警人员报警";
data.point=point;
showAlarmMessage(data,map);
//显示提示信息
function showAlarmMessage(data,map){
var content='<div class="alarmDiv">';
content+='<table style="width:100%;height:100%;" border="1" cellpadding="0" cellspacing="0">';
content+='<tr><td rowspan="4" style="width:80px;"><img src="/css/images/alarmLamp.gif" class="alarmPic"/></td>';
content+='<td class="tabLabel">姓名</td><td class="tabText">李二狗</td></tr><tr><td class="tabLabel">身份证号</td>';
content+='<td class="tabText">412825465458452125</td></tr><tr><td class="tabLabel">事发地点</td>';
content+='<td class="tabText">新市区奥龙广场东门门口</td></tr> <tr> <td class="tabLabel">报警设备</td>';
content+='<td class="tabText">奥龙广场东门门禁</td> </tr> <tr> <td colspan="3">';
content+='<table border="1" class="childTab"><tr><th>现场照片</th><th>预警照片</th></tr>' +
'<tr><td align="center"><img src="/css/images/testPerson.jpg"/></td><td align="center">' +
'<img src="/css/images/testPerson.jpg"/></td></tr></table></td></tr></table></div>';
var opts = {
width : 400, // 信息窗口宽度
height: 300, // 信息窗口高度
title : data.title // 信息窗口标题
}
var infoWindow = new BMap.InfoWindow(content, opts);// 创建信息窗口对象
map.openInfoWindow(infoWindow,data.point);// 打开信息窗口
}css代码如下:
.tabLabel {
height: 24px;
text-align: right;
font-weight: bold;
padding-right: 5px;
}
.tabText {
padding-left: 5px;
}
.alarmPic {
width: 80px;
height: 80px;
}
.childTab {
width: 100%;
height: 100%;
}
.childTab th {
text-align: center;
height: 30px;
}
.alarmDiv {
width: 400px;
height: 275px;
}
.BMap_bubble_title{
text-align: center;
font-weight: bold;
color:red;
font-size: 15pt;
}这样就可以在地图上的point位置显示一个信息窗口啦,效果如下图:

边栏推荐
- My vscode
- php中使用Makefile编译protobuf协议文件
- YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21
- The package name of the manifest file in the library project and the app project are not the same
- Classic image segmentation network: UNET supports libtorch deployment reasoning [with code]
- Screen recording to GIF is an easy-to-use gadget, screentogif, which is free and easy to use!
- xtrabackup的备份还原
- c_ uart_ interface_ Example and offboard modes
- 第五章 习题(124、678、15、19、22)【微机原理】【习题】
- OpenResty篇01-入门简介和安装配置
猜你喜欢
随机推荐
php中使用Makefile编译protobuf协议文件
解决‘tuple‘ object has no attribute ‘lower‘
Uni app -- listen for the exit of the return key
一文讲透研发效能!您关心的问题都在
QT custom implemented calendar control
Share a downloaded osgeo4w64 Library Based on qgis3.10
CSDN添加页内跳转和页外指定段落跳转
excel如何实现中文单词自动翻译成英文?这个公式教你了
xtrabackup的备份还原
Go语言逃逸分析全纪录
为什么Integer的比较最好使用equals
社招两年半10个公司28轮面试面经(含字节、拼多多、美团、滴滴......)
4个要点,助力产品管好项目
Blob
先序线索二叉树
Graduation trip | recommended 5-day trip to London
DPVS-FullNAT模式部署篇
B. Box Fitting-CodeCraft-21 and Codeforces Round #711 (Div. 2)
213.打家劫舍 II
实例:用C#.NET手把手教你做微信公众号开发(21)--使用微信支付线上收款:H5方式









