覆盖物群组
覆盖物群组 OverlayGroup
当用户需要对一组覆盖物集合做整体操作时,可以使用 OverlayGroup 类创建的实例来操作,以避免通过循环来一个个设置属性。
var lineArr = [ [116.37, 39.91], [116.38, 39.90], [116.39, 39.91], [116.40, 39.90] ]; var polyline = new nimap.Polyline({ path: lineArr, //设置线覆盖物路径 "line-join": 'round', "line-cap": 'round', "line-width":8, 'line-blur':0, }); var polygonArr = new Array();//多边形覆盖物节点坐标数组 polygonArr.push([116.40, 39.92]); polygonArr.push([116.41, 39.90]); polygonArr.push([116.40, 39.89]); polygonArr.push([116.39, 39.89]); polygonArr.push([116.40, 39.92]); var polygon = new nimap.Polygon({ path: polygonArr,//设置多边形边界路径 'fill-antialias': true, 'fill-outline-color': 'red', 'fill-opacity': 0.8, "line-width": 10, }); var circle = new nimap.Circle({ center: "116.40,39.92",// 圆心位置 radius: 1000, //半径 'fill-antialias': true, 'fill-outline-color': 'red', "line-width": 10, }); var overlayGroup = new nimap.OverlayGroup([ polyline, polygon, circle ]); map.on('load',function () { //polyline.addTo(map); //polygon.addTo(map); //circle.addTo(map); overlayGroup.addTo(map); map.setFitView(polyline.path.concat(polygon.path).concat(circle.path)); })