Select to view content in your preferred language

MarkerSymbols or PictureMarkerSymbols, where to Put the Image, and testing

2712
4
05-06-2011 12:38 PM
TonyThatcher
Deactivated User
OK, Next up is applying custom symbology to my points.  I have successfully defined my symbology using both a MarkerSymbol with ImageBrush:

<ImageBrush ImageSource="http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/Assets/images/flag-yellow-32x32.png" x:Name="MyImageBrush" />
                                        
                    <esriSymbols:MarkerSymbol x:Name="testImageBrush">
                        <esriSymbols:MarkerSymbol.ControlTemplate>
                            <ControlTemplate>
                                <Rectangle Width="20" Height="20" Fill="{StaticResource MyImageBrush}" />
                            </ControlTemplate>
                        </esriSymbols:MarkerSymbol.ControlTemplate>
                    </esriSymbols:MarkerSymbol>


And just using a simple PictureMarkerSymbol:
<esri:PictureMarkerSymbol x:Key="TestPictureMarker" Height="30" Width="30" OffsetX="15" OffsetY="15"  Source="http://resources.esri.com/help/9.3/arcgisserver/apis/silverlight/samples/Assets/images/flag-yellow-32x32.png" />


Both of these examples use the ESRI yellow flag symbol that is located on the ESRI site (e.g. web accessable), and both work exactly the same way.  But when I try and use my own .png file, I can not get any markers to show up.  For example, if I replace the ImageBrush defined above with:
<ImageBrush ImageSource="flag-yellow-32x32.png" x:Name="MyImageBrush" />

Nothing shows up on the map.  The .png file is in the root of my web directory.  I have also tried it in the 'Assets' folder, along with every combination of path I can think of.  Note that this is happening when I am debugging/testing the application locally.  I have not tried a full build and live deployment.  This is running in the localhost environemnt.  I can access and display other .png  files (e.g. an Info graphic in the legend template) without any problem.  But when I try and use any .png file in my application, nothing shows up.

Any ideas?
0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor
Note that relative paths are relative to the .xap file, and NOT the .html/.aspx file.

This is a good overview on Silverlight relative paths to images:
See http://weblogs.asp.net/jgalloway/archive/2008/09/11/silverlight-and-relative-uri-s-for-image-and-vid...
As noted there, is that you need a trailing forward slash on the path, since you are not compiling the image into the .xap
0 Kudos
TonyThatcher
Deactivated User
Thanks for that link.  For me it wasn't the way the relative path was stated, I had tried all of the possible combinations of hashes.  What it turned out to be was the Build Action (in the Properties) of the .png file.  When adding an Existing Item to the project, that items comes in as a "Resource" in the Build Action.  Changing it to be "Content" made all the difference.  Here's the quote from the article.

1.Include the content in a subfolder of ClientBin. Set the content type to �??Content�?� rather than �??Resource�?� unless you want it downloaded with the XAP. Don�??t include the media as a resource, or your users will have to download all the video and images before the Silverlight element is displayed.


Onward!

-T
0 Kudos
dotMorten_esri
Esri Notable Contributor
Oh. You stated the file was on your webserver, so I never thought about build action. I guess the file is in your xap then?
0 Kudos
TonyThatcher
Deactivated User
I'm not sure if it is compiled into the XAP.  I'm a long-time VBA and ASP guy, so the Silverlight stuff is a bit counterintuitive.  That said I am building and testing an application locally that will be deployed on a client's webserver. 

Another .png mystery came up.  I had another .png that was bing used in a legend template as an Image.  Everything worked fine up until a couple of days ago when the image simply disapperaed from the legend.  No errors, no warning, just would not show up.  Deleted the file, re-added it.  Changed settings back and forth.  No go.  An older version of the application still worked just fine using the exact same code.  It just simply stopped working in the latest version.  I did a bit of digging around on Silverlight forums and came up with the following fix.

Instead of:
<Image Height="15" Width="15"  Source="/Assets/Images/InfoTag.png" MouseLeftButtonDown="Image_MouseLeftButtonDown" Tag="{Binding Label}"  />

use:
<Image Height="15" Width="15"  Source="/PlacePlay1;component/Assets/Images/InfoTag.png" MouseLeftButtonDown="Image_MouseLeftButtonDown" Tag="{Binding Label}"  />

Where "PlacePlay1" is the name of my application.

Go figure.  New post coming with problems with the renderer! 

-T
0 Kudos