You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何覆写Google Maps API默认投影以实现仿射变换?

问题:GPS轨迹与Google卫星地图赛道无法对齐,需自定义投影实现仿射变换

我有一组赛车GPS设备采集的经纬度(lat/lon)轨迹数据,使用Google Maps JavaScript API加载卫星地图绘制轨迹时,轨迹与赛道无法对齐,推测是GPS漂移或卫星位置导致的误差。

我希望通过覆写/扩展Google卫星地图的当前投影,对投影坐标执行仿射变换,获取适配该区域和设备的缩放、错切、旋转及平移常量值。

已尝试的方案

  • 监听projection_changed事件获取到默认墨卡托投影,但不清楚如何修改:
map.addListener("projection_changed", () => {
  const merc = mapInstance.getProjection();
  // but how do I modify the projection here?
});
  • 尝试扩展google.maps.Projection接口实现自定义投影,添加仿射变换逻辑,但未找到为卫星地图类型设置自定义投影的相关文档:
class MyProjection implements google.maps.Projection {
  fromLatLngToPoint(
    latLng: google.maps.LatLng,
    point?: google.maps.Point | undefined
  ): google.maps.Point | null {
    const TILE_SIZE = 256;
    let siny = Math.sin((latLng.lat() * Math.PI) / 180);

    // Truncating to 0.9999 effectively limits latitude to 89.189. This is
    // about a third of a tile past the edge of the world tile.
    siny = Math.min(Math.max(siny, -0.9999), 0.9999);

    return new google.maps.Point(
      TILE_SIZE * (0.5 + latLng.lng() / 360),
      TILE_SIZE * (0.5 - Math.log((1 + siny) / (1 - siny)) / (4 * Math.PI))
    );
  }

  fromPointToLatLng(
    pixel: google.maps.Point,
    noClampNoWrap?: boolean | undefined
  ): google.maps.LatLng | null {
    throw new Error("Method not implemented.");
  }
}

内容的提问来源于stack exchange,提问作者driven1983

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 20:55:18