All Projects → best-flutter → Flutter_amap_location

best-flutter / Flutter_amap_location

Licence: mit
高德地图flutter定位组件

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Flutter amap location

Easydeviceinfo
📱 [Android Library] Get device information in a super easy way.
Stars: ✭ 1,698 (+568.5%)
Mutual labels:  location
Ulogger Android
μlogger • android application for real-time collection and publishing of geolocation data
Stars: ✭ 168 (-33.86%)
Mutual labels:  location
Use Position
🌍 React hook usePosition() for fetching and following a browser geolocation
Stars: ✭ 230 (-9.45%)
Mutual labels:  location
Corelocationcli
Command line program to print location information from CoreLocation
Stars: ✭ 138 (-45.67%)
Mutual labels:  location
Locationsimulator
MacOS 10.15 / 11.0 application to spoof your iOS / iPadOS or iPhoneSimulator device location. WatchOS and TvOS are partially supported.
Stars: ✭ 157 (-38.19%)
Mutual labels:  location
React Native Google Place Picker
React Native Wrapper of Google Place Picker for iOS + Android.
Stars: ✭ 180 (-29.13%)
Mutual labels:  location
Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (-48.03%)
Mutual labels:  location
React Router Last Location
Provides access to the last location in react + react-router (v4.x, v5.x) applications. ❤️ Using hooks? useLastLocation | 💉 Using HOC? withLastLocation
Stars: ✭ 251 (-1.18%)
Mutual labels:  location
Laravel Location
A simple Laravel Package to sort Countries, States and Cities
Stars: ✭ 162 (-36.22%)
Mutual labels:  location
Actingweb firstapp
Starter app for Flutter that includes many different production app features; some not typically included in demo apps.
Stars: ✭ 224 (-11.81%)
Mutual labels:  location
App Dirs Rs
Put your Rust app's data in the right place on every platform
Stars: ✭ 147 (-42.13%)
Mutual labels:  location
Aglocationdispatcher
Location manage framework working in different modes
Stars: ✭ 151 (-40.55%)
Mutual labels:  location
City Geo
🌄 中国城市经纬度数据。
Stars: ✭ 196 (-22.83%)
Mutual labels:  location
Openlocate Android
Stars: ✭ 136 (-46.46%)
Mutual labels:  location
Place Search Dialog
A place autocomplete search dialog which uses Google's places API for finding results.
Stars: ✭ 235 (-7.48%)
Mutual labels:  location
Rxcorelocation
RxCoreLocation is a reactive abstraction to manage Core Location.
Stars: ✭ 132 (-48.03%)
Mutual labels:  location
React Native Android Location Services Dialog Box
React Native Android Location Services Dialog Box
Stars: ✭ 175 (-31.1%)
Mutual labels:  location
Maps
🌍🌏🌎 The whole world fits inside your cloud!
Stars: ✭ 253 (-0.39%)
Mutual labels:  location
Timezonefinder
fast python package for finding the timezone of any point on earth (coordinates) offline
Stars: ✭ 242 (-4.72%)
Mutual labels:  location
Geolocation
Flutter geolocation plugin for Android and iOS.
Stars: ✭ 205 (-19.29%)
Mutual labels:  location

@@ -1,184 +1,14 @@

amap_location

pub package

# flutter_amap_location

android preview

ios preview

高德地图定位flutter组件。

目前实现直接获取定位和监听定位功能。

注意:随着flutter版本的提升, 本项目也会随之更新,

感谢群友 @a396901990 ,目前已经修复了因为使用simple_permissions导致ios不能编译使用的问题

xcode10下如果出现 Multiple commands produce这个错误,参考这篇https://www.jianshu.com/p/8a8444acdca5,亲测可以解决。

如果有疑问或者对这个库感兴趣,可以加qq群:854192563一起探讨

A new flutter plugin project.

Getting Started

集成高德地图定位android版本

1、先申请一个apikey http://lbs.amap.com/api/android-sdk/guide/create-project/get-key

2、修改 你的项目目录/app/build.gradleandroid/defaultConfig节点修改manifestPlaceholders,新增高德地图key配置

android {
    .... 你的代码

    defaultConfig {
        .....
        manifestPlaceholders = [
                AMAP_KEY : "aa9f0cf8574400f2af0078392c556e25", /// 高德地图key
        ]

    }

    ...你的代码

    dependencies {
        /// 注意这里需要在主项目增加一条依赖,否则可能发生编译不通过的情况
        implementation 'com.amap.api:location:latest.integration'
        ...你的代码
    }


集成高德地图定位ios版本

1、申请一个key http://lbs.amap.com/api/ios-sdk/guide/create-project/get-key

直接在dart文件中设置key

import 'package:amap_location/amap_location.dart';
   
   void main(){     
       AMapLocationClient.setApiKey("你的key");
     runApp(new MyApp());
   }

2、在info.plist中增加:

注意必须要描述清楚app使用定位的目的,苹果审核的时候要看, 如果写的不清楚,可能会被苹果拒绝上架,作者有过几次惨痛经历 :(

<key>NSLocationWhenInUseUsageDescription</key>
<string>要用定位</string>

怎么用

先导入dart包 修改pubspec.yaml,增加依赖:

dependencies:
  amap_location: 

在要用的地方导入:

import 'package:amap_location/amap_location.dart';

先启动一下

 await AMapLocationClient.startup(new AMapLocationOption( desiredAccuracy:CLLocationAccuracy.kCLLocationAccuracyHundredMeters  ));

直接获取定位:

await AMapLocationClient.getLocation(true)

监听定位


    AMapLocationClient.onLocationUpate.listen((AMapLocation loc){
      if(!mounted)return;
      setState(() {
         ...
      });
    });

    AMapLocationClient.startLocation();

停止监听定位

AMapLocationClient.stopLocation();

不要忘了在app生命周期结束的时候关闭

@override
  void dispose() {
    //注意这里关闭
    AMapLocationClient.shutdown();
    super.dispose();
  }

注意点:

在android6以上最好手动获取定位权限

在example中以simple_permissions这个库为例:

void _checkPersmission() async{
    bool hasPermission = await SimplePermissions.checkPermission(Permission.WhenInUseLocation);
    if(!hasPermission){
      bool requestPermissionResult = await SimplePermissions.requestPermission(Permission.WhenInUseLocation);
      if(!requestPermissionResult){
        Alert.alert(context,title: "申请定位权限失败");
        return;
      }
    }
    AMapLocationClient.onLocationUpate.listen((AMapLocation loc) {
      if (!mounted) return;
      setState(() {
        location = getLocationStr(loc);
      });
    });

    AMapLocationClient.startLocation();
  }

特性

  • IOS
  • Android
  • 直接获取定位
  • 监听定位改变

下个版本

  • 地理围栏监听

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].