如何在 C# 中使用 GMAP.NET 在 MAP 上绘制圆圈
我在 C# 中使用 GMAP.NET。我能够在表单上显示地图,现在我尝试通过单击某个点来绘制圆形鼠标,保持鼠标左键并将鼠标拖动到特定位置。一旦绘制了圆,我想得到它距中心点的半径(以英里为单位),我确信 GMAP 能够做到这一点。我正在使用 Opentstreet 地图。
我只是无法实现此功能,任何使用过 GMAP 控件的人请分享您的经验以及一些可行的代码。
谢谢
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.
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.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
据我所知,可以实现这样的结果的唯一方法是创建一个包含 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:
如果你想使用与绘图类相关的典型GDI功能,你可以简单地继承GMapMarker类。这允许您绘制简单的形状,例如圆形,并创建自定义属性(例如,将计算形状的半径(以英里为单位)):
在地图上绘制点:(
因为我对此有一些疑问)我们继承自标记类,我们仍然可以利用工具提示文本功能:
If you want to use the typical GDI features associated with the drawing class, you can simply inherit the GMapMarker class. This allows you to draw simple shapes, like circles, and create custom properties (for instance, one that will calculate the radius in miles of the shape):
To draw points on the map:
(And because I had some questions about it) Since we are inhereting from the markers class, we can still take advantage of the tooltiptext capability:
我遇到了同样的问题,在输入时我有经度、纬度和半径,这是我的解决方案。它就像一个魅力:)
打电话
I hit the same problem and on entry I had Lon, Lat and radius, here is my solution. It works like a charm :)
call
所以公寓不会出现椭圆形
so the apartment is not going ellipses
以下是如何在 WPF 中的地图上绘制带有黑色边框的红色圆圈:
就问题本身的第二部分而言,您将使用以下内置 MapControl 函数:
Here's how to draw a red circle, with black border on the map in WPF:
As far as the second part of the question itself, you would use the following built-in MapControl functions:
和这个班级
and this class
我的代码绘制弧线并继承自 GMapMarker。圆弧从 A 点扫过 B 点,枢轴点为 C。当 A 点和 B 点重合时,将绘制一个圆。
My code draws arcs and inherits from GMapMarker too. The arc sweeps from point A to point B with the pivot point at C. Where point A and B are coincidental, a circle will be drawn.
我的方法是覆盖绘画事件然后定义一个矩形。一旦定义了矩形,您就可以绘制圆形、圆弧或饼图。
My approach was to override paint event then define a rectangle. Once you define a rectangle you can draw circle or arc or pie.