yandex-mapsyandex-api

Disable clusters in Yandex Maps API


I have an Yandex Maps installed on my project

Code below display an cluster view of all objects. What I would like to do is disable clusters

    $.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);

    });

Solution

  • The thing is that ymaps.geoQuery doesn't return coordinates (or a GeoObjectCollection for that matter). What it returns is GeoQueryResult. Here what you can do to add results of geoQuery to a map:

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