Search code examples
iosobjective-chere-api

How can I remove all map object from HereMap?


How can I remove all map objects from HereMap ?

HereMap SDK only provide

- (BOOL)removeMapObject:(nonnull NMAMapObject *)object
- (BOOL)removeMapObjects:(nonnull NSArray<NMAMapObject *> *)objects

Solution

  • You are most likely adding NMAMapObject's to the map, I would suggest creating a mutable array of all objects added to the map, so when you do

    //in viewDidLoad for instance create an empty NSMutableArray called mapObjects
    [self.mapView addMapObject:self.mapRoute];
    [mapObjects addObject:mapObject];
    

    Then when you want to remove them all you will be able to do:

    [self.mapView removeMapObject:mapObjects]; 
    

    Let me know if that would work for you...