Select to view content in your preferred language

When adding a shapefile as a layer its objects do not display properly on the basemap

1178
5
04-16-2021 08:15 AM
SteveStamm
Emerging Contributor

Sorry about the images. I can't take code as text out of the development environment.

We are converting an old system based on version 10 to the latest 100 version. When using a shapefile as a layer using this code:

1.png

We get this. But...

2.png

using the same files but the older version of the API I get the following. It looks like the projection is okay but the extent is messed up. How do I match the extent of the shapefile with the base-map?

3.png

Thanks so much for any help!

Steve

0 Kudos
5 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

In the 100.x generation Shapefiles are now supported directly by the ArcGIS Runtime API, without needing to go via the Local Server component. While it's not directly solving the question, I'd recommend trying this approach.

For  API ref and sample code see https://developers.arcgis.com/net/wpf/api-reference/html/T_Esri_ArcGISRuntime_Data_ShapefileFeatureT...

 

0 Kudos
SteveStamm
Emerging Contributor

Michael,

Thanks for your speedy reply.

Looking at your reply and the code I sent leaves me a bit confused. I am not using LocalServer. In fact I got the code I am using from the page you recommended.

I assumed that the line:

await MyMapView.SetViewpointGeometryAsync(newFeatureLayer.FullExtent, 50);

Would set the width and height of the shape file or the basemap so that they match. I know that the API does not re-project the shapefile so you have to make sure that the projections are the same but that doesn't appear to be the issue here (They are both WKID:4269). There has to be a way somehow to make the two use the same starting dimensions.

Thanks again!

Steve

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Steve,

Sorry - I read the first part involving "_emptyMpkPath" and assumed you were using the Local Server.

You are of course correct: you are using the direct API when using ShapefileFeatureTable.

The API should re-project on-the-fly to match the spatial reference of the map.

Possibly you need the additional 'Project Engine' files? (this is a guess, but worth a try I think) 

Take a look at this topic which explains the additional PE files: https://developers.arcgis.com/net/spatial-and-data-analysis/spatial-references/

SteveStamm
Emerging Contributor

Thanks Michael,

I will take a look on Monday. I appreciate your help.

Steve

0 Kudos
SteveStamm
Emerging Contributor

Michael,

Looking at the two layers as I try to display them I see the following WKTEXT for the map and for the layer I am about to add.

SteveStamm_0-1618862063146.png

Once I add the layer AllLayers looks like the following.

SteveStamm_1-1618863917760.png

Does that look right?

Thanks,

Steve

 

0 Kudos