Atomic services can obtain the place information corresponding to the longitude and latitude through the place search service. Before development, complete the configuration by following the instructions provided in Preparations.
Refer to the sample code below:
import { site } from '@kit.MapKit';
@Entry
@Component
struct Demo {
build() {
Button('Query reverse geocoding')
.onClick(async () => {
let params: site.ReverseGeocodeParams = {
location: {
latitude: 31.984410259206815,
longitude: 118.76625379397866
},
language: 'en',
radius: 200
};
try {
const result = await site.reverseGeocode(params);
console.info('Succeeded in querying reverse geocoding: ${JSON.stringify(result)}`);
} catch (err) {
console.error('Failed to query reverse geocoding, fail err = ${JSON.stringify(err)}`);
}
})
}
} Reference