Select to view content in your preferred language

How to set MapTip for KmlLayer?

2650
1
10-18-2011 09:11 AM
VishakhaKadam
Emerging Contributor
Hi,

I am using arcgis esri wpf api 2.2. I have loaded the KML file from local machine into KML Layer As below.

FileStream stream = File.OpenRead(omf.path);  
  KmlLayer kmlItemLayer;
  FileInfo info = new FileInfo(omf.path);
  string[] fileName = info.Name.Split('.');
using (stream)
                    {
                        kmlItemLayer = new KmlLayer()
                        {
                            ID = "KML-" + fileName[0],
                         };                      
                        kmlItemLayer.SetSource(stream);    
                       
                    };
   BaseMap.Layers.Add(kmlItemLayer);

This displays the placemarks on the map, shows the graphics properly on the map, but I recevied following error.

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Symbol.TranslateX; DataItem=null; target element is 'TranslateTransform' (HashCode=35027383); target property is 'X' (type 'Double')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Symbol.TranslateY; DataItem=null; target element is 'TranslateTransform' (HashCode=35027383); target property is 'Y' (type 'Double')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Symbol.Heading; DataItem=null; target element is 'RotateTransform' (HashCode=20944767); target property is 'Angle' (type 'Double')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Symbol.Scale; DataItem=null; target element is 'ScaleTransform' (HashCode=36758902); target property is 'ScaleX' (type 'Double')
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=Symbol.Scale; DataItem=null; target element is 'ScaleTransform' (HashCode=36758902); target property is 'ScaleY' (type 'Double')

Then if try to retrieve graphics object to see what are the attributes by using kmlItemLayer.Graphics,
kmlItemLayer.Graphics is null (count=0).

If I get the attributes I need to set it as maptip for this kmlItemLayer.

Please help me with this issue. I really appreciate your help. Attached is KML sample file.

Thank you,

Sincerely
Vishakha
0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor
I tried the following sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#KmlLayerSimple and in the XAML, I added the following code:
<esri:KmlLayer.MapTip>
     <TextBlock Text="{Binding [name]}"/>
    </esri:KmlLayer.MapTip>
   </esri:KmlLayer>


If you are unsure what attribute to bind to, you can add a MouseLeftButtonDownEvent and inspect e.Graphic.Attributes.Keys.
0 Kudos