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://www.kenshimo.com/reader/download/detail201802017.html --> <link href='http://www.kenshimo.com:9000/bigemap.js/v2.1.0/bigemap.css' rel='stylesheet' /> <!-- JS地址請使用: http://localhost:9000/bigemap.js/v2.1.0/bigemap.js --> <script src='http://www.kenshimo.com:9000/bigemap.js/v2.1.0/bigemap.js'></script> <!--引入對應的JS+CSS 相關下載地址 http://www.kenshimo.com/Public/offline/marker_cluster/cluster.zip--> <link rel="stylesheet" href="/Public/offline/marker_cluster/MarkerCluster.Default.css" /> <script src="/Public/offline/marker_cluster/bm.markercluster-src.js"></script> <style type="text/css"> *{ padding: 0; margin: 0; } html,body,#map{ width: 100%; height: 100%; } </style> </head> <body> <div id="map"></div> <script type="text/javascript"> // 軟件配置信息地址,軟件安裝完成之后使用本地地址,如:http://localhost:9000 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: [0, 0], zoom: 2, zoomControl: true,attributionControl:false }); //登陸聚合對象 var markers = new BM.MarkerClusterGroup({ showCoverageOnHover: false,//不顯示邊框 zoomToBoundsOnClick: true,//點擊放大 removeOutsideVisibleBounds: true,//只顯示當前窗口內的內容, //使用定義的圖標來顯示 //iconCreateFunction: function (cluster) { // var markers = cluster.getAllChildMarkers(); // return BM.divIcon({ html: markers.length, iconSize: BM.point(40, 40) }); //} }); var markersList = []; //生成多個點 function populate() { for (var i = 0; i < 3000; i++) { var m = new BM.Marker(getRandomLatLng(map)); markersList.push(m); markers.addLayer(m); } return false; } //根據當前的范圍生成隨機的點 function getRandomLatLng(map) { var bounds = map.getBounds(), southWest = bounds.getSouthWest(), northEast = bounds.getNorthEast(), lngSpan = northEast.lng - southWest.lng, latSpan = northEast.lat - southWest.lat; return new BM.LatLng( southWest.lat + latSpan * Math.random(), southWest.lng + lngSpan * Math.random()); } //對聚合的實例添加一個點擊事件。 markers.on('clusterclick', function (a) { alert('cluster ' + a.layer.getAllChildMarkers().length); }); //對標注添加一個點擊事件 markers.on('click', function (a) { alert('marker ' + a.layer); }); populate(); map.addLayer(markers); </script> </body> </html>