UserGuide

Mobile Map Viewer

From Xojo Documentation

The Map Viewer control provides a way for you to display a map in roadmap, satellite or hybrid mode. You can add locations and query the map for locations as well. You can also show the device's present location on the map.

Use the Debug ↠ Location menu in the iOS Simulator to provide locations for testing.

Frequently tracking the device's location on the map can cause significant battery drain, so only be sure to set Enabled = False when it is not needed.

Below is a list of commonly used events, properties and methods. Refer to MobileMapViewer in the Language Reference for the complete list.

Events

UserLocationChanged - If you are tracking the device location, this will be called when that location changes.

LocationSelected - Called when the user taps on a location you've added to the map.

Properties

TrackMode - Specifies whether or not you are tracking the device's current location on the map.

Methods

AddLocation - Adds a MapLocation to the map.

GoToLocation - Centers the map on the location specified.

LocationsFromQuery - Returns an array of locations on an area near the center point of the map that match the query specified.

Usage

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)


See Also

MapLocation class