如何在Flutter Web上使用Google Maps库? [关闭]

问题描述 投票:4回答:2

我正在通过一个Flutter移动项目迁移Web,并想知道如何将Google Maps Library与Flutter Web一起使用。

google-maps google-maps-markers flutter-web
2个回答
3
投票

如果您需要使用该库,我找到了这种替代方法:

Widget getMap() {
String htmlId = "7";

final mapOptions = new MapOptions()
  ..zoom = 8
  ..center = new LatLng(-34.397, 150.644);

// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(htmlId, (int viewId) {
  final elem = DivElement()
    ..id = htmlId
    ..style.width = "100%"
    ..style.height = "100%"
    ..style.border = 'none';

  new GMap(elem, mapOptions);

  return elem;
});

return HtmlElementView(viewType: htmlId);
}

12
投票

请参阅其他答案。比这更容易!

© www.soinside.com 2019 - 2024. All rights reserved.