Reputation: 31
In my app I plotted a route with a marker, but when I tap on the route or marker, nothing gets fired. I made sure to do the following:
Made my class a NMAMapViewDelegate:
class ViewController: UIViewController, NMARouteManagerDelegate, NMAMapViewDelegate {
Set the delegate to self:
override func viewWillAppear(_ animated: Bool) {
mapView.delegate = self
}
Set up the delegate method:
func mapViewDidSelectObjects(_ mapView: NMAMapView, objects: [NMAMapObject]) {
print("map view delegate method called")
}
Anyone know why the delegate isn't firing? Is it just a bug in the Swift version of the iOS SDK?
Upvotes: 2
Views: 486
Reputation: 188
If you are use own gestureDelegate
like this:
override func viewWillAppear(_ animated: Bool) {
mapView.delegate = self
mapView.gestureDelegate = self
}
Don't forget to push gesture events into defaultGestureHandler
:
public func mapView(_ mapView: NMAMapView, didReceiveTapAt location: CGPoint) {
mapView.defaultGestureHandler?.mapView?(mapView, didReceiveTapAt: location)
// gesture handling
}
This object responsible for selection and if you define custom gestureDelegate
the selection stop working.
Upvotes: 1
Reputation: 1478
Is this for the Starter of Premium version of the HERE SDK for iOS?
If the Premium version, the signature you have specified in Swift is not correct, it should be
func mapView(_ mapView: NMAMapView!, didSelect objects: [Any]!)
As mentioned in this post: Mute Voice Directions in Here Maps iOS SDK, the correct signature can be found using the "Generated Interface" functionality in Xcode.
Upvotes: 0