打印/下载
案例
import 'package:flutter/material.dart';
import 'package:webmis/library/inc/time-set.dart';
import 'package:webmis/library/plus/map-geolocation.dart';
import 'package:webmis/library/plus/map-position.dart';

class Demo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => DemoState();
}
class DemoState extends State<Demo> {

  Map<String,dynamic> _location;
  var _mapController;

  /* 构造函数 */
  @override
  void initState() {
    super.initState();
    // 定位
    _getLocation();
  }

  /* 销毁 */
  @override
  void dispose(){
    super.dispose();
    MapGeolocation.dispose();
  }

  /* 定位 */
  Future<void> _getLocation({int time: 3000}) async {
    Map res = await MapGeolocation.fetch(context);
    if(res['longitude']>0) setState(()=> _location=res );
    setTimeout((){
      _mapController.setCenter([102.703689,25.048474]);
      _mapController.setZoom(19);
    },time);
  }

  /* Widget */
  @override
  // ignore: must_call_super
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: 300,
        child: MapPosition(
          img: '用户头像URL',
          controller: (res)=>_mapController=res,
          javascript: [
            {'name':'getLocation','msg':(res)=>_getLocation(time: 300)},
            {'name':'getPosition','msg':(res){print(res.message);}},
          ],
        ),
      ),
    );
  }

}
{{copy}}