Navigating a GIS Map

You can navigate (i.e. pan or zoom) a GIS map both at model design time and at model runtime.

Navigating at model design time

At design time, by entering the map edit mode you can select the part of a map, as well as the level of the map’s detail, that you want to be displayed at runtime.

 To enter and exit the map edit mode

  1. To enter the map edit mode, either double-click the map or right-click it and select Edit Map from the menu:

     

  2. The rest of the graphical editor will become grayed out. You can now pan or zoom the map.

  3. To exit the map edit mode, either click the grayed-out area of the graphical editor or double-click the map. Alternatively, right-click the map and select Finish Map Editing from the menu.

Panning

 To pan the map

  1. Enter the edit mode for the map.
  2. Click on the map with the left mouse button and move the mouse while holding the button down. While panning a map, you will see a hand cursor:

  3. If you hold down the right mouse button and move it, you will pan the entire graphical editor with the GIS map still in edit mode.
  4. When finished panning, exit the map edit mode.

Zooming

 To zoom in or out

  1. Double-click the map to enter its edit mode. The rest of the graphical editor will become grayed out. 
  2. To zoom in, move the mouse wheel away from you; to zoom out, move the mouse wheel toward you. The map will zoom in or out at the mouse cursor location. To zoom in or out at a different location, first pan the map. If you are not in the map edit mode, moving the mouse wheel will scroll the entire canvas.
  3. If you hold down the Ctrl button and move the mouse wheel, the map will zoom with smaller steps. Although it may be slower to zoom this way, you can achieve greater precision.
  4. When finished zooming, exit the map edit mode.

Navigating at model runtime

At runtime you can pan the GIS map the same way as at design time: hold down the left mouse button and move the mouse. 

Some users may confuse panning inside the map and panning of the presentation window with the right mouse button. You can disable panning of the presentation window, so that users do not accidentally pan it at runtime. If a GIS map is the only environment for your model, this may be especially useful.

 To disable panning of the presentation window at runtime

  1. Select the Simulation experiment in the model tree to open its Properties view.
  2. Go to the Window section and clear the Enable zoom and panning check box.
  3. Panning of the presentation window with the right mouse button is now disabled. But panning the map itself with the left mouse button is still enabled.

Zooming in and out during runtime is just as easy as at design time.

 To zoom in or out

  1. Put the mouse cursor over the map location that you want to see closer when zooming in. 
  2. To zoom in, move the mouse wheel away from you. The GIS map will zoom in to the location around the mouse cursor location. This location will become the map’s center, so that you can better see the location itself and its surrounding area. 
  3. To zoom out, move the mouse wheel toward you. The map will zoom out relative to its center. It does not matter where the mouse cursor is located. To zoom out another part of the map, you can pan the map.
  4. Note that if you hold down the Ctrl key and move the mouse wheel, you will zoom the presentation window itself rather than the map.

Panning and Zooming Programmatically

Using functions, you can change a map's zoom, pan, or center coordinates dynamically during model runtime.
Map center

Function

Description

double getCenterLatitude()

[Not supported by AnyLogic Cloud] Returns the latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90) 

double getCenterLongitude()

[Not supported by AnyLogic Cloud] Returns the longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

void setCenterLatitude(double centerLatitude)

Sets the latitude of the map projection center.

Parameter:
centerLatitude - new latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

void setCenterLongitude(double centerLongitude)

Sets the longitude of the map projection center.

Parameter:
centerLongitude - new longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

void setProjectionCenter
(double centerLongitude,

double centerLatitude)

Sets the center of the map projection.

Parameters:
centerLongitude - new longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
centerLatitude - new latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

Map scale

Function

Description

double getMapScale()

Returns the scale of map projection (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm".

double getMinMapScale()

Returns the minimum available scale of the map projection (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm".

double getMaxMapScale()

Returns the maximum available scale of the map projection (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm".

void setMapScale(double mapScale)

Sets the scale of map projection

Parameter:
mapScale - the scale (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm"

void pan(int toEast,
int toNorth)

Moves the map projection center. Parameters are amounts of delta in the resulting offset. One horizontal delta is a half of longitude difference from map projection center to the west/east bound of projection.One vertical delta is a half of latitude difference from map projection center to the south/north bound of projection.

Parameters:
toEast - number of horizontal deltas to be added to the projection center, if positive, center is moved to the East, if negative - to the West
toNorth - number of vertical deltas to be added to the projection center, if positive, center is moved to the North, if negative - to the South

void setProjectionCenter
(double centerLongitude,

double centerLatitude)

Sets the center of the map projection.

Parameters:
centerLongitude - new longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
centerLatitude - new latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

void zoomIn()

Increases scale of map projection (x 2).

void zoomOut()

Decreases scale of map projection (x 1/2).


Related topics

 GIS tutorial

GIS map shape