eft_flutter_amap

A flutter plugin to use amap.

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  eft_flutter_amap: "^0.0.1"

Getting Started

  • Android

  • Add following permissions to your AndroidManifest.xml

    <!--用于访问网络,网络定位需要上网-->
    <uses-permission android:name="android.permission.INTERNET" />
    <!--写入扩展存储,向扩展卡写入数据,用于写入缓存定位数据-->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!--用于进行网络定位-->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <!--获取运营商信息,用于支持提供运营商信息相关的接口-->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!--用于访问GPS定位-->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!--用于读取手机当前的状态-->
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <!--用于访问wifi网络信息,wifi信息会用于进行网络定位-->
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <!--这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位-->
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <!--这个权限用于允许程序在手机屏幕关闭后后台进程仍然运行-->
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <!--用于申请调用A-GPS模块-->
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
    <!--用于申请获取蓝牙信息进行室内定位-->
    <uses-permission android:name="android.permission.BLUETOOTH"></uses-permission>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"></uses-permission>

  • Add following code between to your AndroidManifest.xml
            <meta-data
                android:name="com.amap.api.v2.apikey"
                android:value="[您在高德地图后台申请的Android Key]"/>
            <service android:name="com.amap.api.location.APSService"></service>
            <activity android:name="com.amap.api.navi.AmapRouteActivity"
                android:theme="@android:style/Theme.NoTitleBar"
                android:configChanges="orientation|keyboardHidden|screenSize" />
  • ios

  • Add following permissions in info.plist

	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	</dict>
	<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
	<string></string>
	<key>NSLocationWhenInUseUsageDescription</key>
	<string></string>
	<key>UIBackgroundModes</key>
    	<array>
    		<string>fetch</string>
    		<string>location</string>
    		<string>newsstand-content</string>
    	</array>
    	

How to use

import 'package:eft_flutter_amap/eft_flutter_amap.dart';
await EftFlutterAmap.initKey("[您在高德地图后台申请的IOS Key]"); //初始化IOS key
await EftFlutterAmap.initLocation(onceFlag); //请求定位,onceFlag:true单次,false持续
await EftFlutterAmap.stopLocation(); //停止定位
await EftFlutterAmap.destoryLocation(); //销毁定位
await EftFlutterAmap.showMap("[地点名称]","[描述]",[坐标]); //显示地图
await EftFlutterAmap.showNavMap(
      startLocation: [始点坐标],
      endLocation: [终点坐标],
      startAddress: "[始点]",
      endAddress: "[终点]"
    ); //导航
EftFlutterAmap.setMethodCallHandler((MethodCall call){
    });//获取定位返回

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.

Libraries

eft_flutter_amap