使用SharpMap库生成谷歌地图叠加层

4
我希望动态生成一个谷歌地图叠加层,它将由一个单独的透明GIF / PNG图像组成,上面有多个点位于不同的位置。
由于有大量的点,如果使用普通标记,性能将无法接受。
我发现SharpMap库,它看起来是一个处理地图的优秀、全面的库。
问题是,它也非常大,我不确定从哪里开始。
首先,我认为我不需要使用整个框架,甚至可能不需要实例化“Map”对象。
我所需要做的就是将一组纬度/经度坐标转换为像素坐标集合,给定当前缩放级别和视口的大小(固定)。
有没有使用SharpMap的人可以指导我应该使用哪些类/命名空间来完成这个任务?

我找到了一篇与此有些相关的文章,但是它适用于Google Earth而不是Maps API。

http://web.archive.org/web/20080113140326/http://www.sharpgis.net/PermaLink,guid,f5bf2808-4cda-4f41-9ae5-98109efeb8b0.aspx

尝试使示例工作。

1个回答

2
我使用以下类将经纬度转换为x/y坐标:

public static class StaticMapHelper
{
    private const long offset = 268435456;
    private const double radius = offset / Math.PI;

    private static double LongitudeToX(double longitude)
    {
        return Math.Round(offset + radius * longitude * Math.PI / 180);
    }

    private static double LatitudeToY(double latitude)
    {
        return Math.Round(offset - radius * Math.Log((1 + Math.Sin(latitude * Math.PI / 180)) / (1 - Math.Sin(latitude * Math.PI / 180))) / 2);
    }

    private static double XToLongitude(double x)
    {
        return ((Math.Round(x) - offset) / radius) * 180 / Math.PI;
    }

    private static double YToLatitude(double y)
    {
        return (Math.PI / 2 - 2 * Math.Atan(Math.Exp((Math.Round(y) - offset) / radius))) * 180 / Math.PI;
    }

    public static GeoPoint XYToLongitudeLatitude(int offsetX, int offsetY, double centerLongitude, double centerLatitude, int googleZoom)
    {
        double zoom_factor = Math.Pow(2, 21 - googleZoom);
        double longitude = XToLongitude(LongitudeToX(centerLongitude) + (offsetX * zoom_factor));
        double latitude = YToLatitude(LatitudeToY(centerLatitude) + (offsetY * zoom_factor));
        return new GeoPoint(longitude, latitude);
    }

    public static GeoPoint LongitudeLatitudeToXY(int offsetX, int offsetY, double centerLongitude, double centerLatitude, int googleZoom)
    {
        double zoom_factor = Math.Pow(2, 21 - googleZoom);
        double x = (LongitudeToX(offsetX) - LongitudeToX(centerLongitude)) / zoom_factor;
        double y = (LatitudeToY(offsetY) - LatitudeToY(centerLatitude)) / zoom_factor;
        return new GeoPoint(x, y);
    }

}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接