K
K
Kirill Gorelov2019-03-24 20:46:13
JavaScript
Kirill Gorelov, 2019-03-24 20:46:13

Display labels on the map, an error occurs?

Guys, I've been driving for the second day.
I need to display labels on a map and do clustering.
I use this example https://tech.yandex.ru/maps/jsbox/2.1/clusterer_create
From the example everything works. I slip my labels on it, the following error occurs.
5c97c025537a4480555251.png
The data itself is stored in this form:
5c97c0be85868659312214.png
I get the labels like this

$.ajax({
    url: "ajax.php",
    async: false,
    data: ({'op': 'getcoord'}),
    dataType: "json",
    success: function(data){
      // console.log(data+' vv');
      let i = 0;
      data.forEach(function(item) {
        console.log(item);
                let coord = item.PROPERTY_COORD_VALUE;
        if(coord === ''){
          return true;
        }
        coord = coord.split(",");//пробовал и без этого
        i++;
        
        geoObjects[i] = new ymaps.Placemark(coord, getPointData(i), getPointOptions());
      });
    }
  });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pashted, 2019-03-24
@Kirill-Gorelov

if the coordinates are already known, you can use this example. you only need to convert the data to the form of an array dots

click
ymaps.ready(
    () => {
        let Map = new ymaps.Map('map', {
                center: [55.753994, 37.622093],
                zoom:   10
            }),
            objectManager = new ymaps.ObjectManager({
                clusterize: true,
                gridSize:   32,
            }),
            dots = [
                {
                    "type":       "Feature",
                    "id":         1,
                    "geometry":   {
                        "type":        "Point",
                        "coordinates": [54.753215, 36.622504]
                    },
                    "icon":       "darkGreenDotIcon",
                    "address":    "Москва",
                    "properties": {
                        'iconCaption':        "caption",
                        'balloonContentBody': "Balloon",
                    }
                },
                {
                    "type":       "Feature",
                    "id":         2,
                    "geometry":   {
                        "type":        "Point",
                        "coordinates": [53.753215, 34.622504]
                    },
                    "icon":       "darkGreenDotIcon",
                    "address":    "Брянск",
                    "properties": {
                        'iconCaption':        "caption",
                        'balloonContentBody': "Balloon",
                    }
                },
                {
                    "type":       "Feature",
                    "id":         3,
                    "geometry":   {
                        "type":        "Point",
                        "coordinates": [55.753215, 37.622504]
                    },
                    "icon":       "darkGreenDotIcon",
                    "address":    "Санкт-Петербург",
                    "properties": {
                        'iconCaption':        "caption",
                        'balloonContentBody': "Balloon",
                    }
                }
            ];

        Map.geoObjects.add(objectManager);

        objectManager.add({
            "type":     "FeatureCollection",
            "features": dots
        });
        Map.setBounds(objectManager.getBounds(), { checkZoomRange: true });
    }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question