Exercise outline
We want to show the FM model together with the stations that we created.
Create a view for a FM model and stations
And add this code to the end of the script :
#region Create a view for a FM model and stations # Create a view for the fmModel Gui.DocumentViewsResolver.OpenViewForData(fmModel) view = Gui.DocumentViews[Gui.DocumentViews.Count-1] # Create layers for stations and Satellite images stationLayer = CreateMapLayerForStations(stationList, fmModel.CoordinateSystem) bingLayer = BingLayer() bingLayer.Name = "Satellite Hybrid (Bing Maps)" # Set map coordinate system to webmercator (used by Bing Maps) map = view.MapView.Map map.CoordinateSystem = Map.CoordinateSystemFactory.CreateFromEPSG(3857) # webmercator # Add the layers to the map map.Layers.Add(stationLayer) map.Layers.Add(bingLayer) map.ZoomToExtents() #endregion
The following statements will ask DeltaShell (DocumentViewsResolver - object containing the logic to create (resolve) document views) to create a view for our FM model. Then we find the view (the last added view) by looking in the "Gui.DocumentViews" and assign it to the view variable.
# Create a view for the fmModel Gui.DocumentViewsResolver.OpenViewForData(fmModel) view = Gui.DocumentViews[Gui.DocumentViews.Count-1]
Now we create a layer for our stations and a layer for the satellite images (as background):
# Create layers for stations and Satellite images stationLayer = CreateMapLayerForStations(stationList, fmModel.CoordinateSystem) bingLayer = BingLayer() bingLayer.Name = "Satellite Hybrid (Bing Maps)"
Finally we set the coordinate system of the map to webmercator (used by Bing Maps), and add our layers
# Set map coordinate system to webmercator (used by Bing Maps) map = view.MapView.Map map.CoordinateSystem = Map.CoordinateSystemFactory.CreateFromEPSG(3857) # webmercator # Add the layers to the map map.Layers.Add(stationLayer) map.Layers.Add(bingLayer) map.ZoomToExtents()