且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在iPhone App内的MKMapView中显示并通过带有注释的路线连接多个位置?

更新时间:2022-12-30 08:56:20

添加批注的方式很好.
不知道您的关注点是什么,以及所有地方都在一个地方"意味着什么.
如果要在多个位置使用图钉/注释,则必须为每个位置创建一个单独的注释对象.

The way you are adding the annotations is fine.
Not sure what your concern is and what you mean by "all the points at a single place".
If you want pins/annotations at several places, you have to create a separate annotation object for each place.

绘制连接这些位置的路线需要创建一个覆盖图(而不是注释").
您想在地图上添加MKPolyline,以为其指定坐标列表.

Drawing a route connecting those locations requires creating an overlay (not an "annotation").
You want to add an MKPolyline to the map for which you will specify the list of coordinates.

要绘制折线,不需要在每个坐标处都添加注释(但是如果需要的话也可以).

To draw the polyline, you don't need to also add annotations at each coordinate (but you could if you want to).

创建和添加MKPolyline及其对应的MKPolylineViewMKPolygonMKPolygonView非常相似.参见以下问题的示例:

Creating and adding an MKPolyline and its corresponding MKPolylineView is very similar to MKPolygon and MKPolygonView. See this question for an example:

iPhone MKMapView-MKPolygon问题