A
A
a_donov2018-05-26 20:45:25
Yandex
a_donov, 2018-05-26 20:45:25

How to generate an object address for the Yandex.Realty feed?

I am developing a feed for Yandex.Real Estate and noticed an interesting topic - you need to pass the address of the object in several fields:
country - The country in which the object is located.
region - The name of the subject of the Russian Federation.
district - The name of the district of the subject of the Russian Federation.
locality-name - Locality name.
sub-locality-name - The area of ​​the settlement.
address - Street and house number.
Yandex Geocoder, when adding an object to the database, forms a line like:
Russia, Moscow, Potapovsky lane, 9
How would you like to parse this address into 6 columns?
Example of other objects:
Russia, Moscow region, Ramensky district, Kratovo holiday village, International street, 19
Here, too, there are no 6 columns.
Maybe there is a solution, using coordinates, to unload all the fields in the Yandex Geocoder output?
There must be a way out somewhere. Somehow people use xml unloading...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
a_donov, 2018-06-04
@a_donov

//формируем объект со всей выдачей геокодера
var kinds = firstGeoObject.properties.get('metaDataProperty.GeocoderMetaData.Address.Components');
var kinder = kinds.reduce(function(prev, curr) {
  prev[curr.kind] = curr.name;
  return prev;
}, {});
kinder = JSON.stringify(kinder).replace(/\[|\]/g, '');
              
//определяем район города
var raion = '';
ymaps.geocode(ads, { kind: 'district' }).then(function(res2) {
  raion += res2.geoObjects.get(0).properties.get('name');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question