I am trying to create a map which will include radar rainfall data in a KML format. How can I easily do this using the Silverlight API (the version doesn't matter)?
[GIS] Adding KML layer using ArcGIS API for Silverlight
arcgis-silverlight-apikml
Related Solutions
Crazy, but nevertheless... I was using AGS 10 sp1 and could not get a legend to show up from an internal test server (it could not connect to internet). For AGS below 10 sp2, AGS must be able to connect to ESRI servers to generate a legend. Upgrading to sp2 solved the problem because the legends are created on your own server. So crazy and unexpected...
From jsapi (but would apply to all) --
"If the layers are version 10 or lower the legend is created using the ArcGIS.com legend service. In order to use the ArcGIS.com legend service your map service needs to be publicly accessible and your application must be able to access ArcGIS.com."
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm
KmlLayer is alien to me, but I see it has a MapTip property same as FeatureLayer. Here's what we've got for FeatureLayers. These two lines are present in my main MapPage.xaml.cs in an event handler for the layer Initialized event.
FeatureLayerInfo lyrInfo = fLayer.LayerInfo;
fLayer.MapTip = CreateTipWindow(lyrInfo, fLayer.OutFields);
private PopupWindow CreateTipWindow(FeatureLayerInfo lyrInfo, List<string> outFields)
{
//edited to omit details not relevent...
Dictionary<string, string> aliases = new Dictionary<string, string>();
foreach (Field f in lyrInfo.Fields)
{
if (f.Name != lyrInfo.DisplayField) aliases.Add(f.Name, f.Alias);
}
PopupWindow tipWindow = new PopupWindow() { ShowArrow = false, ShowCloseButton = false };
tipWindow.Content = CreateFeatureTipContent(outFields, aliases);
return tipWindow;
}
private FrameworkElement CreateFeatureTipContent(List<string> fields, Dictionary<string, string> aliases)
{
StackPanel stackBox = new StackPanel() { Margin = new Thickness(4, 1, 4, 1), Orientation = Orientation.Vertical };
foreach (string field in fields)
{
if (aliases.Keys.Contains(field))
{
TextBlock valueBlock = new TextBlock() { TextWrapping = TextWrapping.NoWrap };
Binding valueBinding = new Binding() { Path = new PropertyPath(string.Format("[{0}]", field)), StringFormat = aliases[field] + ": {0}" };
valueBinding.Converter = new DateTimeConverter(); //MC 2013-01 added this to tweak any Local DateTimes.
valueBlock.SetBinding(TextBlock.TextProperty, valueBinding);
stackBox.Children.Add(valueBlock);
}
}
return stackBox;
}
We are using the PopupWindow class from the ESRI.SilverlightViewer.Controls library distrubuted with this viewer (from which we've learned a great deal, BTW), but PopupWindow simply derives from ContentControl, so rolling one's own is minor, if you want.
Best Answer
KML layers are not natively supported in AGS web APIs, AFAIK. There is a code sample that you can get inspiration from in the Resource Center: http://resources.esri.com/arcgisserver/apis/silverlight/index.cfm?fa=codeGalleryDetails&scriptID=16487