Class
MobileMapViewer
Description
A control for viewing maps loaded via a map provider like Google.
Properties
Name |
Type |
Read-Only |
Shared |
---|---|---|---|
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
✓ |
|||
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
constraint As iOSLayoutConstraint |
|||
child As MobileUIControl |
|||
locations() As MapLocation |
|||
index As Integer |
|||
location As MapLocation |
|||
query As String |
|||
constraint As iOSLayoutConstraint |
|||
child As MobileUIControl |
|||
locations() As MapLocation |
|||
Events
Name |
Parameters |
Returns |
---|---|---|
location As MapLocation |
||
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.
MobileMapViewer.Enabled
Enabled As Boolean
Indicates whether the control is enabled or disabled.
Disable the button:
Button1.Enabled = False
MobileMapViewer.Height
Height As Double
The height of the control.
This property is read-only.
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 Double
The left position of the control.
This property is read-only.
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.
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.
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 Double
The top position of the control.
This property is read-only.
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 Double
The width of the control.
This property is read-only.
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.
MobileMapViewer.AddControl
AddControl(child As MobileUIControl)
Adds a child control to the control.
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.
mobilemapviewer.Controls
Controls As Iterable
Allows you to iterate through all the controls that have been added to this control.
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 a handle to the underlying native OS control.
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.
MobileMapViewer.RemoveControl
RemoveControl(child As MobileUIControl)
Removes the control from the control.
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.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
Mobile projects on all supported mobile operating systems.
See also
MobileUIControl parent class; MapLocation and MobileLocation classes.