Adding marker on a map

3219
4
11-25-2010 03:05 PM
MukulSonwalkar
New Contributor
Hello,

I am trying to add a marker on my map but i am getting some warning (code highlighted) and application crashes on build

Here is code

id<AGSLayerView> graphicsLayerView = [self.mapView.mapLayerViews objectForKey:@"GraphicsLayer"];
 AGSGraphicsLayer* myGraphicsLayer = (AGSGraphicsLayer*)graphicsLayerView.agsLayer;
 //create a marker symbol to be used by our Graphic
 AGSSimpleMarkerSymbol *myMarkerSymbol =
 [AGSSimpleMarkerSymbol simpleMarkerSymbol];
 myMarkerSymbol.color = [UIColor blueColor];
 
 //Create an AGSPoint (which inherits from AGSGeometry) that
 //defines where the Graphic will be drawn
 AGSPoint* myMarkerPoint =
 [AGSPoint pointWithX:-93.2984
        y:44.9409
  spatialReference:self.mapView.spatialReference];
 
 //Create the Graphic, using the symbol and
 //geometry created earlier
 AGSGraphic* myGraphic = [AGSGraphic graphicWithGeometry:myMarkerPoint symbol:myMarkerSymbol attributes:nil infoTemplate:nil];
 
 //Add the graphic to the Graphics layer
 [myGraphicsLayer addGraphic:myGraphic];
 
 //Tell the layer to redraw itself
 [myGraphicsLayer dataChanged];




The warning: AGSGraphics may not respond to '+graphicWithGeometry:symbol:attributes:infoTemplate

Am i missing something??? Do i have to include any file/framework??

Thanks
0 Kudos
4 Replies
MelvinTan
New Contributor
If you are using the final version of ArcGIS API for iOS 1.0, you will need to replace infoTemplate with infoTemplateDelegate

AGSGraphic* myGraphic = [AGSGraphic graphicWithGeometry:myMarkerPoint symbol:myMarkerSymbol attributes:nil infoTemplateDelegate:nil];
0 Kudos
MukulSonwalkar
New Contributor
Thank you for your reply. I did try with the infoTemplateDelegate and i don't get the warning but i don't see the blue pin on the map. I am using the same code from last post.

Any ideas??
Thanks
0 Kudos
MelvinTan
New Contributor
Have you initialized the Graphics Layer and add it to the map before you execute those statements?
You will need to execute the following first:

AGSGraphicsLayer* graphicsLayer =  [AGSGraphicsLayer graphicsLayer];
[self.mapView addMapLayer:graphicsLayer withName:@"GraphicsLayer"];

The name should match what your codes attempt to retrieve.
0 Kudos
MukulSonwalkar
New Contributor
Thanks a lot!
0 Kudos