当前位置:网站首页>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;
第五步:保存-完成
边栏推荐
- 测试开发工程师成长日记016 - 关于提测的那些事
- Data types of Redis6
- 测试开发工程师成长日记009 - 环境排排站:开发环境、测试环境、生产环境、UAT环境、仿真环境
- Distance calculation from space vertex to straight line and its source code
- MySql connecting to the server remotely
- npm安装nodejs环境配置
- 空间顶点到直线的距离计算及其源码
- libgrape-lite: 提供 GraphScope 的图分析能力
- STL源码剖析:迭代器的概念理解,以及代码测试。
- schur completement
猜你喜欢

GNNLab: A Novel GNN System Based on Spatial Sharing Ideas

prometheus监控mysql

Bull: remove common characters

图解关系数据库设计思想,这也太形象了

Local Implicit Grid Representations for 3D Scenes详解

Advanced multi-threading (CountDownLatch, deadlock, thread-safe collection class)

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

引导过程与服务控制

flask项目快速搭建部署gunicorn+supervisor

STL源码剖析:迭代器的概念理解,以及代码测试。
随机推荐
矩阵的行列式的计算及其源码
02-Use of Cycript
阿里一面:多线程顺序运行有多少种方法?
kubernetes搭建SonarQube进行代码扫描
测开基础知识01
Selenium01
libgrape-lite on GPUs: GPU helps accelerate graph analysis tasks
使用 Grafana 的 Redis Data Source 插件监控 Redis
mysql常用命令以及mysqldump备份
Interactively compose graphs in GraphScope based on the JupyterLab plugin
Required request body is missing 问题解决
软件测试术语 - 场景测试
Selenium02
A New Paradigm for Distributed Deep Learning Programming: Global Tensor
Advanced multi-threading (lock strategy, spin+CAS, Synchronized, JUC, semaphore)
向量的导数运算和向量叉乘以及点乘的导数运算
@Bean 与 @Component 用在同一个类上,会怎样?
搭建vsftpd服务并实现本地用户访问
图解关系数据库设计思想,这也太形象了
计算矩阵的逆源码(使用伴随矩阵,3×3的矩阵)