问题
In Android we can get marker name as this
How to perform map marker click in HERE MAP (android )
But In iOS am using
for (NMALink* item in _resultsArray) // NMAPlaceLink
{
if ([item isKindOfClass:[NMAPlaceLink class]])
{
[self addMarkerAtPlace:(NMAPlaceLink*)item];
}
}
Mutltipe markers add on Map
- (void)addMarkerAtPlace:(NMAPlaceLink*)placeLin
{
NMAImage* img = [NMAImage imageWithUIImage:[UIImage imageNamed:@“”]];
NMAMapMarker *_mapMarker =
[[NMAMapMarker alloc] initWithGeoCoordinates:[placeLink position] icon:img];
[self.mapView addMapObject:_mapMarker];
}
Tap Particular Marker
-(void)mapView:(NMAMapView *)mapView didSelectObjects:(NSArray *)objects {
NMAMapMarker *mapMarker = objects.firstObject // Unable yo get Title name from objects
}
回答1:
If you are using the premium version you can't get title directly there is not property for this. But if you are using the starter version you can title from NMAMapMarker like below.
- (void)mapView:(NMAMapView *)mapView didSelectObjects:(NSArray *)objects {
NMAMapMarker *mapMarker = (NMAMapMarker *) objects.firstObject;
NSString *title = mapMarker.title;
}
For the premium version you can create your own class like and use markerTitle to set & get
#import <NMAKit/NMAKit.h>
@interface CustomMapMarker : NMAMapMarker
@property (nonatomic) NSString *markerTitle;
@end
For more details
NMAMapMarker Premuim
NMAMapMarker Starter
来源:https://stackoverflow.com/questions/43848113/tap-on-particular-marker-how-to-get-title-name