Hi,
I'm using runtime SDK 10.2.6 in a WPF app. I'm tring to add several layers of different kinds in my Map.
// base MyMapView.Map.Layers.Add(new OpenStreetMapLayer()); // first feature layer, from service var serviceTable = await ServiceFeatureTable.OpenAsync( new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/0")); var layer = new FeatureLayer(serviceTable) { ID = "featureLayer" }; MyMapView.Map.Layers.Add(layer); // second feature layer, from shapefile (world-cities.shp in the sample data) var shapefile = await ShapefileTable.OpenAsync(path); var layer2 = new FeatureLayer(shapefile) { ID = shapefile.Name, DisplayName = path, }; MyMapView.Map.Layers.Add(layer2);
The thing is, the layers are rendered, but the shapefile one does not have the same scale :
(when zooming)
Could someboby please tell me what I'm missing here ?
Thanks
Solved! Go to Solution.
Hi Jerome -
The world cities in the sample-data folder are in geographic coordinates. Like most available basemaps, the OpenStreetMap data are in Web Mercator and shapefiles won't reproject to conform with a different coordinate system. To display the world-cities layer correctly, you can either: 1) add it to a map view that is in geographic coordinates (as the only layer, or with other WGS84 datasets, for example) or 2) reproject the shapefile into Web Mercator so it will overlay with most available basemaps.
I used ArcMap to reproject the world-cities.shp dataset to Web Mercator and enclosed the result here. You should be able to add these data to your app and have them display correctly.
Thad
Hi,
The first thing to check is that your Shapefile has the same spatial reference as your MapView. However, since the Shapefile does actually display, I'd suggest checking that your Shapefile actually has valid spatial reference information (there should be a .prj file along side the .shp, .dbf, etc).
Cheers
Mike
Hi,
Thanks for your answer.
In my test, I'm using one of the files included in the sample-data folder : world-cities.shp.
The .prj associated seems to be OK (GCS_WGS_1984) and is the same as the MapView.
Jérome
Hi Jerome -
The world cities in the sample-data folder are in geographic coordinates. Like most available basemaps, the OpenStreetMap data are in Web Mercator and shapefiles won't reproject to conform with a different coordinate system. To display the world-cities layer correctly, you can either: 1) add it to a map view that is in geographic coordinates (as the only layer, or with other WGS84 datasets, for example) or 2) reproject the shapefile into Web Mercator so it will overlay with most available basemaps.
I used ArcMap to reproject the world-cities.shp dataset to Web Mercator and enclosed the result here. You should be able to add these data to your app and have them display correctly.
Thad
Thank you !