NativeGeocoderReverseResult 在 ionic4 + 电容器中导入时出错

阿希拉奈尔

从本机地理编码器导入 NativeGeocoderReverseResult 时出错。我正在使用带有电容器的 ionic4

导入 { NativeGeocoder, NativeGeocoderReverseResult, , NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx'; 除了 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));
  }


}

拉斐尔·迈耶

NativeGeocoderReverseResult 不再是 Ionic 的一部分。插件 (native-geocoder) 已更新至 3.2.0。文档已弃用。建议使用新的导入语句:

import { NativeGeocoder, NativeGeocoderResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';

使用以下代码:

let options: NativeGeocoderOptions = {
      useLocale: true,
      maxResults: 5
  };

  this.nativeGeocoder.reverseGeocode(52.5072095, 13.1452818, options)
    .then((result: NativeGeocoderResult[]) => console.log(JSON.stringify(result[0])))
    .catch((error: any) => console.log(error));

  this.nativeGeocoder.forwardGeocode('Berlin', options)
    .then((result: NativeGeocoderResult[]) => console.log('The coordinates are latitude=' + result[0].latitude + ' and longitude=' + result[0].longitude))
    .catch((error: any) => console.log(error));

如您所见,NativeGeocorderReverseResultNativeGeocoderForwardResult都被NativeGeocoderResult替换

更多信息请参见源代码:https : //github.com/ionic-team/ionic-native/blob/4de49c37dd9bd23799b089595db998ade34a9c88/src/%40ionic-native/plugins/native-geocoder/index.ts

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用电容器,Ionic4中的“ CameraPhoto”类型上不存在属性“ base64Data”

来自分类Dev

带电容器的Ionic 5推送通知

来自分类Dev

Ionic 4电容器选择适用于Android和IOS的文件

来自分类Dev

IONIC 4+电容器:如何在没有ionic native的情况下从github安装Cordova插件(Stepcounter)?

来自分类Dev

如何在带电容器的Ionic中更新iOS和Android应用版本?

来自分类Dev

混合JavaScript移动开发-Apache Cordova与带有Ionic的电容器,NativeScript与React Native

来自分类Dev

在商店上发布APK-Ionic V5 /电容器/角度-权限问题

来自分类Dev

IONIC电容器删除iOS和Android中不必要的权限

来自分类Dev

来自外部URL的Ionic 5电容器/角度预览文件

来自分类Dev

离子电容器版本找不到符号android.support.v4.app.ActivityCompat

来自分类Dev

如何在iOS的Ionic电容器中为登录表单打开Webview自动完成功能?

来自分类Dev

Ionicons在Ionic4中返回404

来自分类Dev

SocialSharing Ionic4 Angular 8

来自分类Dev

Ionic 5 /电容器:如何确定应用程序是在浏览器中运行还是作为本机应用程序编译?

来自分类Dev

ionic: 不能做 prod build appRate ionic4

来自分类Dev

离子4(非电容器)构建失败,出现@ firebase / logger错误[TS1068:无法在环境上下文中声明访问器]

来自分类Dev

使用电容器和离子显示图像时出错

来自分类Dev

使用“电容器”构建“离子角”应用程序时出错

来自分类Dev

离子电容器内部编号

来自分类Dev

电容器本地通知抬头

来自分类Dev

电容器-设置cors的原点

来自分类Dev

Ionic4 / Angular在Twitter上发布推文

来自分类Dev

打印过滤的数组(对象)ionic4 / angular

来自分类Dev

使用ngif ionic4过滤ngfor中的json数据

来自分类Dev

Ionic4中的导航页面重叠

来自分类Dev

隐藏页脚当键盘打开ionic4时

来自分类Dev

ionic4 Facebook登录捕获“用户”被取消为错误

来自分类Dev

ionic4 形式的密码和确认密码匹配验证

来自分类Dev

ionic4 在模板中显示对象类型数据

Related 相关文章

  1. 1

    使用电容器,Ionic4中的“ CameraPhoto”类型上不存在属性“ base64Data”

  2. 2

    带电容器的Ionic 5推送通知

  3. 3

    Ionic 4电容器选择适用于Android和IOS的文件

  4. 4

    IONIC 4+电容器:如何在没有ionic native的情况下从github安装Cordova插件(Stepcounter)?

  5. 5

    如何在带电容器的Ionic中更新iOS和Android应用版本?

  6. 6

    混合JavaScript移动开发-Apache Cordova与带有Ionic的电容器,NativeScript与React Native

  7. 7

    在商店上发布APK-Ionic V5 /电容器/角度-权限问题

  8. 8

    IONIC电容器删除iOS和Android中不必要的权限

  9. 9

    来自外部URL的Ionic 5电容器/角度预览文件

  10. 10

    离子电容器版本找不到符号android.support.v4.app.ActivityCompat

  11. 11

    如何在iOS的Ionic电容器中为登录表单打开Webview自动完成功能?

  12. 12

    Ionicons在Ionic4中返回404

  13. 13

    SocialSharing Ionic4 Angular 8

  14. 14

    Ionic 5 /电容器:如何确定应用程序是在浏览器中运行还是作为本机应用程序编译?

  15. 15

    ionic: 不能做 prod build appRate ionic4

  16. 16

    离子4(非电容器)构建失败,出现@ firebase / logger错误[TS1068:无法在环境上下文中声明访问器]

  17. 17

    使用电容器和离子显示图像时出错

  18. 18

    使用“电容器”构建“离子角”应用程序时出错

  19. 19

    离子电容器内部编号

  20. 20

    电容器本地通知抬头

  21. 21

    电容器-设置cors的原点

  22. 22

    Ionic4 / Angular在Twitter上发布推文

  23. 23

    打印过滤的数组(对象)ionic4 / angular

  24. 24

    使用ngif ionic4过滤ngfor中的json数据

  25. 25

    Ionic4中的导航页面重叠

  26. 26

    隐藏页脚当键盘打开ionic4时

  27. 27

    ionic4 Facebook登录捕获“用户”被取消为错误

  28. 28

    ionic4 形式的密码和确认密码匹配验证

  29. 29

    ionic4 在模板中显示对象类型数据

热门标签

归档