U
U
uzi_no_uzi2020-03-22 16:55:01
JavaScript
uzi_no_uzi, 2020-03-22 16:55:01

How to get the coordinates of all points on the yandex map?

I want to implement point filters by country, city and region.

I think to do it this way:

1. Get the coordinates of all points on the page (points are added by users to the map (there is a button "add a label"))
2. Get data about each point using reverse geocoding (That's what I need the coordinates for)
3 Next, filter these points depending on the country, region, city

I tried to get the coordinates of all points through this method , but it didn’t work out for me:

myMap.GeoObjects(ymaps);
GeoObjects(myMap);
myMap.GeoObjects(myMap);
ymaps.GeoObjects(myMap);
myMap.GetObjects;


Can this be done somehow easier, what are the options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kolotilkyn, 2020-03-23
@asurahan

here is a piece of code from my application.

MapClick(e){
                var coords = e.get('coords');
                tmp = {
                    id: 4,
                    coords: coords,
                    icon: {content: coords}};
// тут вся магия. ymaps.geocode прочитай про это в документации
                    var geo = ymaps.geocode(coords);
                    geo.then((res)=>{
                            var firstGeoObject = res.geoObjects.get(0);
                            console.log(firstGeoObject.properties.get('text'));
                            var objs = res.geoObjects.toArray();
                                var YmapCoords = objs[0].geometry.getCoordinates();
                            },
                            function (err) {
                                // Обработка ошибки.
                            }
                        );
//                console.log(tmp);
            }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question