谷歌地图扑动插件

时间:2018-06-15 17:50:05

标签: google-maps dart flutter

你好我尝试使用google map plugin for flutter https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter

我用这个例子 https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/example/lib

但是在这个例子中有一些页面。在我的应用程序中,我只需要在应用程序的启动时使用一个地图。问题,有了这个例子,我没有设法在我方便的时候使用它。所以我尝试使用read.me的极简主义示例,但它是一个statlesswidget,而且我不能像整数标签一样整数Tag fonction或map_ui.dart。所以我试图在statefull中传递这个无状态但是当我这样做时我有一个错误

这是我试图从两个例子中编译的

例如1 https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter

void main() {
  GoogleMapController.init();
  final GoogleMapOverlayController controller =
  GoogleMapOverlayController.fromSize(width: 300.0, height: 200.0);
  final Widget mapWidget = GoogleMapOverlay(controller: controller);
  runApp(MaterialApp(
    home: new Scaffold(
      appBar: AppBar(title: const Text('Google Maps demo')),
      body: MapUiBody(mapWidget, controller.mapController),
    ),
    navigatorObservers: <NavigatorObserver>[controller.overlayController],
  ));
 }

例2

https://github.com/flutter/plugins/blob/master/packages/google_maps_flutter/example/lib/map_ui.dart

class MapUiBody extends StatefulWidget {
   final GoogleMapOverlayController controller;

   const MapUiBody(this.controller, GoogleMapController mapController);

   @override
   State<StatefulWidget> createState() =>
      MapUiBodyState(controller.mapController);
  }

 class MapUiBodyState extends State<MapUiBody> {
  MapUiBodyState(this.mapController);

  final GoogleMapController mapController;

  @override
   Widget build(BuildContext context) {
    return Column(
    );
  }
}

有了这个,我有一个错误

body: MapUiBody(mapWidget, controller.mapController),
mapWidget: the argument type Widget can't be assigned to the  parameter type 'GooglemapoverlayController'

2 个答案:

答案 0 :(得分:1)

我成功地在主页上显示地图但我无法移动地图..

filenum

答案 1 :(得分:0)

你有

final GoogleMapOverlayController controller;

const MapUiBody(this.controller, GoogleMapController mapController);

传递

的地方
final GoogleMapOverlayController controller =
    GoogleMapOverlayController.fromSize(width: 300.0, height: 200.0);
final Widget mapWidget = GoogleMapOverlay(controller: controller);

  ...

  body: MapUiBody(mapWidget, controller.mapController),

其中mapWidget传递给final GoogleMapOverlayController controller;,而Widget不是controller.mapControllerGoogleMapController const MapUiBody(..., GoogleMapController mapController); 可能是controller所期望的mapWidget,但传递它似乎是多余的,因为无论如何你都可以从mapWidget传递给MapUiBody

从您的代码中不清楚您的意图是什么。

为什么要传递services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Home/Login/"; // auth redirect options.ExpireTimeSpan = new TimeSpan(1,0,0,0 ); }); [Authorize] // set authorize will auto redirect to specified LoginPath public IActionResult yourmethod() ?它应该在select replace(Text,' ',' '); 中发生什么?