BIGEMPA Js API示例中心
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <!-- 以下CSS地址請在安裝軟件了替換成本地的地址 CSS地址請使用: http://localhost:9000/bigemap.js/v2.1.0/bigemap.css 軟件下載地址 http://m.bjxdny.cn/reader/download/detail201802017.html --> <link href="http://m.bjxdny.cn:9000/bigemap.js/v2.1.0/bigemap.css" rel="stylesheet" /> <link href="https://cdn.bootcss.com/Buttons/2.0.0/css/buttons.min.css" rel="stylesheet" /> <!-- JS地址請使用: http://localhost:9000/bigemap.js/v2.1.0/bigemap.js --> <script src="http://m.bjxdny.cn:9000/bigemap.js/v2.1.0/bigemap.js"></script> <script src="http://m.bjxdny.cn/Public/offline/js/line_canvas_bigemap.js"></script> <script src="http://m.bjxdny.cn/Public/offline/js/linecolor_coords.js"></script> <style> body { margin: 0; padding: 0; } #map { position: absolute; top: 0; bottom: 0; width: 100%; } .tool { position: absolute; z-index: 10; right: 10px; top: 40px; } </style> <title>Google Map Streets</title> </head> <body> <div id="map"></div> <p class="tool"> <button id="satellite" onclick="showF()" class="button button-tiny button-rounded button-primary" href="javascript:void (0);" > 線段顯示 </button> <button id="street" onclick="hideF()" class="button button-tiny button-rounded button-primary" href="javascript:void (0);" > 線段隱藏 </button> <button id="street" onclick="setLatLng()" class="button button-tiny button-rounded button-primary" href="javascript:void (0);" > 重新設置經緯度 </button> </p> <script> // 軟件配置信息地址,軟件安裝完成之后使用本地地址,如:http://localhost:9000 BM.Config.HTTP_URL = "http://m.bjxdny.cn:9000"; // 在ID為map的元素中實例化一個地圖,并設置地圖的ID號為 bigemap.baidu-map,ID號程序自動生成,無需手動配置,并設置地圖的投影為百度地圖 ,中心點,默認的級別和顯示級別控件 var map = BM.map("map", "bigemap.zhongkexingtu", { center: [0, 0], zoom: 2, zoomControl: true, attributionControl: false, }); // coords示例坐標 //線段的坐標點 var latlngs = [ [30, 102.68, 150], [33, 108.43, 200], [37.04, 118.2, 300], ]; var hotlineLayer = BM.hotline(coords, { //根據自身數據設置對應的min max min: 150, max: 300, //根據min/max自定計算對應的比例 相對于的顏色 palette: { 0.0: "white", 0.5: "green", 0.8: "yellow", 1.0: "red", }, weight: 5, //寬度 outlineColor: "pink", //外框的顏色】 outlineWidth: 3, //外框寬度 }).addTo(map); //事件文檔 // http://m.bjxdny.cn/offlinemaps/api/#interactive-layer-event //點擊事件 hotlineLayer.on("click", (e) => { // e.target 線段的實例對象 }); //鼠標移動事件 hotlineLayer.on("mousemove", (e) => { // e.target 線段的實例對象 }); //線段顯示 function showF() { hotlineLayer.addTo(map); } //線段刪除 function hideF() { hotlineLayer.remove(); } function setLatLng() { //設置樣式 hotlineLayer.setStyle({ palette: { 0.0: "white", 0.5: "green", 0.8: "yellow", 1.0: "blue", }, weight: 5, //寬度 outlineColor: "red", //外框的顏色】 outlineWidth: 1, //外框寬度 }); //設置經緯度 hotlineLayer.setLatLngs(latlngs); } map.fitBounds(hotlineLayer.getBounds()); </script> </body> </html>