简体   繁体   English

如何在mapView上画一个圆

[英]How to draw a circle on mapView

I am developing an application in which I have to show a mapView.我正在开发一个应用程序,我必须在其中显示一个 mapView。 What I exactly want to do is when user click on radius button, there should be circle drawn of that radius with the center point as the current location.我真正想做的是当用户单击半径按钮时,应该以该半径绘制圆,中心点作为当前位置。 Please tell me how can I draw a filled circle on my map that indicate the radius from the current location.请告诉我如何在我的 map 上绘制一个实心圆圈,指示当前位置的半径。

Any help will be highly appreciated Thanks in advance!!任何帮助将不胜感激在此先感谢!

Create a new instance of MKCircle with appropriate center and radius, and then add it to the map view's overlays.创建一个具有适当中心和半径的 MKCircle 新实例,然后将其添加到 map 视图的叠加层。 MKCircle in a subclass of MKOverlay, so you can handle it like any other overlay. MKCircle 在 MKOverlay 的子类中,因此您可以像处理任何其他叠加层一样处理它。 Example:例子:

MKCircle *myCircle = [MKCircle circleWithCenterCoordinate:myCenterPoint radius:myRadius];
[myMapView addOverlay:myCircle];

I'll leave it to you to substitute "current location" and user-selected radius for myCenterPoint and myRadius in the code above.在上面的代码中,我将把它留给您用“当前位置”和用户选择的半径替换 myCenterPoint 和 myRadius。

If you want to draw anything on a map your best friend is MKOverlay.. Search in Google for MKOverlay tutorials.如果你想在 map 上画任何东西,你最好的朋友是 MKOverlay。在 Google 中搜索 MKOverlay 教程。

MKCircle is the Class which you want to know about. MKCircle是您想了解的 Class。 Just read the docs to get to know some idea只需阅读文档以了解一些想法

Just see circleWithCenterCoordinate:radius只看circleWithCenterCoordinate:radius

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM