location_amap 0.1.0 copy "location_amap: ^0.1.0" to clipboard
location_amap: ^0.1.0 copied to clipboard

outdated

高德地图Flutter插件包。

example/lib/main.dart

/*
 * @Author: your name
 * @Date: 2020-08-26 17:04:45
 * @LastEditTime: 2020-09-10 10:30:39
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: /tejia_user/plugins/amaplocation/example/lib/main.dart
 */
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:location_amap/amaplocation.dart';

import 'package:location_amap/amap_location_option.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    Amaplocation.setApiKey("xxxx1", "xxx2");
    if (!mounted) return;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('高德定位插件示例'),
        ),
        body: FlatButton(
          child: Text('获取定位'),
          color: Colors.blue,
          onPressed: () {
            Amaplocation amaplocation = Amaplocation();
            // 定位参数:是否连续定位
            AMapLocationOption option = AMapLocationOption(onceLocation: false);
            // 监听定位回调
            amaplocation.onLocationChanged().listen((event) {
              debugPrint('$event');
            });
            // 启动定位
            amaplocation.startLocation();
            // 设置定位参数
            amaplocation.setLocationOption(option);
          },
        ),
      ),
    );
  }
}
1
likes
0
pub points
3%
popularity

Publisher

unverified uploader

高德地图Flutter插件包。

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on location_amap