I know I can create a map within a project without having to create a MapPane.
It works just by doing this:
var map = MapFactory.Instance.CreateMap("New Map 1", MapType.Map, MapViewingMode.Map, Basemap.None);
But if I want to define the center of the map, then I have to use a camera. And in order to use that camera, I must first create a MapPane:
await ProApp.Panes.CreateMapPaneAsync(map);
Then I can get the camera from that MapView:
Camera cam = MapView.Active.Camera;
But since I want to create many maps, displaying those MapPanes is time consuming and slows down the whole process.
So, is it possible to do this in the background (without opening a MapPane)?
Solved! Go to Solution.
I found the answer.
I have to use the CIMViewCamera in order to make it work. Just like this:
var map = MapFactory.Instance.CreateMap("New Map 1", MapType.Map, MapViewingMode.Map, Basemap.None);
var def = map.GetDefinition() as CIMMap;
var camera2 = new CIMViewCamera()
{
Heading = 0,
Pitch = -90,
Roll = 0,
Scale = 200000,
X = 855708,
Y = 1112409,
Z = double.NaN
};
def.DefaultCamera = camera2;
map.SetDefinition(def);
Using the CIMViewCamera allows me to define the camera position without having to create a MapPane, making the code run faster.
I found the answer.
I have to use the CIMViewCamera in order to make it work. Just like this:
var map = MapFactory.Instance.CreateMap("New Map 1", MapType.Map, MapViewingMode.Map, Basemap.None);
var def = map.GetDefinition() as CIMMap;
var camera2 = new CIMViewCamera()
{
Heading = 0,
Pitch = -90,
Roll = 0,
Scale = 200000,
X = 855708,
Y = 1112409,
Z = double.NaN
};
def.DefaultCamera = camera2;
map.SetDefinition(def);
Using the CIMViewCamera allows me to define the camera position without having to create a MapPane, making the code run faster.