Class

MobileMapViewer


Description

A control for viewing maps loaded via a map provider like Google.

Events

Name

Parameters

Returns

Closing

LocationSelected

location As MapLocation

Opening

Pressed

latitude As Double, longitude As Double

UserLocationChanged

latitude As Double, longitude As Double

Enumerations

MobileMapViewer.MapTypes

MapTypes

The various ways in which the map to be displayed.

Enum

Description

RoadMap

A graphical version emphasizing roads.

Satellite

Photographic images taken from satellites.

Hybrid

The RoadMap and Satellite types combined.

MobileMapViewer.TrackModes

TrackModes

The ways in which the map can track devices.

Enum

Description

None

The map does no tracking.

User

The map shows the user's current location.

Property descriptions


MobileMapViewer.AccessibilityHint

AccessibilityHint As String

The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.

Me.AccessibilityHint = "Click to calculate the value and display the next screen."

MobileMapViewer.AccessibilityLabel

AccessibilityLabel As String

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

Me.AccessibilityLabel = "Calculate the value."

MobileMapViewer.ControlCount

ControlCount As Integer

The number of child controls in the control.

This property is read-only.

Important

This property is supported for iOS only.


MobileMapViewer.Enabled

Enabled As Boolean

Indicates whether the control is enabled or disabled.

Disable the button:

Button1.Enabled = False

MobileMapViewer.Height

Height As Integer

The height of the control.

This property is read-only on iOS.


MobileMapViewer.Latitude

Latitude As Double

The angular distance of the center of the map north or south of the equator.

This property is read-only.


MobileMapViewer.Left

Left As Integer

The left position of the control.

This property is read-only on iOS.


MobileMapViewer.LockBottom

LockBottom As Boolean

Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning screen.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockBottom = True

MobileMapViewer.LockLeft

LockLeft As Boolean

Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning screen.

LockLeft and Locktop default to True when you add a new control to a screen. Existing controls will be altered only if LockRight and/or LockBottom are not set. LockLeft has no effect unless LockRight is True.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockLeft = True

MobileMapViewer.LockRight

LockRight As Boolean

Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning screen.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockRight = True

MobileMapViewer.LockTop

LockTop As Boolean

Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning screen.

LockTop and LockLeft default to True when you add a control to a screen. Existing controls will be altered only if LockRight and/or LockBottom are not set. LockTop has no effect unless LockBottom is True.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockTop = True

MobileMapViewer.Longitude

Longitude As Double

The angular distance of the center of the map east or west of the meridian at Greenwich, England.

This property is read-only.


MobileMapViewer.MapType

MapType As MapTypes

The type of map being displayed.

The map can be displayed as a Road, Satellite or Hybrid type.

Set MapViewer1 to Hybrid:

MapViewer1.MapType = MobileMapViewer.MapTypes.Hybrid

MobileMapViewer.Name

Name As String

The name of the control.

This property is read-only.


MobileMapViewer.Parent

Parent As MobileUIControl

The parent (sometimes called a "Super") class of the control.

This property is read-only.


MobileMapViewer.TintColor

TintColor As ColorGroup

Changes a control's tint color.

Important

This is supported for iOS only.

On iOS, the following controls support TintColor:

Enum

Description

ProgressBar

The area indicating the value of the control will be drawn in the TintColor.

Slider

The area indicating the value of the control will be drawn in the TintColor.

TextArea

The cursor and text highlight color will be drawn in the TintColor.

TextField

The cursor and text highlight color will be drawn in the TintColor.


MobileMapViewer.Top

Top As Integer

The top position of the control.

This property is read-only on iOS.


MobileMapViewer.TrackMode

TrackMode As TrackModes

Determines if the user's location is tracked on the map.

Set MapViewer1 to track the user on the map:

MapViewer1.TrackMode = MobileMapViewer.TrackModes.User

MobileMapViewer.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

MobileMapViewer.Width

Width As Integer

The width of the control.

This property is read-only on iOS.


MobileMapViewer.ZoomRadius

ZoomRadius As Double

The radius (in kilometers) displayed on the map.

Set the zoom radius on MapViewer1 to 100 kilometers:

MapViewer1.ZoomRadius = 1000

Method descriptions


MobileMapViewer.AddConstraint

AddConstraint(constraint As iOSLayoutConstraint)

Adds a constraint to the control.

This constraint is used by child controls that have been added to this control.

Important

This is supported for iOS only.


MobileMapViewer.AddControl

AddControl(child As MobileUIControl)

Adds a child control to the control.

