仅从MKMapView中删除餐馆

时间:2014-05-14 07:43:44

标签: ios mkmapview mkannotation point-of-interest

我希望我的MKMapView能够显示除了餐厅之外的兴趣点。这是可能的,如果是,我该如何设置呢?

我确实在 Documentation 中看到了以下内容,但它真的全有或全无吗?

@property (nonatomic) BOOL showsPointsOfInterest;
  

当此属性设置为YES时,地图会显示餐馆,学校和其他相关兴趣点的图标和标签。此属性的默认值为YES。

例如,在下面,我想要加油站展示而不是餐厅。

enter image description here

3 个答案:

答案 0 :(得分:5)

无法控制绘制的特定点类型。 Apple可以在Map Kit的任何未来更新中添加/删除/更改它显示的特定类型。正如您所提到的,您唯一的做法是设置showsPointsOfInterest

您可以使用Foursquare或Facebook上的第三方地点数据库获取类似的兴趣点并将其绘制在地图上,但无法保证结果与Apple原本显示的结果相符。

答案 1 :(得分:1)

使用IOS 13,您可以选择过滤:以下示例在地图上不显示任何项目

localMap.pointOfInterestFilter = .some(MKPointOfInterestFilter(including: []))

例如,您可以在地图上过滤机场...

localMap.pointOfInterestFilter = .some(MKPointOfInterestFilter(including: [MKPointOfInterestCategory.airport]))

答案 2 :(得分:0)

iOS 13中的另一个选项是包括或排除某些兴趣点:

// Includes airports
localMap.pointOfInterestFilter?.includes(MKPointOfInterestCategory.airport)


// Excludes laundry/laundromats
localMap.pointOfInterestFilter?.excludes(MKPointOfInterestCategory.laundry)
相关问题