Select to view content in your preferred language

KML Layer incorrectly placed features

943
6
11-10-2011 01:20 PM
BjørnarSundsbø
Deactivated User
I have the following code
<esri:Map x:Name="MyMap">
 <esri:ArcGISTiledMapServiceLayer ID="TopoLayer"
   Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
 <esri:KmlLayer ID="layer" Url="http://wms.met.no/googleearth/symbols.kml" />    
</esri:Map>


I had to make some changes to the KmlLayer class in the toolkit.datasources from codeplex for it to download the kml. The changes can be found here.

The Geometries of the features downloaded have correct X and Y. The layer displays just fine in Google Earth. In my map, the following image displays where the features are located. There are no other features anywhere else.



The question is, of course, why are they not displayed at the right location? Both layers have the same spatial reference. I'm using version 2.2 of the API.
0 Kudos
6 Replies
dotMorten_esri
Esri Notable Contributor
The question is, of course, why are they not displayed at the right location? Both layers have the same spatial reference. I'm using version 2.2 of the API. 


Are you sure they have the same spatial reference? KML always returns data in 4326, and as far as I can tell, you have a WebMercator layer as basemap, which would explain why the data shows up down around 0,0. You will need to reproject your KML data to WebMercator after the features has loaded.
0 Kudos
BjørnarSundsbø
Deactivated User
Excellent. When you're right, you're right. Used the reprojector sample from the blog. Works just fine now. It would be an good addition to the toolkit, with the ability to override a method so on might be able to do client side reprojection for other spatial references.
0 Kudos
GregMcMenimen
Emerging Contributor
Did you have to use a GeometryService to reproject?  I am still getting everything off of Africa even though I am using the OTB ArcGIS WMS for basemaps.  And i am using the AutoReproject.cs class from the blog.

Excellent. When you're right, you're right. Used the reprojector sample from the blog. Works just fine now. It would be an good addition to the toolkit, with the ability to override a method so on might be able to do client side reprojection for other spatial references.
0 Kudos
BjørnarSundsbø
Deactivated User
gmcmenimen,

Yes, I used an online GeometryService. BaseMap was the URL in a previous post. Worked just fine for me. What reference system does your basemap use, and is it supported by the GeometryService?
0 Kudos
GregMcMenimen
Emerging Contributor
My basemap is WebMercator.  My GeometryService should support WebMercator and WGS 84 I believe.  I will look at it again.  I thought that since it already looks at WebMercator in the code you could just use the <local:AutoProjector.Projector/> in the XAML.
0 Kudos
BjørnarSundsbø
Deactivated User
From what I remember from reading the code, reprojecting between webmercator and WGS 84 should be supported client-side. Don't remember if you have to specify a geometryservice url regardless.

I'm sorry I'm not able to help you out further. But if you paste your XAML with layers, someone should be able to help you out.
0 Kudos