I added the following lines of code to a controller class that manages my map instances so that I can change base map from WorldMapKit to OpenStreetMaps, Google or Bing.
var featureLayers = map.GetFeatureLayers();
var proj4Projection =
new
ManagedProj4Projection();
proj4Projection.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
proj4Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString();
foreach
(var featureLayer
in
featureLayers)
{
featureLayer.FeatureSource.Projection = proj4Projection;
}
map.SafelyRefresh();
When I run the application, I now get error: “The projection is not open. Please open it before calling this method”. I am not explicitly calling FeatureSource.Open any where in these feature layers so do not know the proper way to correct this.
Based on a similar problem reported here, I tried creating a projection object for each layer and this still fails with the aforementioned error.
var featureLayers = map.GetFeatureLayers();
foreach
(var featureLayer
in
featureLayers)
{
var proj4Projection =
new
ManagedProj4Projection();
var srid = ViewState.ProjectionSRID;
proj4Projection.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(srid);
proj4Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString();
featureLayer.FeatureSource.Projection = proj4Projection;
}
How do I handle this?
Klaus