Select to view content in your preferred language

KmlLayer does not display images

4543
13
Jump to solution
01-21-2012 11:28 PM
NataliaEvsyuchenya
Emerging Contributor
Hello!

I am try to add KmlLayer to the Map. I place kmz file at the  C:\inetpub\wwwroot\KML_TEST_FILES\. If unzip the my kmz file you can see:


[INDENT]<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<GroundOverlay>
<name>????????? ??? ????????</name>
<Icon>
  <href>files/4_9.jpg</href>
  <viewBoundScale>0.75</viewBoundScale>
</Icon>
<LatLonBox>
  <north>52.95165833333334</north>
  <south>52.70903611111112</south>
  <east>27.76611666666667</east>
  <west>27.37067500000001</west>
</LatLonBox>
</GroundOverlay>
</kml>
[/INDENT]


I add the following code to my page:

              [INDENT]  public MainPage()
  {
   InitializeComponent();
                        Map.Layers.Add(new KmlLayer()
                                                       {
                                                              Url = new Uri("http://localhost/KML_TEST_FILES/radar.kmz"),
                                                              ID = "Kml layer"
                                                        });
  }
[/INDENT]


There is no errors but image is not shown on the map. What's the problem?
0 Kudos
13 Replies
NataliaEvsyuchenya
Emerging Contributor
I could display image when I set for Basic Layer Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" instead of "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer". But why KmlLayer depends on Basic Layer?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I could display image when I set for Basic Layer Url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer" instead of "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer". But why KmlLayer depends on Basic Layer?

That rings a bell.
The extent of the images is set with the geographical coordinates found in the KML file but this extent is not the right one when your map is using projected coordinates.

In fact, KML Groundoverlays don't support autoprojection to non geographic coordinates. It's identified as a possible future enhancement but not planned at this time.

It's probably possible to project the extent by yourself (not tested and probably not that easy though):
- go through the KML layer hierachy to find all ElementLayers
- for each ElementLayer, loop on the elements
- for each element, project the extent from Geographical coordinates to Mercator

Sorry I should have thought about that sooner.
0 Kudos
HumzaAkhtar
Deactivated User
That rings a bell.
The extent of the images is set with the geographical coordinates found in the KML file but this extent is not the right one when your map is using projected coordinates.

In fact, KML Groundoverlays don't support autoprojection to non geographic coordinates. It's identified as a possible future enhancement but not planned at this time.

It's probably possible to project the extent by yourself (not tested and probably not that easy though):
- go through the KML layer hierachy to find all ElementLayers
- for each ElementLayer, loop on the elements
- for each element, project the extent from Geographical coordinates to Mercator

Sorry I should have thought about that sooner.




Hi,

Is the issue you mentioned in your post solved in the new runtime API 10.1.1 ?

Thanks and Regards
Humza
0 Kudos
DominiqueBroux
Esri Frequent Contributor

For the WebMercator case and images that cover a small area, this has been fixed in the ArcGIS for WPF version 10.1.1 and ArcGIS for Silverlight version 3.1.

For others map spatial references, it's not fixed. The workaround may be to project the groundoverlay extent by yourself by using a geometry service. This may make sense for SpatialReferences whose the projection of a WGS84 envelope is also an envelope (i.e a projection where meridians and parallels are perpendicular straight lines).

But anyway  this will not be accurate for images that cover a large area (due to the image distorsion)

0 Kudos