Converting Longitude & Latitude to X Y on a map with Calibration points

后端 未结 7 1123
既然无缘
既然无缘 2020-11-29 01:25

If i have a jpeg map with size sizeX, sizeY

and some calibration points on the map (X, Y, Lon, Lat)

What would be the algorithm for calculating the correspon

7条回答
  •  醉梦人生
    2020-11-29 01:48

    Just make this(for Mercator projection map):

    extension UIView
    {
        func addLocation(coordinate: CLLocationCoordinate2D)
        {
            // max MKMapPoint values
            let maxY = Double(267995781)
            let maxX = Double(268435456)
    
            let mapPoint = MKMapPointForCoordinate(coordinate)
    
            let normalizatePointX = CGFloat(mapPoint.x / maxX)
            let normalizatePointY = CGFloat(mapPoint.y / maxY)
    
            let pointView = UIView(frame: CGRectMake(0, 0, 5, 5))
            pointView.center = CGPointMake(normalizatePointX * frame.width, normalizatePointY * frame.height)
    
            pointView.backgroundColor = UIColor.blueColor()
    
            addSubview(pointView)
        }
    }
    

    My simple project for adding coordinate on UIView: https://github.com/Glechik/MapCoordinateDrawer

提交回复
热议问题