Hi
I have 3DAR up and running but have difficulties trying to display custom icons for the POIs.
Basically, I want to show a custom image for each SM3DARIconMarkerView on a POI. I have spent hours trying to figure out the right approach but the 3DAR library (v.2.1.3) just crashes no matter what.
What is the correct approach for adding a POI with a SM3DARIconMarkerView using a custom image?
Some of the approaches I have tried (which all fail):
1. Create a POI and try to manipulate the view:
CLLocation *location = [[CLLocation alloc] initWithLatitude:somePoint.y longitude:somePoint.x];
SM3DARPointOfInterest *annotation = [[SM3DARPointOfInterest alloc] initWithLocation:location properties:nil];
annotation.title = poi.title;
annotation.subtitle = poi.subtitle;
a. Get the existing view from the POI:
SM3DARIconMarkerView *iconMarkerView = (SM3DARIconMarkerView *)annotation.view;
iconMarkerView.imageName = poi.iconName;
b. Create a new view and set it on the POI:
SM3DARIconMarkerView *iconMarkerView = [[SM3DARIconMarkerView alloc] initWithPointOfInterest:annotation imageName:poi.iconName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:poi.iconName];
markerView.icon = imageView;
a. Add the point:
[self.sm3dar addPoint:annotation];
b. Add the POI: (What is the difference?)
[self.sm3dar addPointOfInterest:annotation];
2. Add a POI directly:
[self.sm3dar addPointOfInterestWithLatitude:somePoint.y
longitude:somePoint.x
altitude:0
title:poi.title
subtitle:poi.subtitle
markerViewClass:[SM3DARIconMarkerView class]
properties:nil];
The same approcaches for manipulating the view as above all fail.
3. Subclass SM3DARIconMarkerView and try to set the image and/or icon in the initWithPointOfInterest:imageName: method.
In all cases the custom image appears for the POIs but the 3DAR library crashes right after with the following exception:
2012-02-08 17:25:53.445 AppName[2632:707] -[ShowMeViewController updateMap] [Line 190] Adding annotations
2012-02-08 17:25:53.915 AppName[2632:707] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
The "Adding annotations" message is printed out after adding all the points but before the method exits, so the crash is not in the addPoint/addPointOfInterest methods but something after, probably inside the SM3DARIconMarkerView class.
FYI: I use ARC (automatic reference counting) and I debug on an iPhone 3GS.
Thanks for any help on this. I am out of ideas at this point. It is very unclear how using custom icons is supposed to be implemented.