Important

This is supported for iOS only.


MobileMapViewer.AddLocation

AddLocation(locations() As MapLocation)

Adds to the map the MapLocations passed.

Map locations appear as pins on the map.

The map will automatically set the ZoomRadius to fit all add locations.

If you set the MapLocation.Icon of the MapLocation before adding it, the Picture you set as as icon will be drawn at the location rather than the default pin.

Add the Grand Canyon and the White House locations to MapViewer1:

Var locations() As MapLocation
locations.Add(New MapLocation(36.056595, -112.125092)) ' Grand Canyon
locations.Add(New MapLocation(38.897957, -77.036560)) ' White House
MapViewer1.AddLocation(locations)

MobileMapViewer.ClearFocus

ClearFocus

Removes the focus from the control.

TextField1.ClearFocus

MobileMapViewer.ControlAt

ControlAt(index As Integer) As MobileUIControl

Gets the child control at the specified index.

Important

This is supported for iOS only.


mobilemapviewer.Controls

Controls As Iterable

Allows you to iterate through all the controls that have been added to this control.

Important

This is supported for iOS only.


MobileMapViewer.GoToLocation

GoToLocation(location As MapLocation)

Centers the map on the provided location.

If either the latitude or longitude are invalid, an InvalidArgumentException will occur.

Show Hobbiton on MapViewer1:

MapViewer1.GotoLocation(-37.871826, 175.681283)

MobileMapViewer.Handle

Handle As Ptr

The handle to the underlying native OS control.

Important

This is supported for iOS only.


MobileMapViewer.LocationsFromQuery

LocationsFromQuery(query As String) As MapLocation()

Returns an array of MapLocations based upon the query passed.

Find all the McDonalds locations near the center of the map currently being displayed and add them to it:

Var locationsFound() As MapLocation
locationsFound = MapViewer1.LocationsFromQuery("McDonalds")
MapViewer1.AddLocation(locationsFound)

MobileMapViewer.Refresh

Refresh

Marks the control so that it will be redrawn during the next event loop.

Call Refresh to force a Canvas to redraw itself:

Canvas1.Refresh

MobileMapViewer.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.

Important

This is supported for iOS only.


MobileMapViewer.RemoveControl

RemoveControl(child As MobileUIControl)

Removes the control from the control.

Important

This is supported for iOS only.


MobileMapViewer.RemoveLocation

RemoveLocation(locations() As MapLocation)

Removes from the map the MapLocations passed.

Specifically, the pins that represent the locations are removed.

Remove the location stored in MyHouse from MapViewer1:

MapViewer1.RemoveLocation(MyHouse)

MobileMapViewer.SetFocus

SetFocus

Sets the focus to the control.

TextField1.SetFocus

Event descriptions


MobileMapViewer.Closing

Closing

Called when the control's layout is closing.


MobileMapViewer.LocationSelected

LocationSelected(location As MapLocation)

The user has tapped on a location (displayed as a pin) that was added with the AddLocation method.


MobileMapViewer.Opening

Opening

Called when the control's layout is opening.

This is where you typically put initialization code.

This example in the Opening event of a label sets its text to "Hello":

Me.Text = "Hello"

MobileMapViewer.Pressed

Pressed(latitude As Double, longitude As Double)

The user has long pressed/tapped on the map at the location specified by the latitude and longitude passed.


MobileMapViewer.UserLocationChanged

UserLocationChanged(latitude As Double, longitude As Double)

The location of the user has changed.

The GPS in most smartphones is very sensitive and as a result, moving the device just very slightly will result in this event being called.

Notes

With the MobileMapViewer, you can go to a specific location, add pins that represent locations, remove those locations and LocationsFromQuery for locations by name, address, type, etc.

Sample code

Show Hobbiton on MapViewer1:

MapViewer1.GotoLocation(-37.871826, 175.681283)

Add the Grand Canyon and the White House locations to MapViewer1:

Var locations() As MapLocation
locations.Add(New MapLocation(36.056595, -112.125092)) 'Grand Canyon
locations.Add(New MapLocation(38.897957, -77.036560)) 'White House
MapViewer1.AddLocation(locations)

Find all the McDonalds locations near the center of the map currently being displayed and add them to it:

Var locationsFound() As MapLocation
locationsFound = MapViewer1.LocationsFromQuery("McDonalds")
MapViewer1.AddLocation(locationsFound)

Compatibility

iOS projects on all supported mobile operating systems.

See also

MobileUIControl parent class; MapLocation and MobileLocation classes.