M
M
Maxim Nikitin2014-08-06 22:13:05
JavaScript
Maxim Nikitin, 2014-08-06 22:13:05

Why don't Yandex.Maps clusters work?

I'm trying to run some pretty simple code.

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>demo</title>
  <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
</head>
<body>
    <script type="text/javascript">
        ymaps.ready(init);
        var myMap;
        var myGeoObjects = [];

        function init() {
            myMap = new ymaps.Map("map", {
                center: [55.76, 37.64],
                zoom: 7
            });
        }

        var coords = [
           [56.023, 36.988],
           [56.025, 36.981],
           [56.020, 36.981],
           [56.021, 36.983],
           [56.027, 36.987]
        ]

        for (var i = 0; i < coords.length; i++) {
            myGeoObjects[i] = new ymaps.GeoObject({
                geometry: {
                    type: "Point",
                    coordinates: coords[i]
                }
            });
        }

        var myClusterer = new ymaps.Clusterer();
        myClusterer.add(myGeoObjects);
        myMap.geoObjects.add(myClusterer);
    </script>
 <div id="map" style="width: 500px; height: 500px">
</div>
</body>
</html>

However, I get "Undefined is not a function" in the line
myGeoObjects[i] = new ymaps.GeoObject
Not strong in JS, open your eyes. Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petrov, 2014-08-06
@MaxSter

codepen.io/cleric/pen/LFKsJ

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question