从本地地理编码器导入 NativeGeocoderReverseResult 时出错。我正在使用带电容器的 ionic4
从 '@ionic-native/native-geocoder/ngx' 导入 { NativeGeocoder, NativeGeocoderReverseResult, , NativeGeocoderOptions };除了 NativeGeocoderForwardResult 之外的所有内容都在导入且没有错误
import { Component } from '@angular/core';
import { Plugins, Capacitor, CameraSource, CameraResultType, CameraDirection, Camera, Geolocation } from '@capacitor/core';
import { NativeGeocoder, NativeGeocoderReverseResult, NativeGeocoderForwardResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
selectedImage: string;
coordinates: { lat: number; long: number; };
resultValue: any;
constructor(private mediaCapture: MediaCapture, private alertcontroller: AlertController, private nativeGeocoder: NativeGeocoder) {
this.getLocation();
}
getLocation() {
if (!Capacitor.isPluginAvailable('Geolocation')) {
this.alertcontroller.create({header: 'could not fetch location'});
return;
}
Plugins.Geolocation.getCurrentPosition().then(position => {
this.coordinates = { lat: position.coords.latitude, long: position.coords.longitude};
console.log('coordinates-oojj', this.coordinates);
});
const options: NativeGeocoderOptions = {
useLocale: true,
maxResults: 5
};
this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818, options)
.then((result: NativeGeocoderReverseResult[]) => {
this.resultValue = result;
console.log('resultValue',this.resultValue)
console.log(JSON.stringify(result[0]))}
)
.catch((error: any) => console.log(error));
}
}