【问题标题】:Disable clusters in Yandex Maps API在 Yandex Maps API 中禁用集群
【发布时间】:2016-08-17 00:54:51
【问题描述】:

我的项目中安装了 Yandex 地图

下面的代码显示所有对象的集群视图。 我想做的是禁用集群

    $.getJSON( ymFormAction , "ymJSON=1" ).done( function (json) {

        window.geoObjects = ymaps.geoQuery(json);

        window.clusters = geoObjects.search("geometry.type == 'Point'").clusterize({preset: 'islands#invertedblueClusterIcons'});
        myMap[[+idMap]].geoObjects.add(clusters);

        // Trying to disable clusters
        var coords = geoObjects;
        // coords should be = [[56.023, 36.988]] according to API

        var myCollection = new ymaps.GeoObjectCollection();
        for (var i = 0; i<coords.length; i++) {
            myCollection.add(new ymaps.Placemark(coords[i]));
        }
        myMap[[+idMap]].geoObjects.add(myCollection);

    });

【问题讨论】:

    标签: yandex-maps yandex-api


    【解决方案1】:

    问题是ymaps.geoQuery 不返回坐标(或GeoObjectCollection)。它返回的是GeoQueryResult。您可以在这里将geoQuery 的结果添加到地图中:

    ymaps.geoQuery(json).search("geometry.type == 'Point'").addToMap(yourMap);
    

    【讨论】:

    • 这将导致一个空地图
    • 我已经确定了答案。
    猜你喜欢
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    • 2011-12-16
    • 1970-01-01
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多