Hi,
Sometimes my shapefile layers is not shown on the map when i run my method below.
The first row with the Delay solves the problem. But is there another way to do it? Because i dont want to do the delay.
public async Task drawShapeFileAsync() { await Task.Delay(2000); ArrayList shpFiles = layersSingleton.getShpLayers(); for (int i = 0; i < shpFiles.Count; i++) { ShpLayer shpLayer = (ShpLayer)shpFiles[i]; string filepath = workingDirectory + "\\\\" + shpLayer.fileName; ShapefileFeatureTable shapefileFeatureTable = await ShapefileFeatureTable.OpenAsync(filepath); FeatureLayer featureLayer = new FeatureLayer(shapefileFeatureTable); featureLayer.RenderingMode = FeatureRenderingMode.Dynamic; await MyMapView.Map.LoadAsync(); MyMapView.Map.OperationalLayers.Add(featureLayer); } }
Any input would be appreciated.
Thanks, Mattias
Just curious, if there is a reason for loading MyMapView.Map.LoadAsync() in the loop?
Can you try removing `MyMapView.Map.LoadAsync()` from the loop. If loading the map is needed, I suggest either do it before or after the for loop.
No there was no reason for that.
I have now tried to move MyMapView.Map.LoadAsync() to both before and after the loop.
When i have it before the loop it works, but only if i still have the Delay. So it did not solve my problem.
Thanks for the suggestion.