Select to view content in your preferred language

What is the recommend way to create my Picture Marker?

1046
3
03-14-2011 02:39 PM
MarkCollins
Frequent Contributor
Hello,

I am creating a graphic layer that contains locations of several vehicles. We are using different images to differentiate vehicle types and would like render a circle/ball behind the image with a background color that is set programatically. (Using different colors to indicate a status). I have attached a picture of what I would like to do. (view pic) Right now all I am displaying is just the image with no circle/ball behind it. My questions is .... what is the best/recommend way to create the marker?

Here is the code I am using to create my current picture marker....
AGSPictureMarkerSymbol *myMarkerSymbol = [AGSPictureMarkerSymbol 
             pictureMarkerSymbolWithImage:[UIImage imageNamed:@"taxi.png"]]; 
 myMarkerSymbol.size = _defaultPinSize;
 
 //Create a dictionary w/ our pin attributes.
 NSArray *keys = [NSArray arrayWithObjects:@"UNITID", @"STATUS", nil];
 NSArray *objects = [NSArray arrayWithObjects:item.unitId, item.status, nil];
 NSDictionary *pindetails = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
 
 //Create an AGSPoint (which inherits from AGSGeometry) that
 //defines where the Graphic will be drawn
 AGSPoint* myMarkerPoint =
 [AGSPoint pointWithX:item.longitude
        y:item.latitude
  spatialReference:self.mapView.spatialReference];
 
 [self UpateMaxMin:item.latitude longitude:item.longitude];
 
 //Create the Graphic, using the symbol and
 //geometry created earlier
 AGSGraphic *myGraphic = [AGSGraphic 
        graphicWithGeometry:myMarkerPoint 
        symbol:myMarkerSymbol 
        attributes:pindetails 
        infoTemplateDelegate:unitTemplate];
 
 [self.unitsLayer addGraphic:myGraphic];


I have tried creating SimpleFill and SimpleMarker symbols but was not able to figure out to render my image on top of them or add the image to the symbol. Is it a bad idea to try and add two separate symbols (one simple marker and other image picture marker) at the same coordinates to try and achieve the desired result? It seems like there is probably a better way to do this.. any ideas would be appreciated.

Thanks,
Mark
0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
Hi Mark,

You should use AGSCompositeSymbol. Add a Simple Marker and Picture Marker symbols to composite symbol and assign it to a graphic.

Also, if your vehicle types are already defined then you can use the unique value renderer to symbolize features instead of assigning a symbol each graphic.

Regards,
Nimesh
0 Kudos
MarkCollins
Frequent Contributor
Thanks for the suggestion! I have tried it and it seems to be working great. For any one doing the same here is how I did it... (sry for the sloppy code!)


AGSCompositeSymbol *compSymbol = [[AGSCompositeSymbol alloc] init];
    
 AGSPictureMarkerSymbol *myMarkerSymbol = [AGSPictureMarkerSymbol 
             pictureMarkerSymbolWithImage:[UIImage imageNamed:@"taxi.png"]]; 
 myMarkerSymbol.size = _defaultPinSize;
 
 
 
 //Create the AGSSimpleMarker Symbol and set some properties
 AGSSimpleMarkerSymbol* simpleSymbol = [AGSSimpleMarkerSymbol simpleMarkerSymbol];
 simpleSymbol.color = [UIColor blueColor];
 simpleSymbol.style = AGSSimpleMarkerSymbolStyleCircle;
    simpleSymbol.size = 40;
 simpleSymbol.outline.color = [UIColor blackColor];
 simpleSymbol.outline.width = 2;
    
    [compSymbol.symbols addObject:simpleSymbol];
    [compSymbol.symbols addObject:myMarkerSymbol];
0 Kudos
MichaelLiu1
Emerging Contributor
Your Picture Marker looks cool. Great job!

We would like to add Video Marker (e.g. Youtube Preview Panel) to our map. What is the best way to implement this feature via ArcGIS? Any suggestions will be greatly appreciated!

Best,
Mike
0 Kudos