Select to view content in your preferred language

Defining the center of a map in the background?

325
1
Jump to solution
07-29-2022 12:48 PM
MarioLandry2
New Contributor III

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)?

 

0 Kudos
1 Solution

Accepted Solutions
MarioLandry2
New Contributor III

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.

View solution in original post

0 Kudos
1 Reply
MarioLandry2
New Contributor III

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.

0 Kudos