Select to view content in your preferred language

KMLLayer use of identify or maptips

1015
4
04-10-2011 09:15 PM
DanielBrown1
Deactivated User
I am interested in learning more about the KMLLayer and more importantly, being able to identify and/or use a maptip with the KML layers.

I know of the Resource Center sample under "Toolkit Data Sources" for KML... showing points and polygons of the Google campus.  But I need the sample to go one step further...  How would I learn more about maptips with a KMLLayer... or a identify tool...

I have reviewed the 2 maptips samples, but those are using QueryTasks and FeatureLayers... and seem to be using REST endpoints.  I did see the GeoRSS sample as well.  Unfortunately I cant use a AGS service for this project, and I seem to be stuck with the concept of using something else...

I have used Flex.. and now switching over to Silverlight... so...
Any help on a direction would be generous and help me stop staring at my computer.  🙂

thanks,d.
0 Kudos
4 Replies
DominiqueBroux
Esri Frequent Contributor
Identify is only working with AGS dynamic map service and so is not working with KMLLayers.

But as KMLLayer is a subclass of GraphicsLayer, the maptips will work with KMLLayer.

For example, with the KML interactive sample, you can get a maptip with this code:

   <Grid x:Name="LayoutRoot" >
 
<esri:Map x:Name="MyMap" WrapAround="True">
<esri:Map.Extent>
<esri:Envelope XMin="-122.090" YMin="37.419" XMax="-122.079" YMax="37.424">
<esri:Envelope.SpatialReference>
<esri:SpatialReference WKID="4326"/>
</esri:Envelope.SpatialReference>
</esri:Envelope>
</esri:Map.Extent>
 
<esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer" />
<esri:KmlLayer ID="KmlLayer" Url="http://kml-samples.googlecode.com/svn/trunk/KML_Samples.kml"
                          ProxyUrl=http://serverapps.esri.com/SilverlightDemos/ProxyPage/proxy.ashx/>
</esri:Map>
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" >
<esri:MapTip x:Name="MyMapTip" BorderBrush="#99000000" GraphicsLayer="{Binding Layers[KmlLayer],ElementName=MyMap}"
               BorderThickness="1" Title="{Binding [name]}" VerticalOffset="10" 
               HorizontalOffset="10" Background="#DDFFFFFF" />
</Canvas>
 
</Grid>
0 Kudos
ElizabethMiller
Regular Contributor
Is it also possible to include KML Extended Data in the KML Maptips? Is there an example somewhere?

Thanks!
0 Kudos
ShawnSeawright
Deactivated User
Is it also possible to include KML Extended Data in the KML Maptips? Is there an example somewhere?

Thanks!


Did you ever get an answer to this? I'm trying to figure this out as well.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Yes you can include the KML extended data in the maptip, but this needs a few code.

The extendeddata are stored as a list of 'KmlExtendedData' in an attribute called 'extendedData'.

To access this list, you will need a converter such as this one:
 
public class ExtendedDataConverter : IValueConverter
{
  public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
  {
     return value is IList<ESRI.ArcGIS.Client.Toolkit.DataSources.Kml.KmlExtendedData>
                 ? ((IList<ESRI.ArcGIS.Client.Toolkit.DataSources.Kml.KmlExtendedData>)value).Where(ed => ed.Name == parameter.ToString()).Select(ed => ed.Value.ToString()).FirstOrDefault()
                 : value;
  }
  public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
  {
    throw new System.NotImplementedException();
  }
}


This converter expects the KmlExtendedData list as input and the extended data name as parameter.
To use it, you define such a converter in your XAML resources:
 
<local:ExtendedDataConverter x:Key="extendedDataConverter" />

and you call it in your KML maptip:
 
<esri:KmlLayer ............ >
  <esri:KmlLayer.MapTip>
    <TextBlock Text="{Binding [extendedData], Converter={StaticResource extendedDataConverter}, ConverterParameter=myExtendedDataName}" />
  </esri:KmlLayer.MapTip>
</esri:KmlLayer>


Hope this helps.
0 Kudos