{"id":28470605,"url":"https://github.com/octmon/amap_flutter_location","last_synced_at":"2025-07-01T17:31:04.043Z","repository":{"id":278113604,"uuid":"934546271","full_name":"OctMon/amap_flutter_location","owner":"OctMon","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-18T03:26:50.000Z","size":79,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-07T09:44:37.304Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OctMon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-18T02:35:43.000Z","updated_at":"2025-02-18T03:26:53.000Z","dependencies_parsed_at":"2025-02-18T04:36:09.405Z","dependency_job_id":null,"html_url":"https://github.com/OctMon/amap_flutter_location","commit_stats":null,"previous_names":["octmon/amap_flutter_location"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/OctMon/amap_flutter_location","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OctMon%2Famap_flutter_location","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OctMon%2Famap_flutter_location/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OctMon%2Famap_flutter_location/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OctMon%2Famap_flutter_location/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OctMon","download_url":"https://codeload.github.com/OctMon/amap_flutter_location/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OctMon%2Famap_flutter_location/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263007081,"owners_count":23398759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-07T09:40:01.528Z","updated_at":"2025-07-01T17:31:04.035Z","avatar_url":"https://github.com/OctMon.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"##  前述 \n\n1. 高德定位Flutter插件\n2. 登录[高德开放平台官网](https://lbs.amap.com/api/)分别申请[Android端](https://lbs.amap.com/api/android-location-sdk/guide/create-project/get-key/)和[iOS端](https://lbs.amap.com/api/ios-location-sdk/guide/create-project/get-key)的key\n3. 如需了解高德定位SDK的相关功能，请参阅[Android定位SDK开发指南](https://lbs.amap.com/api/android-location-sdk/locationsummary/)和[iOS定位SDK开发指南](https://lbs.amap.com/api/ios-location-sdk/summary/)\n\n\n## 使用高德定位Flutter插件\n* 请参考[在Flutter里使用Packages](https://flutter.cn/docs/development/packages-and-plugins/using-packages)， 引入amap_flutter_location插件\n* 引入高德定位SDK，Android平台请参考[Android Sudio配置工程](https://lbs.amap.com/api/android-location-sdk/guide/create-project/android-studio-create-project), iOS平台请参考[ios安装定位SDK](https://lbs.amap.com/api/ios-location-sdk/guide/create-project/cocoapods)\n\n### 常见问题：\n1、[在iOS设备上运行或者运行iOS工程遇到： `Invalid `Podfile` file: cannot load such file - /flutter/packages/flutter_tools/bin/podhelper`](https://github.com/flutter/flutter/issues/59522)\n```\n$ rm ios/Podfile\n$ flutter build ios\n```\n\n\n### 在需要的定位功能的页面中引入定位Flutter插件的dart类\n``` Dart\nimport 'package:amap_flutter_location_plus/amap_flutter_location_plus.dart';\nimport 'package: amap_flutter_location_plus/amap_location_option.dart';\n```\n## 接口说明\n\n### 设置定位参数\n``` Dart\n /// 设置定位参数\n void setLocationOption(AMapLocationOption locationOption)\n```\n\u003e 将您设置的参数传递到原生端对外接口，目前支持以下定位参数\n\n``` Dart\n //// 是否需要地址信息，默认true\n  bool needAddress = true;\n\n  ///逆地理信息语言类型\u003cbr\u003e\n  ///默认[GeoLanguage.DEFAULT] 自动适配\u003cbr\u003e\n  ///可选值：\u003cbr\u003e\n  ///\u003cli\u003e[GeoLanguage.DEFAULT] 自动适配\u003c/li\u003e\n  ///\u003cli\u003e[GeoLanguage.EN] 英文\u003c/li\u003e\n  ///\u003cli\u003e[GeoLanguage.ZH] 中文\u003c/li\u003e\n  GeoLanguage geoLanguage;\n\n  ///是否单次定位\n  ///默认值：false\n  bool onceLocation = false;\n\n  ///Android端定位模式, 只在Android系统上有效\u003cbr\u003e\n  ///默认值：[AMapLocationMode.Hight_Accuracy]\u003cbr\u003e\n  ///可选值：\u003cbr\u003e\n  ///\u003cli\u003e[AMapLocationMode.Battery_Saving]\u003c/li\u003e\n  ///\u003cli\u003e[AMapLocationMode.Device_Sensors]\u003c/li\u003e\n  ///\u003cli\u003e[AMapLocationMode.Hight_Accuracy]\u003c/li\u003e\n  AMapLocationMode locationMode;\n\n  ///Android端定位间隔\u003cbr\u003e\n  ///单位：毫秒\u003cbr\u003e\n  ///默认：2000毫秒\u003cbr\u003e\n  int locationInterval = 2000;\n\n  ///iOS端是否允许系统暂停定位\u003cbr\u003e\n  ///默认：false\n  bool pausesLocationUpdatesAutomatically = false;\n\n  /// iOS端期望的定位精度， 只在iOS端有效\u003cbr\u003e\n  /// 默认值：最高精度\u003cbr\u003e\n  /// 可选值：\u003cbr\u003e\n  /// \u003cli\u003e[DesiredAccuracy.Best] 最高精度\u003c/li\u003e\n  /// \u003cli\u003e[DesiredAccuracy.BestForNavigation] 适用于导航场景的高精度 \u003c/li\u003e\n  /// \u003cli\u003e[DesiredAccuracy.NearestTenMeters] 10米 \u003c/li\u003e\n  /// \u003cli\u003e[DesiredAccuracy.Kilometer] 1000米\u003c/li\u003e\n  /// \u003cli\u003e[DesiredAccuracy.ThreeKilometers] 3000米\u003c/li\u003e\n  DesiredAccuracy desiredAccuracy = DesiredAccuracy.Best;\n\n  /// iOS端定位最小更新距离\u003cbr\u003e\n  /// 单位：米\u003cbr\u003e\n  /// 默认值：-1，不做限制\u003cbr\u003e\n  double distanceFilter = -1;\n\n  ///iOS 14中设置期望的定位精度权限\n  AMapLocationAccuracyAuthorizationMode desiredLocationAccuracyAuthorizationMode = AMapLocationAccuracyAuthorizationMode.FullAccuracy;\n\n  /// iOS 14中定位精度权限由模糊定位升级到精确定位时，需要用到的场景key fullAccuracyPurposeKey 这个key要和plist中的配置一样\n  String fullAccuracyPurposeKey = \"\";\n```\n### 开始定位\n``` Dart\nvoid startLocation()\n```\n### 停止定位\n``` Dart\nvoid stopLocation()\n```\n### 销毁定位\n\u003e 高德定位Flutter插件，支持多实例，请在weidet执行dispose()时调用当前定位插件的销毁方法\n``` Dart\nvoid destroy()\n```\n### 定位结果获取\n\u003e 原生端以键值对map的形式回传定位结果到Flutter端, 通过onLoationChanged返回定位结果\n\n``` Dart\nStream\u003cMap\u003cString, Object\u003e\u003e onLocationChanged(）\n```\n\n\u003e 注册定位结果监听\n\n``` Dart\n\n_locationPlugin\n        .onLocationChanged()\n        .listen((Map\u003cString, Object\u003e result) {\n          ///result即为定位结果\n        }\n```\n \n 定位结果是以map的形式返回的，具体内容为\n ``` Dart\n \n /// `callbackTime`:回调时间，格式为\"yyyy-MM-dd HH:mm:ss\"\n  ///\n  /// `locationTime`:定位时间， 格式为\"yyyy-MM-dd HH:mm:ss\"\n  ///\n  /// `locationType`:  定位类型， 具体类型可以参考https://lbs.amap.com/api/android-location-sdk/guide/utilities/location-type\n  ///\n  /// `latitude`:纬度\n  ///\n  /// `longitude`:精度\n  ///\n  /// `accuracy`:精确度\n  ///\n  /// `altitude`:海拔, android上只有locationType==1时才会有值\n  ///\n  /// `bearing`: 角度，android上只有locationType==1时才会有值\n  ///\n  /// `speed`:速度， android上只有locationType==1时才会有值\n  ///\n  /// `country`: 国家，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `province`: 省，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `city`: 城市，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `district`: 城镇（区），android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `street`: 街道，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `streetNumber`: 门牌号，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `cityCode`: 城市编码，android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `adCode`: 区域编码， android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `address`: 地址信息， android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `description`: 位置语义， android上只有通过[AMapLocationOption.needAddress]为true时才有可能返回值\n  ///\n  /// `errorCode`: 错误码，当定位失败时才会返回对应的错误码， 具体错误请参考：https://lbs.amap.com/api/android-location-sdk/guide/utilities/errorcode\n  ///\n  /// `errorInfo`: 错误信息， 当定位失败时才会返回\n  \n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctmon%2Famap_flutter_location","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foctmon%2Famap_flutter_location","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foctmon%2Famap_flutter_location/lists"}