【问题标题】:Adding multiple annotations on WKInterfaceMap在 WKInterfaceMap 上添加多个注解
【发布时间】:2016-01-19 18:43:23
【问题描述】:

我正在尝试向我的地图添加多个注释,但手表只显示一个。这就是我正在做的。

for (RestaurantObject *restaurant in nearbyMapArray) {
     CLLocationCoordinate2D mapLocation = CLLocationCoordinate2DMake([restaurant.latitude doubleValue], [restaurant.longitude doubleValue]);
    [self.map addAnnotation:mapLocation withPinColor: WKInterfaceMapPinColorRed];
    MKCoordinateSpan coordinateSpan = MKCoordinateSpanMake(0.1, 0.1); 
    [self.map setRegion:(MKCoordinateRegionMake(mapLocation, coordinateSpan))];
  }

【问题讨论】:

    标签: ios annotations watchkit


    【解决方案1】:

    我认为问题在于您在每个注释位置设置区域。尝试设置一次。

    regionCoordinate = ?
    MKCoordinateSpan coordinateSpan = MKCoordinateSpanMake(0.1, 0.1); 
    [self.map setRegion:(MKCoordinateRegionMake(regionCoordinate, coordinateSpan))];
    
    for (RestaurantObject *restaurant in nearbyMapArray) {
        CLLocationCoordinate2D mapLocation = CLLocationCoordinate2DMake([restaurant.latitude doubleValue], [restaurant.longitude doubleValue]);
        [self.map addAnnotation:mapLocation withPinColor: WKInterfaceMapPinColorRed];
    }
    

    您可能需要使用坐标跨度值和区域坐标才能将它们全部显示出来。我想知道是否最多允许 5 个注释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-06
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      相关资源
      最近更新 更多