Select to view content in your preferred language

KmlLayer missing placemarks

1464
7
Jump to solution
02-09-2012 09:24 PM
TylerRothermund
Emerging Contributor
I have a Kml file that I'm loading that has a few placemarks.  When I view the file in GoogleEarth I can see the placemarks but they are not showing in my silverlight arcgis control;  any ideas?

Using Ver 2.3.0.774
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
I tried using TextSymbols for the placemarks

Changing symbols on the fly is a great idea 🙂

but I'm having a zIndex issue with the TextSymbols showing below the other graphics.
You can see from the remarked out code that I tried to fix the zIndex and use a KmlPlaceMarkerSymbol, but no luck.

Unfortunately DrawOrder is not supported either (sorry about that :() and changing the zindex is not working because the graphics are not in the same GraphicsLayer.

One option is to change the layer order by moving the text placemarks after the polygons.
This code should work:
private void KmlLayer_Initialized(object sender, EventArgs e) {     KmlLayer kmlLayer = sender as KmlLayer;      var placemarkers = kmlLayer.Graphics.Where(g => g.Symbol is KmlPlaceMarkerSymbol).ToList();     placemarkers.ForEach(p => p.Symbol = new TextSymbol() { Text = p.Attributes["name"].ToString(), FontSize = 20, OffsetX = 5 * p.Attributes["name"].ToString().Count(), OffsetY = 8 });      var regions = kmlLayer.ChildLayers["FEMA Regions"] as KmlLayer;     if (regions != null)     {         // move placemarks layer at the end         var placemarks = regions.ChildLayers["Placemarks"];         if (placemarks != null)         {             regions.ChildLayers.Remove(placemarks);             regions.ChildLayers.Add(placemarks); // add it at the end         }     } }

View solution in original post

0 Kudos
7 Replies
DominiqueBroux
Esri Frequent Contributor
Labelling is not supported by current implementation of the KML layer.
As the placemarks of your KML  are only symbolized by a label, we end up with blank placemarks.

There is no easy workarounds. Only one I see is you to get the KML layer code and tweak it.
0 Kudos
TylerRothermund
Emerging Contributor
The whats new section in the 2.3 documentation says it supports placemarks

"The KmlLayer was rebuilt as a GroupLayer (also new in 2.3) to better represent KML content. It includes support for nested folders (layers), setting visibility of layers, placemarks, ground overlays, regions, network links, auto-refresh on network links, and more. Support for display in the Legend control has also been added."
0 Kudos
TylerRothermund
Emerging Contributor
Could you please provide a little more direction on what it is I need to tweak in the KML Layer code?
0 Kudos
TylerRothermund
Emerging Contributor
I tried using TextSymbols for the placemarks but I'm having a zIndex issue with the TextSymbols showing below the other graphics. 
You can see from the remarked out code that I tried to fix the zIndex and use a KmlPlaceMarkerSymbol, but no luck.

Any Ideas???

        
        private void KmlLayer_Initialized(object sender, EventArgs e)
        {
            var regionXSymbols = ((KmlLayer)MyMap.Layers[1]).Graphics.Where(g => g.Attributes.Any(ga => ga.Value.ToString() == "Region X")).Select(g => g.Symbol as SimpleFillSymbol);
            regionXSymbols.ToList().ForEach(s => s.Fill = new SolidColorBrush(Colors.Red));

            var placemarkers = ((KmlLayer)MyMap.Layers[1]).Graphics.Where(g => g.Symbol is KmlPlaceMarkerSymbol).ToList();
            placemarkers.ForEach(p => p.Symbol = new TextSymbol() { Text = p.Attributes["name"].ToString(), FontSize=20});

            //placemarkers.ForEach(g => { g.Symbol = (KmlPlaceMarkerSymbol)Resources["KmlPlaceMarkerSymbol"]; g.SetZIndex(1000000); });

        }
0 Kudos
DominiqueBroux
Esri Frequent Contributor
The whats new section in the 2.3 documentation says it supports placemarks

"The KmlLayer was rebuilt as a GroupLayer (also new in 2.3) to better represent KML content. It includes support for nested folders (layers), setting visibility of layers, placemarks, ground overlays, regions, network links, auto-refresh on network links, and more. Support for display in the Legend control has also been added."

Placemarks (symbols, lines, polygons) are supported but the labelling of these placemarks is not.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I tried using TextSymbols for the placemarks

Changing symbols on the fly is a great idea 🙂

but I'm having a zIndex issue with the TextSymbols showing below the other graphics.
You can see from the remarked out code that I tried to fix the zIndex and use a KmlPlaceMarkerSymbol, but no luck.

Unfortunately DrawOrder is not supported either (sorry about that :() and changing the zindex is not working because the graphics are not in the same GraphicsLayer.

One option is to change the layer order by moving the text placemarks after the polygons.
This code should work:
private void KmlLayer_Initialized(object sender, EventArgs e) {     KmlLayer kmlLayer = sender as KmlLayer;      var placemarkers = kmlLayer.Graphics.Where(g => g.Symbol is KmlPlaceMarkerSymbol).ToList();     placemarkers.ForEach(p => p.Symbol = new TextSymbol() { Text = p.Attributes["name"].ToString(), FontSize = 20, OffsetX = 5 * p.Attributes["name"].ToString().Count(), OffsetY = 8 });      var regions = kmlLayer.ChildLayers["FEMA Regions"] as KmlLayer;     if (regions != null)     {         // move placemarks layer at the end         var placemarks = regions.ChildLayers["Placemarks"];         if (placemarks != null)         {             regions.ChildLayers.Remove(placemarks);             regions.ChildLayers.Add(placemarks); // add it at the end         }     } }
0 Kudos
TylerRothermund
Emerging Contributor
That works great, Thanks!
0 Kudos