Version

Navigating Map Content Using Code

Purpose

This topic provides information about navigating the map content in the UltraGeographicMap™ control using code.

Required background

The following table lists the topics required as a prerequisite to understanding this topic.

Topic Purpose

This topic provides information about layout of map elements in the UltraGeographicMap control.

This topic provides conceptual information about navigating map content in the UltraGeographicMap control as well as all supported navigation features of the control.

Map Navigation

Overview

In the UltraGeographicMap control, there are two navigation techniques for navigating the map content using code. The first technique allows map navigation using window navigation system and the second one using world navigation system.

  • Window Navigation System

  • World Navigation System

The UltraGeographicMap control provides methods for converting values between both navigation systems. These methods are explained in the Examples section of this topic.

Window navigation system

The window navigation system consists of properties for setting position and size of WindowRect – a map view in window coordinates. In this navigation system values can be set between 0 and 1 for properties of the map window view.

The following image is a preview of UltraGeographicMap control with highlighted position and size of the WindowRect when zoomed to some region of the map content (for example, Africa and Europe continents).

GeographicMap Navigating Map Content Using Code 1.png

The following table summarizes properties for setting position and size of map window in the UltraGeographicMap control.

Property Type Description

Rectangle

Specifies position and size of the map window - currently viewable area of the map content in window coordinates and the anchor point is located in the top left corner of the window rect.

double

Specifies horizontal position of the map window’s anchor point from the left edge of the UltraGeographicMap control. It is equivalent to value stored in the Left of the WindowRect property.

double

Specifies vertical position of the map window’s anchor point from the top edge of the UltraGeographicMap control. It is equivalent to value stored in the Top of the WindowRect property.

World navigation system

The world navigation system consists of properties for setting position and size of the WorldRect – a map view in geographic coordinates. In this navigation system values can be set between -180 and 180 for longitude properties of the WorldRect and values between -85 and 85 for latitude properties of the WorldRect view.

The following image is a preview of UltraGeographicMap control with highlighted position and size of the WorldRect when zoomed to some region of the map content (for example, Africa and Europe continents).

GeographicMap Navigating Map Content Using Code 2.png

The following table summarizes properties for setting position and size of map window in the UltraGeographicMap control.

Property Type Description

Rectangle

Specifies position and size of the map navigation bounds – an area of the map content in world geographic coordinates within map navigation is allowed.

Map Navigation Features

Examples

Zoom in the map content, to the center of map by factor of 0.1

In C#:

var widthScale = (0.1 * this.GeoMap.WindowRect.Width);
var heightScale = (0.1 * this.GeoMap.WindowRect.Height);
var x = this.GeoMap.WindowRect.X + (widthScale / 2);
var y = this.GeoMap.WindowRect.Y + (heightScale / 2);
var w = this.GeoMap.WindowRect.Width - widthScale;
var h = this.GeoMap.WindowRect.Height - heightScale;
this.GeoMap.WindowRect = new Rectangle(x, y, w, h);

In Visual Basic:

Dim widthScale = (0.1 * Me.GeoMap.WindowRect.Width)
Dim heightScale = (0.1 * Me.GeoMap.WindowRect.Height)
Dim x = Me.GeoMap.WindowRect.X + (widthScale / 2)
Dim y = Me.GeoMap.WindowRect.Y + (heightScale / 2)
Dim w = Me.GeoMap.WindowRect.Width - widthScale
Dim h = Me.GeoMap.WindowRect.Height - heightScale
Me.GeoMap.WindowRect = New Rectangle(x, y, w, h)

Zoom out the map content by factor of 0.1

In C#:

var widthScale = (0.1 * this.GeoMap.WindowRect.Width);
var heightScale = (0.1 * this.GeoMap.WindowRect.Height);
var x = this.GeoMap.WindowRect.X - (widthScale / 2);
var y = this.GeoMap.WindowRect.Y - (heightScale / 2);
var w = this.GeoMap.WindowRect.Width + widthScale;
var h = this.GeoMap.WindowRect.Height + heightScale;
this.GeoMap.WindowRect = new Rectangle(x, y, w, h);

