| | |
| | | mountMethodToWindow(); |
| | | |
| | | }); |
| | | window.onload = function () { |
| | | console.log(window.onload); // 打印数组数据 |
| | | //加载坐标点 |
| | | window.Android.loadMarker(); |
| | | }; |
| | | // window.onload = function () { |
| | | // console.log(window.onload); // 打印数组数据 |
| | | // //加载坐标点 |
| | | // window.Android.loadMarker(); |
| | | // }; |
| | | // 初始化地图 |
| | | function initMap() { |
| | | // 影像底图 |
| | |
| | | } |
| | | |
| | | // 点击标注的事件 |
| | | function addMarkerListener(data) { |
| | | function addMarkerListener(id,data) { |
| | | chageMarkerIcon(data); |
| | | showWaterIntakeDetail("模拟数据"); |
| | | showWaterIntakeDetail(id); |
| | | } |
| | | |
| | | // 修改点击标注的图标 |
| | |
| | | return data1.lat === data2.lat && data1.lng === data2.lng; |
| | | } |
| | | //添加从原生传过来的坐标并显示在地图上 |
| | | function addMarker(jsonData) { |
| | | function addMarker(id,lng,lat,name) { |
| | | console.log("function》》》》》addMarker"); |
| | | var array = JSON.parse(jsonData); |
| | | |
| | | var icon = new T.Icon({ |
| | | iconUrl: markerBluePath, |
| | | iconSize: new T.Point(27, 27), |
| | | iconAnchor: new T.Point(10, 25) |
| | | }); |
| | | array.forEach(element => { |
| | | let marker = new T.Marker( |
| | | new T.LngLat(element[0], element[1]) // 创建标注 |
| | | new T.LngLat(lng, lat) // 创建标注 |
| | | , { icon: icon }); |
| | | //添加点击事件 |
| | | marker.addEventListener("click", (data) => { |
| | | addMarkerListener(data) |
| | | addMarkerListener(id,data) |
| | | }); |
| | | map.addOverLay(marker); // 将标注添加到地图中 |
| | | let label = new T.Label({ |
| | | text: element[2], |
| | | text: name, |
| | | position: marker.getLngLat(), |
| | | offset: new T.Point(-35, 8), // 设置标注文字的位置 |
| | | opacity: 1, // 设置文本的显示不透明度(范围0-1) |
| | |
| | | label.setFontColor("#0000FF"); |
| | | label.setFontSize(10); |
| | | map.addOverLay(label); |
| | | }); |
| | | return "addMarker加载成功" |
| | | } |
| | | //更新定位坐标 |