Now that I have loaded a map in my app, I need to show a marker annotation for a location. Here is the code I'm using but nothing is showing on the map:
CLLocation *location = [[CLLocation alloc] initWithLatitude:douLat longitude:douLon];
AGSPoint *markerPoint = [AGSPoint pointWithLocation:location];
AGSGraphicsLayer* myGraphicsLayer = [AGSGraphicsLayer graphicsLayer];
[self.ibMapView addMapLayer:myGraphicsLayer withName:@"Graphic Layer"];
AGSPictureMarkerSymbol *markerSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:@"existing_project_icon.png"];
AGSGraphic* myGraphic = [AGSGraphic graphicWithGeometry:markerPoint
symbol:markerSymbol
attributes:nil];
// Add the graphic to the Graphics layer
[myGraphicsLayer addGraphic:myGraphic];
[self.ibMapView.callout showCalloutAtPoint:markerPoint forFeature:myGraphic layer:myGraphicsLayer animated:YES];
Please help.
Solved! Go to Solution.
I just replaced the (duoLat, duoLon) in your code with (0, 0) and it worked for me. Can you see the graphic on the map?
- Did you set your viewController to be the delegate for callouts (`AGSCalloutDelegate`)
?
This is initially `nil` & needs to be set or else annotations won't appear. You can then implement the delegate methods to control what the annotation displays.
Displaying a callout—ArcGIS Runtime SDK for iOS | ArcGIS for Developers
- Not sure it's relevant, but you call `showCalloutAtPoint...` immediately after adding the graphic.
Does `myGraphic` appear? If not, maybe refresh the layer or map before calling this method?
Where are you calling the `showCalloutAtPoint` method from? Try doing it from the `mapViewDidLoad` delegate.
Thanks for responding. I couldn't make much progress. Here is another way asking the same question:
Given the CLLocation *location, how can I draw an annotation on the map?
Any code samples would be highly appreciated.
Thanks.
I just replaced the (duoLat, duoLon) in your code with (0, 0) and it worked for me. Can you see the graphic on the map?