Search code examples
iosobjective-chere-apihere-ios

Unable to select a map object when Gesture delegate set


This is an issue related to HERE iOS HybridPlus SDK.

If any interaction is done with mapView of class NMAMapView and NMAMapViewDelegate and NMAMapGestureDelegate both are set then only methods of NMAMapGestureDelegate are being called.

For ex:

If an object on map is tapped, then - mapView:didReceiveTapAtLocation: gets called and - mapView:didSelectObjects: doesn't get called!

Whereas in android this is not the case. In android, if an object is tapped and both the delegates are set then both methods mentioned above will get called.

Question: What is the solution for this in iOS?


Solution

  • Got this answer from HERE Development Support.

    The mapView:didSelectObjects: is not getting called, because they are overriding the default tap handler by implementing mapView:didReceiveTapAtLocation in their NMAMapGestureDelegate. Because this is a protocol, they cannot call mapView:didReceiveTapAtLocation of the super class to run the default implementation, after they perform operation they need. However objects passed to mapView:didSelectObjects: are retrieved in a standard way, which is available to the customer, therefore they can mimic the default implementation, for example:

    - (void)mapView:(NMAMapView *)mapView didReceiveTapAtLocation:(CGPoint)location  {
    
        NSLog(@"didReceiveTapAtLocation: %fx%f", location.x, location.y); 
        if ([mapView.delegate respondsToSelector:@selector(mapView:didSelectObjects:)]) { 
            // Check to see if any objects are selected 
            NSArray *selectedObjects = [mapView visibleObjectsAtPoint:location]; 
            // If any objects were selected, treat the tap as a selection 
            if (selectedObjects.count > 0) { 
                [mapView.delegate mapView:mapView didSelectObjects:selectedObjects]; 
            } 
        } 
    }