When using Search.autocomplete and getting the results, each search result object has coordinate which have 13 decimal places. When you use Geocoder.reverseLookup for these coordinates, it returns the wrong address and different coordinates (6 decimal places and different as well). What works is using Geocoder.lookup (with getsUserLocation as true) and putting in the Search.autocomplete displayLines (as a string) for the query. Am I doing something wrong or is this a bug?
Code:
const exampleQuery = '<example address>';
const search = new mapkit.Search({
getsUserLocation: true,
});
search.autocomplete(
exampleQuery,
(error, data) => {
if (error) {
console.error('Search error:', error);
return;
}
const { coordinate } = data.results[0];
console.log("Autocomplete coordinate", coordinate); // Lat and lng are both have 13 decimal places
const geoCoder = new mapkit.Geocoder({});
geoCoder.reverseLookup(
new mapkit.Coordinate(coordinate.latitude, coordinate.longitude),
(error, data) => {
const { formattedAddress, coordinate } = data.results[0];
console.log(formattedAddress, coordinate); // Not the same address from example query and from the search autocomplete, also the coordinate has 7 decimal places
}
);
},
{}
);