BIGEMPA Js API示例中心
<!DOCTYPE html>
<html>
<head>
<title>draw</title>
<!--
以下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.bigemap.com/reader/download/detail201802017.html
-->
<link href='http://www.bigemap.com:9000/bigemap.js/v2.1.0/bigemap.css' rel='stylesheet' />
<script src='http://www.bigemap.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>
</head>
<style type="text/css">
html,body,#map{
width: 100%;
height: 100%;
}
.bigemap-draw-section{top:50px;}
</style>
<body>
<div id="map">
</div>
<script>
//软件配置信息地址,软件安装完成之后使用本地地址,如:
//http://localhost:9000
BM.Config.HTTP_URL = 'http://www.bigemap.com:9000';
// 在ID为map的元素中实例化一个地图,并设置地图的ID号为 bigemap.zhongkexingtu,ID号程序自动生成,无需手动配置,并设置地图的投影为百度地图 ,中心点,默认的级别和显示级别控件
var map = BM.map('map', 'bigemap.zhongkexingtu', {center: [30, 104], zoom: 8, zoomControl: true,attributionControl:false });
//创建一个图形覆盖物的集合来保存点线面
var drawnItems = new BM.FeatureGroup();
//添加在地图上
map.addLayer(drawnItems);
// 为多边形设置一个标题
BM.drawLocal.draw.toolbar.buttons.polygon = '添加一个多边形';
//实例化鼠标绘制的控件
var drawControl = new BM.Control.Draw({
position: 'topright',//位置
//控制绘制的图形
draw: {
polyline: {
//单独设置线的颜色为红色,其它为默认颜色
shapeOptions:{
color:'red'
}
},
polygon: true,
circle: true,
marker: true
},
edit: { featureGroup: drawnItems }
});
map.addControl(drawControl);
//监听绘画完成事件
map.on(BM.Draw.Event.CREATED, function (e) {
var type = e.layerType, layer = e.layer;
if (type === 'marker') {
//如果是标注,实现一个点击出现的提示
layer.bindPopup('A popup!');
}
drawnItems.addLayer(layer);
});
</script>
</body>
</html>