In the Here iOS SDK, how can I make an NMAMapMarker show a callout when tapped?

风流意气都作罢 提交于 2019-12-07 01:56:27

The NMAMapOverlay is the only option right now. This functionality is only provided within the HERE SDK for iOS Premium.

You have a right start.

I suppose you have an array of coordinates which you add as NMAMapMarkers on the NMAMapView.

So basically every NMAMapMarker has it's own coordinates from where you can distinguish it from others.

After you conform to NMAMapViewDelegate, use this method:

func mapView(_ mapView: NMAMapView, didSelect objects: [NMAViewObject]) {
  for object in objects {
     // Search for NMAMapMarkers only
     if object is NMAMapMarker {
          // Get your map marker as follow
          let mapMarker = object as! NMAMapMarker
          // Check if you found your map marker by checking coordinates
          // Show desired information with your custom method
          }
      }
   }
}

Notice: NMAMapOverlay doesn't have any tap detect method which is provided be Here Maps SDK. You have to implement it on your own. Since NMAMapOverlay inherits from Apple's UIView it allows you to do that.

It's yours to choose between them, based on your needs.

I would say, go with NMAMapMarker

Currently, NMAMapOverlay is the only option to display custom view in place of NMAMapMarkers.

NMAMapOverlay* overlaySubview = [NMAMapOverlay mapOverlayWithSubview:customView geoCoordinates:place.position];

[self.mapView addMapOverlay:overlaySubview];

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!