当前位置:网站首页>Let the "label" content in Baidu map generator expand--solution
Let the "label" content in Baidu map generator expand--solution
2022-07-30 07:51:00 【cplvfx】
This article is simple:Copy directly from the article“完整代码”, 修改【坐标】和【公司信息】就完事了
代码
If you use the code I wrote,Need to know below2个
百度地图生成器:http://api.map.baidu.com/lbsapi/createmap/index.html
百度地图拾取坐标系统:http://api.map.baidu.com/lbsapi/getpoint/index.html
但是,Baidu map generator“标注”点,是不会展开的, We just want it to unfold today
效果展示:

Just focus on the code:
var cp_title=" Zhengzhou Yinglun Electric Co., Ltd";
var cp_content="联系人:王伟(先生) <br/>手 机:137***367<br/> 电 话:0371-***628 <br/> Q Q:128***498 <br/>网址:http://www.xxx.com <br/>地 址:Tanxiang Road, High-tech Development Zone, Zhengzhou City1号";
var cp_lng=113.539696;
var cp_lat=34.804373;
完整代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="百度地图,百度地图API,百度地图自定义工具,百度地图所见即所得工具" />
<meta name="description" content="百度地图API自定义地图,帮助用户在可视化操作下生成百度地图" />
<title>百度地图API自定义地图</title>
<!--引用百度地图API-->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=v3Cg0hRvbX7cuUSKG2sEklyeP8iw5eye"></script>
</head>
<body>
<!--百度地图容器-->
<div style="width:80%;height:550px;border:#ccc solid 1px;font-size:12px" id="map"></div>
</body>
<script type="text/javascript">
var cp_title=" Zhengzhou Yinglun Electric Co., Ltd";
var cp_content="联系人:王伟(先生) <br/>手 机:137***367<br/> 电 话:0371-***628 <br/> Q Q:128***498 <br/>网址:http://www.xxx.com <br/>地 址:Tanxiang Road, High-tech Development Zone, Zhengzhou City1号";
var cp_lng=113.539696;
var cp_lat=34.804373;
//创建和初始化地图函数:
function initMap(){
createMap();//创建地图
setMapEvent();//设置地图事件
addMapControl();//向地图添加控件
addMapOverlay();//向地图添加覆盖物
}
function createMap(){
map = new BMap.Map("map");
map.centerAndZoom(new BMap.Point(cp_lng,cp_lat),19);
}
function setMapEvent(){
map.enableScrollWheelZoom();
map.enableKeyboard();
map.enableDragging();
map.enableDoubleClickZoom()
}
function addClickHandler(target,window){
target.addEventListener("click",function(){
target.openInfoWindow(window);
});
}
function addMapOverlay(){
var markers = [
{content:cp_content,title:cp_title,imageOffset: {width:-46,height:-21},position:{lat:cp_lat,lng:cp_lng}}
];
for(var index = 0; index < markers.length; index++ ){
var point = new BMap.Point(markers[index].position.lng,markers[index].position.lat);
var marker = new BMap.Marker(point,{icon:new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png",new BMap.Size(20,25),{
imageOffset: new BMap.Size(markers[index].imageOffset.width,markers[index].imageOffset.height)
})});
var label = new BMap.Label(markers[index].title,{offset: new BMap.Size(25,5)});
var opts = {
width: 200,
title: markers[index].title,
enableMessage: false
};
var infoWindow = new BMap.InfoWindow(markers[index].content,opts);// 创建信息窗口对象
marker.setLabel(label);
addClickHandler(marker,infoWindow);
map.addOverlay(marker);
map.openInfoWindow(infoWindow, map.getCenter()); // 打开信息窗口
};
}
//向地图添加控件
function addMapControl(){
var scaleControl = new BMap.ScaleControl({anchor:BMAP_ANCHOR_BOTTOM_LEFT});
scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
map.addControl(scaleControl);
var navControl = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE});
map.addControl(navControl);
var overviewControl = new BMap.OverviewMapControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT,isOpen:true});
map.addControl(overviewControl);
}
var map;
initMap();
</script>
</html>修改代码
修改内容
var cp_title="The title you want to display、店名、公司名";
var cp_content="联系人:XXX(先生) <br/>手 机:137****5367<br/> 电 话:0371-***28 <br/> Q Q:128***98 <br/>网址:http://www.XXXXX.com <br/>地 址:Tanxiang Road, High-tech Development Zone, Zhengzhou City1号";修改坐标
第一步:打开 【百度地图拾取坐标系统】:http://api.map.baidu.com/lbsapi/getpoint/index.html
第二步:Find where you want to show
第三步:复制坐标

第四步:修改代码
“,”The value before the comma is given to the variablecp_lng
“,”The value after the comma is given to the variablecp_lat
var cp_lng=113.539696;
var cp_lat=34.804373;
第五步:保存-完成
边栏推荐
- numpy 多维数组ndarray的详解
- 阿里二面:Redis有几种集群方案?我答了4种
- Test Development Engineer Growth Diary 001 - Some Introduction to Agile Testing, CI/CD/CT, DecOps
- prometheus监控mysql
- Selenium01
- Build an intelligent network security management and control system for digital government
- Swagger使用方式,告别postman
- libgrape-lite on GPUs: GPU helps accelerate graph analysis tasks
- prometheus监控nacos
- As a test leader, examine several aspects of job candidates
猜你喜欢

OP tokens and non-transferable NFTs work to build a new digital democracy

Redis download and installation

DHCP principle and configuration

Rodrigues:旋转矩阵的向量表达

计算矩阵的逆源码(使用伴随矩阵,3×3的矩阵)

Application of graph computing in network security analysis

The Force Plan Microservices | Centralized Configuration Center Config Asymmetric Encryption and Security Management

How to save modelsim simulation data as a file
Test Development Engineer Growth Diary 010 - CI/CD/CT in Jenkins (Continuous Integration Build/Continuous Delivery/Continuous Testing)

DHCP原理与配置
随机推荐
Camera coordinate system, world coordinate system, pixel coordinate system conversion, and Fov conversion of OPENGLDEFocal Length and Opengl
Local Implicit Grid Representations for 3D Scenes详解
numpy 多维数组ndarray的详解
Advanced multi-threading (lock strategy, spin+CAS, Synchronized, JUC, semaphore)
Selenium01
Test development engineer growth diary 016 - those things about the test
测开基础知识02
Test Development Engineer Growth Diary 018 - Record of Required Questions for Test Interview (Continuous Update)
黑盒测试的概念及测试方法
how to use xilinx's FFT ip
Polygon 3D(三维平面多边形)的法向量的计算(MeshLab默认的计算)
Test Development Engineer Growth Diary 007 - Bug Priority Definition and Filling Specifications
从 Vertex 到 Subgraph 再到 PIE: 并行图计算编程模型概览
LVM和磁盘配额
Vineyard: An open source distributed in-memory data management framework
矩阵的行列式的计算及其源码
debian problem
Selenium02
Linx common directory & file management commands & VI editor usage introduction
05-Theos