amap_location_muka 0.0.1+2 copy "amap_location_muka: ^0.0.1+2" to clipboard
amap_location_muka: ^0.0.1+2 copied to clipboard

outdated

Flutter高德定位插件

amap_location #

Flutter高德定位插件

引入方式 #

    amap_location_muka:
      git:
        url: https://github.com/Spicely/amap_view.git
        ref: location

Android #

AndroidManifest.xml添加如下代码 <meta-data android:name="com.amap.api.v2.apikey" android:value="你的key" />

IOS #

Info.plist添加如下代码

    // 默认
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>App需要您的同意,才能访问位置</string>
    <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
    <string>App需要您的同意,才能访问位置</string>
    <key>amap_key</key>
    <string>你的key</string>

    // 导航 后台持续定位只需要location
    <key>UIBackgroundModes</key> 
    <array> 
        <string>location</string>
        <string>audio</string> 
    </array>

支持 #

  • 单次获取位置信息
  • 持续获取位置信息
  • 后台持续定位
  • 地理围栏

AmapLocation

    /// 持续定位
    stopLocation = await AmapLocation.start(
        listen: (Location location) {
            print(location.toJson());
        },
    );
    
    /// 停止定位
    stopLocation();

    /// 单次定位
    Location location = await AmapLocation.fetch();
    print(location.toJson());

    /// 后台定位 目前有问题
    /// vibrate 属性只支持一次性设置 设置后除非卸载app否则不会变更
    /// 另一种办法是变更chanlid 但对于定位来说 一般不会变更 暂时不考虑提供参数
    class _MyAppState extends State<MyApp> with WidgetsBindingObserver {

        @override
        void initState() {
            super.initState();
            WidgetsBinding.instance.addObserver(this);
        }

        @override
        void didChangeAppLifecycleState(AppLifecycleState state) async {
            switch (state) {
            case AppLifecycleState.inactive: // 处于这种状态的应用程序应该假设它们可能在任何时候暂停。
                break;
            case AppLifecycleState.resumed: // 应用程序可见,前台
                await AmapLocation.disableBackground();
                break;
            case AppLifecycleState.paused: // 应用程序不可见,后台
                await AmapLocation.enableBackground(assetName: 'app_icon', label: '正在获取位置信息', title: '高德地图',vibrate: false);
                break;
            default:
                break;
            }
        }
    }
1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Flutter高德定位插件

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

amap_core, flutter

More

Packages that depend on amap_location_muka