Map
Definition
A two-dimensional container that renders map tiles in the background and allows for multiple Marker
elements to identify points on the map. Map tiles are supplied by OpenStreetMap contributors and the the United States Geological Survey.
The Map
component provides three utilities for manipulating its boundaries with App Inventor. First, a locking mechanism is provided to allow the map to be moved relative to other components on the Screen. Second, when unlocked, the user can pan the Map
to any location. At this new location, the “Set Initial Boundary” button can be pressed to save the current Map
coordinates to its properties. Lastly, if the Map
is moved to a different location, for example to add Marker
s off-screen, then the “Reset Map to Initial Bounds” button can be used to re-center the Map
at the starting location.
Properties
- BoundingBox
- Sets or gets the current boundary for the map’s drawn view. The value is a list of lists containing the northwest and southeast coordinates of the current view in the form
((North West) (South East))
. - CenterFromString
- Set the initial center coordinate of the map. The value is specified as a comma-separated pair of decimal latitude and longitude coordinates, for example,
42.359144, -71.093612
.In blocks code, it is recommended for performance reasons to usePanTo
with numerical latitude and longitude rather than convert to the string representation for use with this property. - EnablePan
- Enables or disables the ability of the user to move the Map.
- EnableRotation
- Enables or disables the two-finger rotation gesture to rotate the Map.
- EnableZoom
- Enables or disables the two-finger pinch gesture to zoom the Map.
- Features
- Gets the list of features attached to the
Map
(without regard to the value of the feature’sVisible
property). This list also includes any features created on theMap
by calls toFeatureFromDescription
. - Height
- Specifies the
Map
’s vertical height, measured in pixels. - HeightPercent
- Specifies the
Map
’s vertical height as a percentage of theScreen
’sHeight
. - Latitude
- Gets the latitude of the center of the Map. To change the latitude, use the
PanTo
method. - LocationSensor
- Uses the provided
LocationSensor
for user location data rather than the built-in location provider. - Longitude
- Gets the longitude of the center of the Map. To change the longitude, use the
PanTo
method. - MapType
- Sets or gets the tile layer used to draw the Map background. Defaults to Roads. Valid values are:
- Roads
- Aerial
- Terrain
Note: Road layers are provided by OpenStreetMap and aerial and terrain layers are provided by the U.S. Geological Survey.
- Rotation
- Specifies the rotation of the map in decimal degrees, if any.
- ScaleUnits
- Specifies the units used for the scale overlay. 1 (the default) will give metric units (km, m) whereas 2 will give imperial units (mi, ft).
- ShowCompass
- Specifies whether to a compass overlay on the Map. The compass will be rotated based on the device’s orientation if a digital compass is present in hardware.
- ShowScale
- Shows a scale reference on the map.
- ShowUser
- Shows or hides an icon indicating the user’s current location on the
Map
. The availability and accuracy of this feature will depend on whether the user has location services enabled and which location providers are available. - ShowZoom
- Specifies whether to show zoom controls or not.
- UserLatitude
- Returns the user’s latitude if ShowUser is enabled.
- UserLongitude
- Returns the user’s longitude if ShowUser is enabled.
- Visible
- Specifies whether the
Map
should be visible on the screen. Value istrue
if theMap
is showing andfalse
if hidden. - Width
- Specifies the horizontal width of the
Map
, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
Map
as a percentage of theScreen
’sWidth
. - ZoomLevel
- Specifies the zoom level of the map. Valid values of ZoomLevel are dependent on the tile provider and the latitude and longitude of the map. For example, zoom levels are more constrained over oceans than dense city centers to conserve space for storing tiles, so valid values may be 1-7 over ocean and 1-20 over cities. Tile providers may send warning or error tiles if the zoom level is too great for the server to support.