Flutter_map:嵌入整个世界地图的最佳方法(只是大陆,没有细节)?

发布于 2025-02-12 17:42:24 字数 494 浏览 1 评论 0原文

我正在使用Flutter_map开发一个Aviation应用程序,该应用似乎是一个很棒的工具,并且可以轻松显示自定义标记。 我需要在该应用程序中预加载整个世界地图,但实际上没有细节,就像下面的图片一样。陆地和乡村边界理想情况下,就是这样。

我尝试了Flutter_map_tile_caching,确实确实很棒的插件,但是像我现在在有限的区域一样从OpenStreetMap下载瓷砖,这将是一个完全不现实的数据,甚至限制了非常低的Zoom级别……而且我不需要这些详细信息。 。

我是“映射业务”的新手,因此,关于如何实现这一目标的任何暗示都是最受欢迎的。如果需要,我愿意使用其他库。

此致!

I'm developing an aviation app in Flutter, currently using flutter_map which seems to be a great tool and easily allows to display custom Markers.
I need to preload the whole world map in the app, but really no details, pretty much like on the picture below. Landmasses and country borders ideally, that's it.

I tried flutter_map_tile_caching, great plugin indeed, but downloading tiles from openstreetmap as I do now for limited areas, it would be a totally unrealistic amount of data, even limiting at a very low zoom level... And I don't need those details.

I'm new in the "mapping business", so any hint about how to achieve this would be most welcome. I'm open to using other libraries if need be.

Best regards!

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好的,这里的输入不多。
我目前找到了一个不错的解决方案,从Zoom 7处的OpenStreetMaps缓存地图,最相关的区域,然后在更宽的区域的Zoom 4处,用透明的默认图块显示最佳的Zoom One,以便较低分辨率一个将出现。这使下载的文件达到了不错的规模。
对于整个世界,我相信有可能使用形状文件。 (例如 https://osmdata.openta.opensta.de/data/data/data/data/data/land-polygons.html < /a>之类的),但还没有使其与Flutter_map一起使用。我将在进一步的迭代中进行调查。
干杯!

Ok, not much input here.
I found a decent solution for now, caching maps from openstreetmaps at zoom 7 for the most relevant region, and then at zoom 4 for the wider region, displaying the best zoom one on top with a transparent default tile, so that the lower resolution one will show around. That keeps the downloaded files to a decent size.
For the whole globe, there's a possibility to use shapes files I believe. (like https://osmdata.openstreetmap.de/data/land-polygons.html or such), but didn't make it work with flutter_map yet. I'll investigate in a further iteration.
Cheers!

嗫嚅 2025-02-19 17:42:24

我使用 https://mapstyle.withgoogle.com/ 生成一个json文件,然后我链接到我的我通过PubSpec.yaml应用。例如,此JSON从地图中删除了很多信息:

[
    {
      "elementType": "labels",
      "stylers": [
        {
          "visibility": "off"
        }
      ]
    },
    {
      "featureType": "administrative.land_parcel",
      "stylers": [
        {
          "visibility": "off"
        }
      ]
    },
    {
      "featureType": "administrative.neighborhood",
      "stylers": [
        {
          "visibility": "off"
        }
      ]
    },
    {
      "featureType": "road",
      "elementType": "labels",
      "stylers": [
        {
          "visibility": "on"
        }
      ]
    }
  ]

将其添加到pubspec.yaml类似:

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/empty_map_style.json

然后您应该执行类似的操作来加载样式:

  void _setMapStyles() async {
      final _style =
          await MapUtils.getStyles("assets/empty_map_style.json");

      (await _mapCtrl.future).setMapStyle(_style);
  }

我会在on mapcreated on mapcreated中称呼此方法 googlemap小部件

I use https://mapstyle.withgoogle.com/ to generate a json file which I then link to my app via pubspec.yaml. For example this json removes quite a lot of info from maps:

[
    {
      "elementType": "labels",
      "stylers": [
        {
          "visibility": "off"
        }
      ]
    },
    {
      "featureType": "administrative.land_parcel",
      "stylers": [
        {
          "visibility": "off"
        }
      ]
    },
    {
      "featureType": "administrative.neighborhood",
      "stylers": [
        {
          "visibility": "off"
        }
      ]
    },
    {
      "featureType": "road",
      "elementType": "labels",
      "stylers": [
        {
          "visibility": "on"
        }
      ]
    }
  ]

Add it to pubspec.yaml like:

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/empty_map_style.json

You should then do something like this to load the styles:

  void _setMapStyles() async {
      final _style =
          await MapUtils.getStyles("assets/empty_map_style.json");

      (await _mapCtrl.future).setMapStyle(_style);
  }

I would call this method inside onMapCreated of GoogleMap widget

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文