POST
|
I have a resolution. It turns out that the problem wasn't with the code I posted, but rather with the way I had the map configured (d'oh!). The map in which the graphics didn't appear had the graphics layer defined in XAML, and the base map layer defined in code in such a way that the graphics layer was beneath the base map. After I rectified that, the graphics started appearing. I apologize for what was probably a confusing question. For what it's worth, the code I posted does apparently seem to be a reasonable example for creating the image from a URL. Once again, many thanks.
... View more
09-30-2010
06:58 AM
|
0
|
0
|
194
|
POST
|
Thank you for your reply. The ImageOpened event handler is being hit (I verify that with a breakpoint). When I created the BitmapImage by passing the URI to the constructor, it was not, but using the code as I've posted it here, it is. I have performed tests wherein I use the loaded BitmapImage in a regular Image control and that seems to work as you would expect. (That is to say, you see the image in the control.) I have witnessed in my experimentation that if I create the BitmapImage (passing the URI to the contructor), then use it as the ImageSource for a standard .Net control (like the Image control), the ImageOpened event doesn't fire if I don't actually put that .Net control somewhere into the layout so it can be drawn. So I think I can generally verify what you're saying about Silverlight not downloading the image until it's time to show it in some cases. But, as I say, in this case I think I do have a valid BitmapImage by the time I make it the image source of my PictureMarkerSymbol. That has led me to think that I am just missing a step somewhere. Essentially, what I am trying to do is create a graphic whose picture is retrieved from a URL (rather than being defined by a resource in my XAP). It seems as though the process I'm using should allow me to do that, but I am wondering: Can I actually do this with the API? If so, is there perhaps a code sample somewhere that demonstrates how I should be going about it?
... View more
09-30-2010
05:10 AM
|
0
|
0
|
194
|
POST
|
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.
... View more
09-29-2010
01:41 PM
|
0
|
3
|
2137
|
POST
|
Not too long after I posted this message, I found an explanation for the behavior I described. I was, indeed, initializing an ArcObjects class as a private member of my class before calling RuntimeManager.Bind(). That initialization didn't throw an exception; but by creating it after calling RuntimeManager.Bind(), I no longer seem to see the problem mentioned in my post.
... View more
04-23-2010
11:05 AM
|
0
|
0
|
382
|
POST
|
I am having some trouble with the RuntimeManager in the ArcGIS 10.0 beta. I persistently (though not consistently) get an exception at this point in my code: // Before executing the offending line, I do this to "bind to an ArcGIS version".
// (In this example I use Engine, but I have the same problem if I use Server).
RuntimeManager.Bind(ProductCode.Engine);
// (These are the variables I'm working with...)
esriLicenseStatus licenseStatus;
private IAoInitialize m_AoInitialize = new AoInitializeClass();
esriLicenseProductCode productCode;
// This line is where I get the exception...
licenseStatus = m_AoInitialize.IsProductCodeAvailable(productCode); // And here are the exception details... System.Runtime.InteropServices.COMException occurred Message="ArcGIS version not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components." Source="esriSystem.AoInitialize" ErrorCode=-2147221002 StackTrace: at ESRI.ArcGIS.esriSystem.AoInitializeClass.IsProduct CodeAvailable(esriLicenseProductCode ProductCode) at Bbsi.ArcObjects.Bs.AoLicenseInitializer.CheckOutPr oduct(esriLicenseProductCode productCode) in <my code file> InnerException: My machine does have valid Engine and Server licenses. The peculiar part is that I don't see this exception every single time. I happens most of the time; but without my changing anything, it some times does not. I have flailed at it by changing the product code I pass to RuntimeManager.Bind() from Engine to Server, placing breakpoints and waiting a few seconds between calling RuntimeManager.Bind() and calling IsProductCodeAvailable(), but I have yet to determine with certainty how to make it succeed or fail reliably. When the exception is not thrown, the application behaves normally. If I place a break point before the offending line of code and inspect the RuntimeManager's ActiveRuntime property, it looks as though it's ready to go (so far as I can tell, anyway): ESRI.ArcGIS.RuntimeManager.ActiveRuntime {ESRI.ArcGIS.RuntimeInfo} Path: "C:\\Program Files\\ArcGIS\\Engine10.0\\" Product: Engine Version: "10.0" I am using C# and Visual Studio 2008 on Windows 7 (32-bit) and had no similar problem with this application when I built it against 9.3. In fact, the only difference between the version built against 9.3 and this one is the call to RuntimeManager.Bind(), which I understand is a new convention in 10.0. I would greatly appreciate any advice I can get.
... View more
04-23-2010
10:27 AM
|
0
|
2
|
2689
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|