我希望动态生成谷歌地图覆盖,这将包括一个单一的透明GIF/PNG图像与多个点在不同的位置。
会有大量的点,如果我使用正常的标记,表现将是不可接受的。
我偶然发现了SharpMap库,它看起来是一个处理地图的极好的、全面的库。
问题是,它也很大,我不知道从哪里开始。
首先,我不认为我需要使用整个框架,我甚至可能不需要实例化一个“Map”对象。
我所需要做的就是将一个纬度/经度坐标集合转换成一个像素坐标集合,考虑到当前的缩放级别和视口大小(这是固定的)。
有过SharpMap经验的人能为我指明我可以/应该使用哪些类/名称空间来完成这个任务吗?
找到了一篇与此相关的文章,但应用于Google,而不是Maps API。
http://web.archive.org/web/20080113140326/http://www.sharpgis.net/PermaLink,guid,f5bf2808-4cda-4f41-9ae5-98109efeb8b0.aspx
试着让样本正常工作。
发布于 2010-12-23 13:26:57
我使用以下类将lat/long转换为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);
}
}https://stackoverflow.com/questions/1598268
复制相似问题