这是用百度地图API组件写的,在点击图(1)“到这里”之后跳转到图(2)的页面,在输入起点的位置怎么自动获取用户地理位置? <header class="t_map"> <span class="h_back"> < 返回 </span> <p>地图</p> </header> <lbs-map class="map_box"> <lbs-poi name="奎科科技大厦" location="116.313393,40.04778" addr="北京市海淀区信息路甲9号"></lbs-poi> </lbs-map>
1 回答

墨色风雨
TA贡献1853条经验 获得超6个赞
在图1的页面中就把用户位置获取到
let geolocationControl = new BMap.GeolocationControl({ locationIcon: geolocationIcon }); geolocationControl.addEventListener("locationSuccess", function(e){ // 定位成功事件 todo(e.point, e.addressComponent); }); geolocationControl.addEventListener("locationError",function(e){ // 定位失败事件 //alert(e.message);}); map.addControl(geolocationControl); geolocationControl.location();
添加回答
举报
0/150
提交
取消