当前位置:网站首页>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;
第五步:保存-完成
边栏推荐
- How to import matlab data into modelsim simulation
- prometheus监控mysql
- libgrape-lite on GPUs: GPU helps accelerate graph analysis tasks
- Build an intelligent network security management and control system for digital government
- MySQL common commands and mysqldump backup
- Test Development Engineer Growth Diary 007 - Bug Priority Definition and Filling Specifications
- STL源码剖析:bound friend template friend代码测试和理解
- The Force Plan Microservices | Centralized Configuration Center Config Asymmetric Encryption and Security Management
- Polygon 3D(三维平面多边形)的法向量的计算(MeshLab默认的计算)
- 04-packing and unpacking
猜你喜欢

STL source code analysis: conceptual understanding of iterators, and code testing.

GNNLab: A Novel GNN System Based on Spatial Sharing Ideas

About memcache kernel, so one of the most popular

Linx常见目录&文件管理命令&VI编辑器使用 介绍

Test and Development Engineer Growth Diary 009 - Environment Pai Pai Station: Development Environment, Test Environment, Production Environment, UAT Environment, Simulation Environment

How to import matlab data into modelsim simulation

Data types of Redis6

Network Protocol 01 - Basic Concepts

Graph Computing 101: Types, Languages, and Systems of Graph Computing

libgrape-lite on GPUs: GPU helps accelerate graph analysis tasks
随机推荐
The calculation proof of the intersection of the space line and the plane and its source code
Data types of Redis6
LVM和磁盘配额
numpy 多维数组ndarray的详解
Event Delivery and Responder Chains
debian problem
Alamofire source code analysis - POST request
MongoDB-查询
Local Implicit Grid Representations for 3D Scenes详解
Redis download and installation
matlab机器学习_01
GNNLab: A Novel GNN System Based on Spatial Sharing Ideas
prometheus监控nacos
Detailed explanation of numpy multidimensional array ndarray
MongoDB-介绍,数据类型,基本语句
Selenium01
矩阵的行列式的计算及其源码
阿里一面:多线程顺序运行有多少种方法?
测试开发工程师成长日记003 - 接口自动化框架搭建
Test Development Engineer Growth Diary 018 - Record of Required Questions for Test Interview (Continuous Update)