In Visual Basic:

Dim widthScale = (0.1 * Me.GeoMap.WindowRect.Width)
Dim heightScale = (0.1 * Me.GeoMap.WindowRect.Height)
Dim x = Me.GeoMap.WindowRect.X - (widthScale / 2)
Dim y = Me.GeoMap.WindowRect.Y - (heightScale / 2)
Dim w = Me.GeoMap.WindowRect.Width + widthScale
Dim h = Me.GeoMap.WindowRect.Height + heightScale
Me.GeoMap.WindowRect = New Rectangle(x, y, w, h)

Zoom to an area of the map content using map window coordinates

In C#:

this.GeoMap.WindowRect = new Rectangle(0.2, 0.3, 0.6, 0.4);

In Visual Basic:

Me.GeoMap.WindowRect = New Rectangle(0.2, 0.3, 0.6, 0.4)

Zoom to geographic region of the map content using world geographic coordinates

In C#:

var geoRegion = new Rectangle(-30, -40, 120, 80);
this.GeoMap.WindowRect = this.GeoMap.GetZoomFromGeographic(geoRegion);

In Visual Basic:

Dim geoRegion = New Rectangle(-30, -40, 120, 80)
Me.GeoMap.WindowRect = Me.GeoMap.GetZoomFromGeographic(geoRegion)

Fit the map content to viewable area using map window coordinates

In C#:

this.GeoMap.WindowRect = Rectangle(0.0, 0.0, 1.0, 1.0);

In Visual Basic:

Me.GeoMap.WindowRect = New Rectangle(0.0, 0.0, 1.0, 1.0)

Fit map content to maximum viewable area using world geographic coordinates

In C#:

var geoRegion = new Rectangle(-180, -75, 360, 150);
this.GeoMap.WindowRect = this.GeoMap.GetZoomFromGeographic(geoRegion);

In Visual Basic:

Dim geoRegion = New Rectangle(-180, -75, 360, 150)
Me.GeoMap.WindowRect = Me.GeoMap.GetZoomFromGeographic(geoRegion)

Bind and limit navigation of the map content to geographic region

In C#:

this.GeoMap.WorldRect = new Rectangle(-30, -40, 120, 80);

In Visual Basic:

Me.GeoMap.WorldRect = New Rectangle(-30, -40, 120, 80)

Pan the map content in left (west direction) by factor of 0.05

In C#:

this.GeoMap.WindowPositionHorizontal = this.GeoMap.WindowRect.X - 0.05;

In Visual Basic:

Me.GeoMap.WindowPositionHorizontal = Me.GeoMap.WindowRect.X - 0.05

Pan the map content in right (east direction) by factor of 0.05

In C#:

this.GeoMap.WindowPositionHorizontal = this.GeoMap.WindowRect.X + 0.05;

In Visual Basic:

Me.GeoMap.WindowPositionHorizontal = Me.GeoMap.WindowRect.X + 0.05

Pan the map content in up (north direction) by factor of 0.05

In C#:

this.GeoMap.WindowPositionVertical = this.GeoMap.WindowRect.Y - 0.05;

In Visual Basic:

Me.GeoMap.WindowPositionVertical = Me.GeoMap.WindowRect.Y - 0.05

Pan the map content in down (south direction) by factor of 0.05

In C#:

this.GeoMap.WindowPositionVertical = this.GeoMap.WindowRect.Y + 0.05;

In Visual Basic:

Me.GeoMap.WindowPositionVertical = Me.GeoMap.WindowRect.Y + 0.05

Related Content

The following topics provide additional information related to this topic.

Topic Purpose

This topic provides information about layout of map elements in the UltraGeographicMap control.

This topic provides conceptual information about navigating map content in the UltraGeographicMap control as well as all supported navigation features of the control.

This topic provides information about navigating the map content in the UltraGeographicMap control using inputs from a keyboard.

This topic provides information about navigating the map content in the UltraGeographicMap control using inputs from a mouse.