123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <!DOCTYPE html>
- <html style="">
- <head>
- <meta charset="UTF-8" />
- <meta name="viewport"
- content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
- <title></title>
- <script src="./js/jquery3.5.js" type="text/javascript"></script>
-
- <script src="./js/hybrid_html_uni.webview.1.5.5.js" type="text/javascript"></script>
-
- <script src="http://api.tianditu.gov.cn/api?v=4.0&tk=ffb54337376426c1941e6d6bf5b5f8e5" type="text/javascript"></script>
-
- <script>
- let map;
- let zoom = 16;
-
- function onLoad() {
- let lnglat = {};
- map = new T.Map('mapDiv');
- map.centerAndZoom(new T.LngLat(120.139726, 33.345562), zoom);
-
- var scale = new T.Control.Scale();
-
- map.addControl(scale);
-
- var control_zoom = new T.Control.Zoom();
- control_zoom.setPosition(T_ANCHOR_BOTTOM_RIGHT);
-
-
- map.addControl(control_zoom);
-
-
- var ctrl = new T.Control.MapType([
- {
- title: "地图",
- icon: "http://api.tianditu.gov.cn/v4.0/image/map/maptype/vector.png",
- layer: TMAP_NORMAL_MAP
- },
- {
- title: "卫星",
- icon: "http://api.tianditu.gov.cn/v4.0/image/map/maptype/satellite.png",
- layer: TMAP_SATELLITE_MAP
- }
- ]);
-
-
- let geolocation = new T.Geolocation()
-
-
-
-
-
-
-
-
-
-
-
-
- document.addEventListener('UniAppJSBridgeReady', function() {
-
-
-
-
-
-
- })
-
- $.ajax({
- url: "/api/map/mapVisualization/getBuildingList",
- dataType: "json",
- type: "get",
- success: function (data) {
- console.log( data );
- if (data != null && data.length > 0) {
- batchMark( data );
- }
- },
- error:function(){
- alert( "请求楼宇信息失败!" );
- },
- });
- }
-
- function batchMark(buildingData) {
- if (buildingData != null && buildingData.length > 0) {
- var pointArray = new Array();
- for (var i = 0; i < buildingData.length; i++) {
- var point = new T.LngLat(buildingData[i].building_longitude, buildingData[i].building_latitude);
- var marker = new T.Marker(point);
- marker.markerName = buildingData[i].building_name;
- marker.buildingId = buildingData[i].building_id;
- marker.addEventListener("click", markerClick);
- map.addOverLay(marker);
- pointArray[i] = point;
- }
-
- map.setViewport(pointArray);
- }
- }
- function markerClick(e) {
- uni.postMessage({
- data: {
- buildingId: e.target.buildingId,
- buildingName: e.target.markerName
- },
- })
- }
-
- window.msgFromUniapp = function(buildingData) {
- batchMark(buildingData)
- }
- </script>
- <style>
- body,
- html {
- padding: 0;
- margin: 0;
- width: 100%;
- height: 100%;
- transform: translateX(-1.5px);
- }
- .tdt-control-copyright {
- display: none !important;
- }
- .tdt-control-datasources {
- display: none !important;
- }
- </style>
- </head>
- <body style="width:100%; height:100%" onLoad="onLoad()">
- <div id="mapDiv" style="width:100%; height:100%"></div>
- </body>
- </html>
|