Bing使用群集映射方向

问题描述 投票:0回答:1

我可以用机动点绘制地图。

下面是地图的屏幕截图

enter image description here

以下是路由的代码。

var maneuverPoints = this.model.get("maneuverPoints");
        if (maneuverPoints) {
            var routePoints = [];
            _.each(maneuverPoints, function (point) {
                routePoints.push(new MsMaps.Location(point.latitude, point.longitude));
            });
            var routeOptions = {
                strokeColor: new MsMaps.Color(1, 65, 255, 35),
                strokeThickness: 3
            };
            var routeShape = new MsMaps.Polyline(routePoints, routeOptions);
            map.entities.push(routeShape);
        }

现在我正在尝试实现群集,我能够按如下方式执行:

enter image description here

粉色图钉是簇。

群集代码如下:

Microsoft.Maps.loadModule(“Microsoft.Maps.Clustering”,function(){

                var clusterLayer = new Microsoft.Maps.ClusterLayer(pushpins);
                map.layers.insert(clusterLayer);

                clusterLayer.setPushpins(pushpins);
                map.setView(viewOptions);
                var maneuverPoints = this.model.get("maneuverPoints");
                if (maneuverPoints) {
                    var routePoints = [];
                    _.each(maneuverPoints, function (point) {
                        routePoints.push(new MsMaps.Location(point.latitude, point.longitude));
                    });
                    var routeOptions = {
                        strokeColor: new MsMaps.Color(1, 65, 255, 35),
                        strokeThickness: 3
                    };
                    var routeShape = new MsMaps.Polyline(routePoints, routeOptions);
                    map.entities.push(routeShape);
                }

我无法同时进行群集和路由。有可能同时做两件事吗?

bing-maps
1个回答
0
投票

你的代码没有根据事物的外观做路由,它只是采用路线线点并将它们渲染为折线。我没有看到代码中使用的指示模块。如果您正在使用该指示模块,为什么不简单地使用内置渲染?您可以自定义它的外观。如果您继续使用折线,请考虑将其添加到图层,以便以后更轻松地进行管理。

也就是说,您提供的代码只是聚类和绘制折线。当我测试这个场景时,这很好用。

您在集群层中调用setPushpins的原因是什么?您在创建图层时已经通过了图钉,无需再次传入它们。

© www.soinside.com 2019 - 2024. All rights reserved.