如何在 Google 地图上显示自定义矢量图块

How to display custom vector tiles on Google Maps

目标是在 Google 地图上显示大量数据。我所说的大量是指大约 1000 万个段存储在 PostgreSQL 数据库中。路段代表了道路的一些特征,因此路段应该叠加在底图中的道路上。细分属性可能会随时间变化。

解决该问题的最佳技术方案是使用自定义瓦片服务器(如有错误请指正)。

根据 Google Maps JS API,我找到了两种使用自定义切片服务器绘制地图的方法:

我都试过了。第一个不符合我的需求,因为 GeoJson 显得太大,导致性能问题。从用户体验的角度来看,第二个是不好的,因为它使用的是栅格图块,而现在我们应该使用矢量图块。我还查看了 OpenLayers / Leaflet,但没有找到使用 Google 地图的官方方法(参见 https://github.com/mapbox/mapbox-gl-js/issues/1791)。

这里的关键是使用矢量图块,但是我无法在 Google 地图上渲染矢量图块 (MVT)。

有什么方法可以在 Google Maps Platform 上渲染矢量图块吗?

我已经达到 Google Maps Platform 支持,他们建议我使用 deck.gl

这是一种在地图上显示庞大数据集的技术,包括Google地图。它使用 官方 Google 地图 API 进行渲染,尤其是 OverlayView.

这里有一篇关于 Google 地图和 deck.gl 的好博客 post: https://cloud.google.com/blog/products/maps-platform/high-performance-data-visualizations-google-maps-platform-and-deckgl

我已经成功地使用 angular 在 Google 地图上显示自定义矢量图块,这里是示例存储库: https://github.com/yterletskyi/deckgl-angular

顺便说一句,感谢 LuisTavares 关于 https://github.com/landtechnologies/Mapbox-vector-tiles-basic-js-renderer 库的解决方案,它也依赖于 OverlayView。我没有尝试过,但方法与 deck.gl 中的方法相同,所以应该不会有任何问题。

更新:

在尝试 deck.gl 之后,问题转向了在移动 iOS 和 Android 平台上实现这一点。经过一些研究,我联系了 Google 支持,但不幸的是,似乎没有解决方案。 Google 支持引用:

Hello Yura,

Unfortunately there is no way to render vector tiles with the mobile APIs. I also have no recommendations for services that allow you to do this with the Google Maps API.

My apologies,

检查此库以在 Google 地图中加载矢量切片: https://github.com/techjb/Vector-Tiles-Google-Maps

您只需创建一个 mbtiles 文件,然后上传到 Mapbox 或其他服务器,最后连接到 Google 地图。