美文网首页
地图坐标系的转换

地图坐标系的转换

作者: 懒懒猫 | 来源:发表于2021-08-01 17:01 被阅读0次

    目前国内主要有以下三种坐标系:

    WGS84:地球坐标系

    为一种大地坐标系,即地球坐标系,国际上通用的坐标系。也是目前广泛使用的GPS全球卫星定位系统使用的坐标系。
    谷歌地图采用的是WGS84地理坐标系(中国范围除外);

    GCJ02:火星坐标系

    又称火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。由WGS84坐标系经加密后的坐标系。 高德地图、谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系,

    BD09:百度坐标系

    为百度坐标系,在GCJ02坐标系基础上再次加密。其中bd09ll表示百度经纬度坐标,bd09mc表示百度墨卡托米制坐标。
    非中国地区地图,服务坐标统一使用WGS84坐标。

    // 转换坐标,GCJ02-->BD09

        GCJ2BD09(poi) {
          var poi2 = []
          var x = poi[0]
          var y = poi[1]
          var X_PI = (3.14159265358979324 * 3000.0) / 180.0
          var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI)
          var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI)
          poi2[0] = z * Math.cos(theta) + 0.0065
          poi2[1] = z * Math.sin(theta) + 0.006
          return poi2
        },
        coordinateTransformation(points) {
          var handlePointsArr = []
          points.forEach((item, index, arr) => {
            handlePointsArr.push(this.GCJ2BD09(item))
          })
          return handlePointsArr
        },
    
     // 规范化坐标数据
          var data = [
            {
              geometry: {
                type: 'LineString',
                coordinates: this.coordinateTransformation(drivingPathData) || ''
              }
            }
          ]
    

    相关文章

      网友评论

          本文标题:地图坐标系的转换

          本文链接:https://www.haomeiwen.com/subject/ntyxvltx.html