js实现定位功能
//x x轴 y y轴 _wendu 温度 _time time _humidity 湿度function now_one_map01(x, y, _wendu, _time, _humidity, _shebeibianhao, _chepaihao) {$("#danMap").html("");// 放地图的容器var map01 = new BMap.Map("dan
·
//x x轴 y y轴 _wendu 温度 _time time _humidity 湿度 function now_one_map01(x, y, _wendu, _time, _humidity, _shebeibianhao, _chepaihao) { $("#danMap").html("");// 放地图的容器 var map01 = new BMap.Map("danMap"); var point = new BMap.Point(x, y); map01.centerAndZoom(point, 12); map01.panBy(250,200);//这里的数值单位是像素不是百度的经纬度 地图的中心点 var geoc = new BMap.Geocoder(); //添加地图到页面并确定中心点; var marker = new BMap.Marker(point); map01.addOverlay(marker); //添加小红点; map01.enableScrollWheelZoom(true); geoc.getLocation(point, function(rs) { var addComp = rs.addressComponents; var address = (addComp.province == addComp.city) ? (addComp.city + addComp.district + addComp.street + addComp.streetNumber) : (addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber) var _label = new BMap.Label("车牌号:" + _chepaihao + "<br>设备编号:" + _shebeibianhao + "<br>上报地址:" + address + "<br/>温/湿度:" + Number(_wendu) / 10 + "℃/" + Number(_humidity) / 10 + "%<br/>时间:" + _time, { offset: new BMap.Size(20, -25) }) _label.setStyle({ color: "#046da9", fontSize: "1rem", backgroundColor: "#fefefe", fontWeight: "normal", border: "1px solid #ff892a" }); marker.setLabel(_label); }); }
更多推荐
已为社区贡献1条内容
所有评论(0)