Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MapController 无法在 location 的locationChanged方法里面调用 #4

Closed
zmGitHub opened this issue Oct 28, 2019 · 0 comments
Closed

Comments

@zmGitHub
Copy link

Map 和 location 配合使用出现如下问题

// flutter 版本
Flutter 1.9.1+hotfix.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1aedbb1835 (11 天前) • 2019-10-17 08:37:27 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0

// 插件版本 
amap_map_fluttify: ^0.2.4+9922976
amap_location_fluttify: ^0.2.3+9922976
.....
.....      
body: AmapView(
        onMapCreated: (controller) async {
          _controller = controller;
         // 如果此处用 await controller.setZoomLevel(18); 下面的代码都无效
          controller.setZoomLevel(18);
          await controller.setCenterCoordinate(36.10453694661458, 120.40822835286458);
          AmapLocation.startLocation(
            once: false,
            locationChanged: locationChanged: this._startLocation        
          ); 
.....
.....
  void _startLocation(Location location) async {
    double latitude = await location.latitude;
    double longitude = await location.longitude;
    print('***********');
    print("latitude: $latitude");
    print("longitude: $longitude");
   // 当前能改变经纬度 但是调用地图的 controller 是无效的
    await _controller?.setCenterCoordinate(36.10453694661458, 120.40822835286458);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants