Change the coordinate system of a Canvas in WPF

后端 未结 8 1772
一整个雨季
一整个雨季 2021-02-01 06:59

I\'m writing a mapping app that uses a Canvas for positioning elements. For each element I have to programatically convert element\'s Lat/Long to the canvas\' coordinate, then

8条回答
  •  醉梦人生
    2021-02-01 07:31

    I'm pretty sure you can't do that exactly, but it would be pretty trivial to have a method which translated from lat/long to Canvas coordinates.

    Point ToCanvas(double lat, double lon) {
      double x = ((lon * myCanvas.ActualWidth) / 360.0) - 180.0;
      double y = ((lat * myCanvas.ActualHeight) / 180.0) - 90.0;
      return new Point(x,y);
    }
    

    (Or something along those lines)

提交回复
热议问题