【问题标题】:Is there any way to center a map (Google Map) based where's located a layer from carto有什么方法可以使地图(谷歌地图)居中,该地图(谷歌地图)基于从 carto 层的位置
【发布时间】:2019-01-18 13:54:06
【问题描述】:

我使用 carto.js v4 从 carto 获取图层并将其显示在地图(Google 地图)上,我想将地图居中放置在图层的位置

【问题讨论】:

    标签: angular google-maps-api-3 cartodb


    【解决方案1】:

    您需要使用 SQL API 和 PostGIS 函数获取该信息,一般来说,简单的方法是将地图居中在数据的边界框中,以便发送此查询

    select st_asgeojson(
               st_boundingdiagonal(
                   st_collect(
                       the_geom)))
      from populated_places
    

    该查询将为您提供 corners of the bounding box 的坐标作为 GeoJSON 对象,非常容易解析并转换为 Google Maps API 地图更改。

    【讨论】:

      猜你喜欢
      • 2018-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多