BIGEMPA Js API示例中心
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>繪制</title> <link href='http://www.kenshimo.com:9000/bigemap.js/v2.1.0/bigemap.css' rel='stylesheet' /> <script src='http://www.kenshimo.com:9000/bigemap.js/v2.1.0/bigemap.js'></script> <script src="/Public/common/js/jquery.min.js"></script> <!-- 以下CSS地址請在安裝軟件了替換成本地的地址 CSS地址請使用: http://localhost:9000/bigemap.js/v2.1.0/bigemap.css JS地址請使用: http://localhost:9000/bigemap.js/v2.1.0/bigemap.js 軟件下載地址 http://www.kenshimo.com/reader/download/detail201802017.html --> <!--<link href='http://www.kenshimo.com:9000/bigemap.js/v2.1.0/bigemap.css' rel='stylesheet' />--> <!--<script src='http://www.kenshimo.com:9000/bigemap.js/v2.1.0/bigemap.js'></script>--> <!--引入鼠標繪制的JS+CSS--> <!--對應下面的CSS+JS的下載地址 請直接訪問 http://bigemap.com/Public/mouse_draw/mouse_draw.zip 來下載--> <link rel="stylesheet" href="/Public/mouse_draw/Bigemap.draw.css"/> <script src="/Public/js/bm.draw.min.js"></script> <link href="http://www.kenshimo.com/Public/css/button.min.css" rel="stylesheet"> </head> <style type="text/css"> *{ padding: 0; margin: 0; } html,body,#map{ width: 100%; height: 100%; } #start{ position: absolute; z-index: 10; right: 20px; top:20px; display: inline-block; width: 150px; } </style> <body> <button id="start" class="button button-tiny button-rounded button-primary">繪制多邊形</button> <div id="map"> </div> <script> BM.Config.HTTP_URL = 'http://www.kenshimo.com:9000'; // 在ID為map的元素中實例化一個地圖,并設置地圖的ID號為 bigemap.arcgis-satellite,ID號程序自動生成,無需手動配置,并設置地圖的投影為百度地圖 ,中心點,默認的級別和顯示級別控件 var map = BM.map('map', 'bigemap.arcgis-satellite', {center: [30, 104], zoom: 8, zoomControl: true,attributionControl:false }); //創建一個圖形覆蓋物的集合來保存點線面 var drawnItems = new BM.FeatureGroup(); //添加在地圖上 map.addLayer(drawnItems); // var polygon = new BM.Polyline([ // [51.51, -0.1], // [51.5, -0.06], // [51.52, -0.03] // ]); // // polygon.editing.enable(); // // polygon.on('contextmenu',function (e) { // console.log(this); // }); // // polygon.addTo(map); // map.on(BM.Draw.Event.EDITSTOP,function () { // console.log(this); // }); //監聽繪畫完成事件 map.on(BM.Draw.Event.CREATED, function (e) { var layer = e.layer; console.log(e.layer); drawnItems.addLayer(layer); }); //設置一個變量來保存當前的繪制對象 var draw; document.querySelector('#start').onclick=function () { if (!draw){ draw=new BM.Draw.Polygon(map); } draw.enable(); } </script> </body> </html>