【问题标题】:Remove only restaurants from MKMapView从 MKMapView 中只删除餐馆
【发布时间】:2014-07-02 03:29:23
【问题描述】:

我希望我的 MKMapView 显示兴趣点除了餐厅。这可能吗?如果可以,我该如何设置?

我确实在 Documentation 中看到了以下内容,但这真的是全有还是全无?

@property (nonatomic) BOOL showsPointsOfInterest;

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

例如,在下面,我希望显示加油站而不显示餐厅。

【问题讨论】:

    标签: ios mkmapview mkannotation point-of-interest


    【解决方案1】:

    在 IOS 13 中,您可以选择过滤:这里是在地图上不显示任何项目的示例

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

    例如,您可以从地图中过滤机场...

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

    【讨论】:

    • 如果要显式包含所有兴趣点,可以使用 exclude: localMap.pointOfInterestFilter = MKPointOfInterestFilter( exclude: [])
    • @user1909186 不错!
    【解决方案2】:

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

    您可以使用 Foursquare 或 Facebook 的第三方地点数据库来获取相似的兴趣点并将它们绘制在您的地图上,但不能保证结果与 Apple 会显示的结果一致。

    【讨论】:

      【解决方案3】:

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

      // Includes airports
      localMap.pointOfInterestFilter?.includes(MKPointOfInterestCategory.airport)
      
      
      // Excludes laundry/laundromats
      localMap.pointOfInterestFilter?.excludes(MKPointOfInterestCategory.laundry)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-12-25
        相关资源
        最近更新 更多