BIGEMPA Js API示例中心
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <link href="http://www.bt68f.cn:9000/bigemap.js/v2.1.0/bigemap.css" rel="stylesheet" /> <script src="http://www.bt68f.cn:9000/bigemap.js/v2.1.0/bigemap.js"></script> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.js"></script> <style> * { margin: 0; padding: 0; } html, body { width: 100%; height: 100%; } #map { position: absolute; top: 0; bottom: 0; width: 100%; } </style> <title>ArcGis Map</title> </head> <body> <div id="map"></div> <script> window.polygonArr = []; window.centerPolygon = []; // 軟件配置信息地址,軟件安裝完成之后使用本地地址,如:http://localhost:9000 BM.Config.HTTP_URL = "http://www.bt68f.cn:9000"; // 在ID為map的元素中實例化一個地圖,并設(shè)置地圖的ID號為bigemap.arcgis-map,ID號程序自動生成,無需手動配置,無需設(shè)置地圖投影 ,設(shè)置中心點,默認(rèn)的級別和顯示級別控件 window.map = BM.map("map", "bigemap.zhongkexingtu", { center: [32.17852128889127, 103.06919018354374], zoom: 10, zoomControl: true, attributionControl: false, }); $.ajax({ url:"/offline_data/newjunbiao/hs.geojson", contentType: "application/json",//必須項 dataType: "json",//必須項 }).then((res) => { console.log(res, "請求結(jié)果"); BM.geoJSON(res, { style: function () { return {}; }, onEachFeature: function (feature, layer) { var latlngs = layer.feature.geometry.coordinates; latlngs.forEach((v) => { getCooridnate(v); }); // console.log(window.polygonArr); window.polygonArr = [...new Set(window.polygonArr)]; var latLngs = [ [ [-91, -181], [91, -181], [91, 181], [-90, 181], ], // 外環(huán) window.polygonArr, // 洞 ]; var polygon = BM.polygon(latLngs, { fillColor: "black", stroke: true, // weight: 300, fillOpacity: 0.8, color: "aqua", weight: 6, dashArray: [20, 10], }).addTo(map); }, }); }); // 獲取行政區(qū)域邊界數(shù)據(jù) function getCooridnate(arr) { // console.log(arr); arr.forEach((v, i) => { // console.log(v[1], v[0]); window.polygonArr.push([v[1], v[0]]); }); } </script> </body> </html>