I am attempting to create a Graphic that has as its symbol a PictureMarkerSymbol whose image source is derived from an image found at a given URI. I can successfully retrieve the image, and use it for other purposes, but when I make it the source of my PictureMarkerSymbol, set that symbol on a Graphic object, and add that Graphic object to the graphics layer... I see nothing.I have included a snippet of code that illustrates what I'm doing. This seems as though it should be a pretty standard operation, and I am wondering if I am missing something minor, or something critical.public void DrawAGraphic()
{
// The URI to the image (a PNG) is valid.
Uri imgUri = new Uri("http://localhost:8099/Objects.png", UriKind.Absolute);
BitmapImage bitmap = new BitmapImage();
// (I've tried each of the CreateOptions, but have been going with this one.)
bitmap.CreateOptions = BitmapCreateOptions.None;
// We'll try to place the graphic when the image loads.
bitmap.ImageOpened += new EventHandler<RoutedEventArgs>(bitmap_ImageOpened);
bitmap.UriSource = imgUri;
}
static void bitmap_ImageOpened(object sender, RoutedEventArgs e)
{
// This handler is called, so I believe I can safely say that
// we have the image in-hand. It's PixelWidth and PixelHeight
// properties are appropriate.
// The sender is the original bitmap we were trying to open.
// (At this point, the bitmap appears to be valid for any
// purpose other than using it with a PictureMarkerSymbol.)
BitmapImage bitmap = sender as BitmapImage;
// We create the picture marker symbol.
PictureMarkerSymbol pict = new PictureMarkerSymbol();
pict.Source = bitmap;
pict.OffsetX = 0;
pict.OffsetY = 0;
// Now we create the graphic.
Graphic graphic = new Graphic();
// The geometry is well within the map extent, and in the same
// spatial reference.
graphic.Geometry = new MapPoint(
-101.5, 47.5, new SpatialReference(4326));
graphic.Symbol = pict;
// We have access to the map's GraphicsLayer, so we add the graphic.
graphicsLayer.Graphics.Add(graphic);
}
I am using ArcGIS Server 10, Silverlight 4, C#, and Visual Studio 2010. I've been hunting around the forums and the Internet for information that might point me towards a solution, but haven't found anything so far. I would dearly appreciate any advice.