基于mapbox-gl 开发类似于高德地图的经纬度拾取器

该博客详细介绍了如何使用Mapbox GL JS库创建一个地图应用,包括设置地图样式、添加鼠标坐标显示、实现坐标拾取及复制功能,并结合geocoder插件进行位置搜索。此外,还展示了如何处理地图上的点击事件,以及添加自定义地图控件和样式切换。

1.index.html页面

<!DOCTYPE html>
<html>
<head> 
	<meta charset="utf-8" /> 
	<title>坐标拾取器</title> 
	<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
	
</head>
<body>

<div id="map"></div>
<div id="geocoder" class="geocoder"></div>
<div id="myPageTop" style="display: block; width: 100%; height: 120px; background: #797373;">	
	<table id="myLngLat" style="display: block; position: absolute;  margin-left: 900px;; top: 10px ;">
		<tbody >
			<tr>				
				<td >
					<label id="copyLngLatTips" style="color :#f55159;font-size: 16px; ">点击地图,拾取经纬度</label>
				</td>				
			</tr> 
			<tr>				
				<td>
					<input type="text" id="txtCoordinate" style="font-size: 24px; width:500px; height: 60px;" readonly>
					<button type="button" id="copyLngLat" style="font-size: 20px; height: 60px; width: 100px; margin-left: 20px; background-color: #5068f0; color: #fdfdfd; border-width: 0px ;" >复制</button>
				</td>
			</tr>
		</tbody>
	</table>
</div>


<!--右下角地图样式切换-->
<div id="style-switcher"></div>

<!--左下鼠标经纬度信息-->
<pre id="mouseCoordinates"></pre>

<!--左下角可移动marker信息--&g
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值