问题描述
我在C#中使用GMAP.NET。我能够在表单上显示的地图,我现在想通过点击certian点,保持鼠标左键并拖动鼠标高达特定的地方画了一个圈鼠标。一旦圆圈绘制我想要得到它从圆心方圆十里我确信GMAP是能够做到的。我使用Opentstreet地图。
I am using GMAP.NET in c#. I am able to display the map on the form, now i am trying to draw a CIRCLE mouse by clicking on a certian point, keeping the left mouse button and dragging the mouse upto specific place. Once the circle is drawn I want to get its radius in miles from the center point which I am sure GMAP is capable of doing it. I am using Opentstreet maps.
我只是无法functionly achive这一点,谁曾与GMAP控制起到好心分享一些代码,将工作经验的人。
I am just unable to achive this functionly, anybody who has played with GMAP control kindly share your experience with some code which will work.
感谢
推荐答案
这是我知道的唯一途径能取得这样的成绩是创建PointLatLng点列表,并绘制这些多边形。下面是一个例子。
the only way that I am aware of that can achieve such a result is to create a list with PointLatLng points and draw them as a polygon. Here is an example.
private void CreateCircle(PointF point, double radius, int segments)
{
List<PointLatLng> gpollist = new List<PointLatLng>();
double seg = Math.PI * 2 / segments;
int y = 0;
for (int i = 0; i < segments; i++)
{
double theta = seg * i;
double a = point.x + Math.cos( theta ) * radius;
double b = point.y + Math.sin( theta ) * radius;
PointLatLng gpoi = new PointLatLng(a,b);
gpollist.Add(gpoi);
}
GMapPolygon gpol = new GMapPolygon(gpollist, "pol");
overlayOne.Polygons.Add(gpol);
}
这篇关于如何绘制圆在C#中使用GMAP.NET的地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!