C# 如何使用sharpmap在地球上渲染一个国家的图像

C# 如何使用sharpmap在地球上渲染一个国家的图像,c#,.net,geolocation,sharpmap,C#,.net,Geolocation,Sharpmap,我在SQL数据库中有一个区域边界列表,我正在使用sharpmap为我需要的每个国家渲染缩略图。它工作得非常好 但我想更进一步,在它周围加上一个小地球仪,把这个国家定位在它在全球的位置上,但我不知道从哪里开始 以下是我目前正在使用的代码,用于渲染国家大拇指。有什么想法吗 var map = new Map(new Size(command.Width, command.Height)); map.BackColor = Color.Transparent; var countryGeometry

我在SQL数据库中有一个区域边界列表,我正在使用sharpmap为我需要的每个国家渲染缩略图。它工作得非常好

但我想更进一步,在它周围加上一个小地球仪,把这个国家定位在它在全球的位置上,但我不知道从哪里开始

以下是我目前正在使用的代码,用于渲染国家大拇指。有什么想法吗

var map = new Map(new Size(command.Width, command.Height));
map.BackColor = Color.Transparent;
var countryGeometry = GeometryFromWKT.Parse(command.CountryLevelWkt);
IProvider countryProvider = new GeometryFeatureProvider(countryGeometry);
var countryLayer = new VectorLayer("country", countryProvider);
var borderColor = System.Drawing.ColorTranslator.FromHtml(command.BorderColor);
countryLayer.Style.EnableOutline = true;
countryLayer.Style.Outline = new Pen(borderColor);
countryLayer.Style.Outline.Width = command.BorderWidth;
countryLayer.Style.Fill = Brushes.Transparent;

var transformationFactory = new CoordinateTransformationFactory();
countryLayer.CoordinateTransformation = transformationFactory.CreateFromCoordinateSystems(
            GeographicCoordinateSystem.WGS84,
            ProjectedCoordinateSystem.WebMercator);
map.Layers.Add(countryLayer);
var bottomLeft = new Coordinate(command.Extents.BottomLeft.Longitude, command.Extents.BottomLeft.Latitude);
var topRight = new Coordinate(command.Extents.TopRight.Longitude, command.Extents.TopRight.Latitude);


// transformations
var bottomLeftLongLat = countryLayer.CoordinateTransformation.MathTransform.Transform(bottomLeft);
var topRightLongLat = countryLayer.CoordinateTransformation.MathTransform.Transform(topRight);
map.ZoomToBox(new Envelope(bottomLeftLongLat, topRightLongLat));
             var img = map.GetMap();
return img;
  • 首先在新地图上绘制所有国家,每个国家都在自己的图层上
  • 在自己的图层上绘制感兴趣的国家
  • 将地图中心设置为封套。第2步中的图层中心。如果画澳大利亚,地图将向左移动
  • 将贴图渲染为图像。在绘图区域(
    System.drawing.Graphics
    )上绘制图像
  • 将地图重新居中,以覆盖空白区域。如果要画澳大利亚,请将地图几乎一直向右移动。您需要以编程方式计算这些偏移量
  • 将步骤5中的贴图渲染为图像。将图像添加到同一图形中(请参见步骤4)
  • 重复步骤5-6,覆盖步骤3中渲染的下方/上方的空白区域
  • 以下是一个例子:

    请注意:

    • 澳大利亚处于中心位置
    • 鼠标指针附近的地图层之间存在间隙(屏幕截图中的间隙旨在演示逻辑)
    • 有些国家非常大(例如俄罗斯),并获得信封。中心不会很好地工作-考虑基于最大多边形的定心仅

    这是一个样品。在示例中,我使用了来自的地图。

    地球仪意味着3d地球仪或投影?@Isma no。它在通知中可以与facebook图标相同,但必须包含选定的国家/地区。