Hi,
In a scenario I add a layer on map then add BingMapsOverlay as background.
Since Bing and google have different projection than my source I have to set the projection of all layers through a loop :
var projection =
new
Proj4Projection
{
InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(27700),
ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString()
};
projection.Open();
foreach
(Overlay itm
in
WpfMap.Overlays)
{
var overlay = (LayerOverlay) itm;
var featureLayer = (FeatureLayer) overlay.Layers.FirstOrDefault();
if
(featureLayer ==
null
)
continue
;
featureLayer.FeatureSource.Projection = projection;
WpfMap.Refresh(overlay);
}
So far it works well and layer is observable on the expected location.
Based on the scenario I might have to add a InMemoryFeatureLayer to the map after adding BingOverlay and applying projection on existing layers.
As I tried, although the InMemoryFeatureLayer has the proper projection but the map doesn’t show it. This is the code to adding InMemoryFeatureLayer to the map :
private
void
AddInMemoryFeatureLayer()
{
var highlightOverlay =
new
LayerOverlay();
var layer =
new
ShapeFileFeatureLayer(@
“ShpFiles\Cardiff_Boundary_region.shp”
);
layer.Open();
IEnumerable<Feature> features = layer.QueryTools.GetAllFeatures(ReturningColumnsType.NoColumns).Take(01);
Collection<FeatureSourceColumn> collection = layer.QueryTools.GetColumns();
var inmeory =
new
InMemoryFeatureLayer(collection.ToList(), features);
inmeory.ZoomLevelSet = GetHighlightLayerStyle();
var projection =
new
Proj4Projection
{
InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(27700),
ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString()
};
projection.Open();
inmeory.FeatureSource.Projection = projection;
highlightOverlay.Layers.Add(inmeory);
WpfMap.Overlays.Add(highlightOverlay);
WpfMap.Overlays.MoveToTop(highlightOverlay);
WpfMap.Refresh(highlightOverlay);
}
If I add the InMemoryFeatureLayer (with null projection on it’s feature layer) before applying the projection on other layers and extent, everything works fine. But my scenario in the actual project is like that I have to add InMemory after adding BingOverlay.
To be more clear I have created a light sample that shows the problem.
In attached project I have firstly added a shapeFile then added BingMap as background and finally tried to add an InMemoryFeatureLayer on the Map.
Thank you in advance,
Sean
ThinkgeoWmsIneMemoryFeatureLayer.zip (35 KB)