Location:

Overlay Group

Overlay group OverlayGroup

When a user needs to do a whole operation on a set of overlays, they can use the instance created by the OverlayGroup class to avoid setting the properties one by one through loops.

                    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, //Set the line overlay path
                        "line-join": 'round',
                        "line-cap": 'round',
                        "line-width":8,
                        'line-blur':0,
                    });

                    Var polygonArr = new Array();//polygon overlay node coordinate 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, // ​​set the polygon boundary path
                        'fill-antialias': true,
                        'fill-outline-color': 'red',
                        'fill-opacity': 0.8,
                        "line-width": 10,
                    });

                    var circle = new nimap.Circle({
                        Center: "116.40,39.92",// center position
                        Radius: 1000, //radius
                        '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));
                    })
                
TOP