Map

Category Requires Version
Maps API 19, Android 4.4 - 4.4.4 KitKat 5

Overview

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 United States Geological Survey.

The Map component provides three utilities for manipulating its boundaries within 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 Markers off-screen, then the "Reset Map to Initial Bounds" button can be used to re-center the Map at the starting location.

Permissions

Events

Bounds Change

User has changed the map bounds by panning or zooming the map.

Double Tap At Point

The user double-tapped at a point on the map. This event will be followed by a ZoomChanged event if zooming gestures are enabled and the map is not at the highest possible zoom level.

Params
latitude Number
longitude Number

Feature Click

The user clicked on a map feature.

Params
feature Component

Feature Drag

The user dragged a map feature.

Params
feature Component

Feature Long Click

The user long-pressed on a map feature.

Params
feature Component

Feature Start Drag

The user started dragging a map feature.

Params
feature Component

Feature Stop Drag

The user stopped dragging a map feature.

Params
feature Component

Got Features

A GeoJSON document was successfully read from url. The features specified in the document are provided as a list in features.

Params
url Text
features List

Invalid Point

An invalid coordinate was supplied during a maps operation. The message parameter will have more details about the issue.

Params
message Text

Load Error

An error was encountered while processing a GeoJSON document at the given url. The responseCode parameter will contain an HTTP status code and the errorMessage parameter will contain a detailed error message.

Params
url Text
response Code Number
error Message Text

Long Press At Point

The user long-pressed at a point on the map.

Params
latitude Number
longitude Number

Map Ready

Map has been initialized and is ready for user interaction.

Tap At Point

The user tapped at a point on the map.

Params
latitude Number
longitude Number

Zoom Change

User has changed the zoom level of the map.

Methods

Create Marker

Returns: Component

Create a new marker with default properties at the specified latitude and longitude.

Params
latitude Number
longitude Number

Feature From Description

Returns: Any

Convert a feature description into an App Inventor map feature. Currently the onlysupported conversion is from a GeoJSON point to Marker component. If the feature hasproperties, they will be mapped into App Inventor properties using the following mapping:description becomes Description;draggable becomes Draggable;infobox becomes EnableInfobox;fill becomes FillColor;fill-opacity becomes FillOpacity;image becomes ImageAsset;stroke becomes StrokeColor;stroke-opacity becomes StrokeOpacity;stroke-width becomes StrokeWidth;title becomes Title;visible becomes Visible

Params
description List

Load From URL

Load a feature collection in GeoJSON format from the given url. On success, the event GotFeatures will be raised with the given url and a list of the features parsed from the GeoJSON as a list of (key, value) pairs. On failure, the LoadError event will be raised with any applicable HTTP response code and error message.

Params
url Text

Pan To

Pan the map center to the given latitude and longitude and adjust the zoom level to the specified zoom.

Params
latitude Number
longitude Number
zoom Number

Save

Save the contents of the Map to the specified path.

Params
path Text

Properties

Bounding Box

List ➖ Read Write - Blocks

Bounding box for the map stored as [[North, West], [South, East]].

Center From String

Text Default: 42.359144, -71.093612 ➖ Write - Designer Blocks

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 use SetCenter with numerical latitude and longitude rather than convert to the string representation for use with this property.

Enable Pan

Boolean Default: True ➖ Read Write - Designer Blocks

Enable two-finger panning of the Map

Enable Rotation

Boolean Default: False ➖ Read Write - Designer Blocks

Enable rotating the map based on the user's orientation.

Enable Zoom

Boolean Default: True ➖ Read Write - Designer Blocks

Set whether the user can zoom the map using touch gestures. This value does not affectwhether the user can zoom using the zoom controls from

Features

List ➖ Read Write - Blocks

The list of features placed on this map. This list also includes any features created by calls to FeatureFromDescription

Height

Number ➖ Read Write - Blocks

Specifies the component's vertical height, measured in pixels.

Height Percent

Number ➖ Write - Blocks

Specifies the component's vertical height as a percentageof the height of its parent Component.

Latitude

Number ➖ Read - Blocks

The latitude of the center of the map.

Location Sensor

Component ➖ Write - Designer Blocks

Uses the provided LocationSensor for user location data rather than the built-in location provider.

Longitude

Number ➖ Read - Blocks

The longitude of the center of the map.

Map Type

Number Default: 1 ➖ Read Write - Designer Blocks

Set the type of map tile used for the base tile layer. Valid values are:

  1. Roads
  2. Aerial
  3. Terrain

Rotation

Number Default: 0.0 ➖ Read Write - Designer Blocks

Sets or gets the rotation of the map in decimal degrees if any

Scale Units

Number Default: 1 ➖ Read Write - Designer Blocks

Show Compass

Boolean Default: False ➖ Read Write - Designer Blocks

Show a compass on the map. If the device provides a digital compass, orientation changes willbe used to rotate the compass icon.

Show Scale

Boolean Default: False ➖ Read Write - Designer Blocks

Shows a scale reference on the map.

Show User

Boolean Default: False ➖ Read Write - Designer Blocks

Show the user's location on the map.

Show Zoom

Boolean Default: False ➖ Read Write - Designer Blocks

Show the zoom controls on the map.

User Latitude

Number ➖ Read - Blocks

Returns the user's latitude if ShowUser is enabled.

User Longitude

Number ➖ Read - Blocks

Returns the user's longitude if ShowUser is enabled.

Visible

Boolean Default: True ➖ Read Write - Designer Blocks

Returns true iff the component is visible.

Width

Number ➖ Read Write - Blocks

Specifies the component's horizontal width, measured in pixels.

Width Percent

Number ➖ Write - Blocks

Specifies the component's horizontal width as a percentageof the Width of its parent Component.

Zoom Level

Number Default: 13 ➖ Read Write - Designer Blocks

Set the zoom level of the map.

Valid values of ZoomLevel are dependent on the tile provider and the latitude andlongitude of the map. For example, zoom levels are more constrained over oceans than densecity centers to conserve space for storing tiles, so valid values may be 1-7 over ocean and1-18 over cities. Tile providers may send warning or error tiles if the zoom level is toogreat for the server to support.


Last update: January 27, 2020