Answer the question
In order to leave comments, you need to log in
How to split the address received from Yandex maps geolocation?
Hello!
I get the address from the geolocation as an object, and depending on the accuracy of the entered address, certain nested properties are missing, so errors sometimes come out with direct access.
It would be possible to provide all the options (if-else is a perversion, but as an option), but I don’t know them :(
Maybe there is a ready-made solution to get separately "city", "street", "house", etc.?
Or can someone tell me how to make a one-dimensional "key" => "value" from a multidimensional object? My knowledge is not enough :(
Please help :)
Answer the question
In order to leave comments, you need to log in
The solution was suggested in the Maps API Club.
The solution is the GeocodeResult
constructor
Here is an example code snippet:
multiRoute.model.events.add('requestsuccess', function(e) {
var startPointProps = multiRoute.getWayPoints().get(0),
startPoint.properties.getAll();
var geocodeResult = new ymaps.GeocodeResult({
properties: {
...startPointProps,
metaDataProperty: {
GeocoderMetaData: startPointProps.geocoderMetaData
}
}
});
console.log(geocodeResult.getAddressLine())
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question