Maps
Table of Contents:
Circle
The Circle
component visualizes a circle of a given Radius
, in meters,
centered at a Latitude
and Longitude
. The Circle
’s appearance
cnn be customized using properties such as FillColor
, StrokeColor
,
and StrokeWidth
.
The Circle
component can also be used to implement features such as geofencing, a mechanism
where the user’s presence within an area is used to trigger other behaviors. Using the
DistanceToPoint
method combined with the
LocationSensor
, you can determine whether a user’s location is
inside or outside of the Circle
. You can use this feature to trigger additional actions.
Properties
- Description
- Sets or gets the description displayed in the info window. The info window appears when the
user taps on the
Circle
. - Draggable
- Sets or gets whether or not the user can drag a map feature. This feature is accessed by
long-pressing and then dragging the
Circle
to a new location. - EnableInfobox
- Enables or disables the infobox window display when the user taps the
Circle
. - FillColor
- Sets or gets the color used to fill in the
Circle
. - FillOpacity
- Sets or gets the opacity of the color used to fill the
Circle
. A value of 0.0 will be completely invisible and a value of 1.0 will be completely opaque. - Latitude
- Sets or gets the latitude of the center of the circle, in degrees. Positive values represent
north of the equator and negative values represent south of the equator. To update the
latitude and longitude simultaneously, use the
SetLocation
method. - Longitude
- Sets or gets the longitude of the center of the circle, in degrees. Positive values represent
east of the prime meridian and negative values represent west of the prime meridian. To update
the latitude and longitude simultaneously, use the
SetLocation
method. - Radius
- Sets or gets the radius of the circle, in meters.
- StrokeColor
- Sets or gets the color used to outline the
Circle
. - StrokeOpacity
- Sets or gets the opacity of the outline of the
Circle
. A value of 0.0 will be invisible and a value of 1.0 will be opaque. - StrokeWidth
- Sets or gets the width of the stroke used to outline the
Circle
. - Title
- Sets or gets the title displayed in the info window that appears when the user clicks on the map feature.
- Type
- Returns the type of the feature. For Circles, this returns MapFeature.Circle (“Circle”).
- Visible
- Specifies whether the
Circle
should be visible on the screen. Value istrue
if theCircle
is showing andfalse
if hidden.
Events
- Click()
- The
Click
event runs when the user taps on theCircle
. - Drag()
- The
Drag
event runs in response to position updates of theCircle
as the user drags it. - LongClick()
- The
LongClick
event runs when the user presses and holds theCircle
and then releases it. This event will only trigger ifDraggable
isfalse
because it uses the same gesture asStartDrag
. - StartDrag()
- The
StartDrag
event runs when the user presses and holds theCircle
and then proceeds to move their finger on the screen. It will be followed by theDrag
andStopDrag
events. - StopDrag()
- The
StopDrag
event runs when the user releases theCircle
at the end of a drag.
Methods
- DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Circle
and the givenmapFeature
. Ifcentroids
istrue
, the computation is done between the centroids of the two features. Otherwise, the distance will be computed between the two features based on the closest points. Further, whencentroids
isfalse
, this method will return 0 if theCircle
intersects or contains themapFeature
. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
Circle
and the givenlatitude
andlongitude
. Ifcentroids
istrue
, the distance is computed from the center of theCircle
to the given point. Otherwise, the distance is computed from the closest point on theCircle
to the given point. Further, this method will return 0 ifcentroids
isfalse
and the point is in theCircle
. If an error occurs, -1 will be returned. - HideInfobox()
- Hides the
Circle
’s info box if it is visible. Otherwise, no action is taken. - SetLocation(latitude,longitude)
- Moves the center of the
Circle
to the givenlatitude
andlongitude
. This method is more efficient than settingLatitude
andLongitude
separately. - ShowInfobox()
- Shows the info box for the
Circle
if it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfobox
is false.
FeatureCollection
A FeatureCollection
groups one or more map features together. Any events that occur on a
feature in the collection will also trigger the corresponding event in the collection component.
FeatureCollection
s can be loaded from external resources to populate Map
s with content.
GeoJSON is the only format supported at this time.
Properties
- Features
- Gets the list of features attached to the
FeatureCollection
(without regard to the value of the feature’sVisible
property). This list also includes any features created on theFeatureCollection
by calls toFeatureFromDescription
. - FeaturesFromGeoJSON
- Populates the feature collection from a string containing GeoJSON content. Given the size of
such strings, it is recommended to load the feature collection from assets or the web using
the
Source
property. - Height
- Specifies the
FeatureCollection
’s vertical height, measured in pixels. - HeightPercent
- Specifies the
FeatureCollection
’s vertical height as a percentage of theScreen
’sHeight
. - Source
- Specifies the source URL used to populate the feature collection. If the feature collection was not loaded from a URL, this will be the empty string.
- Visible
- Specifies whether the
FeatureCollection
should be visible on the screen. Value istrue
if theFeatureCollection
is showing andfalse
if hidden. - Width
- Specifies the horizontal width of the
FeatureCollection
, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
FeatureCollection
as a percentage of theScreen
’sWidth
.
Events
- FeatureClick(feature)
- When a feature is clicked, the parent
FeatureCollection
will also receive aFeatureClick
event. Thefeature
parameter indicates which child feature was clicked. This event is run after theClick
event on the corresponding feature and after thewhen any ... Click
event if one is provided. - FeatureDrag(feature)
- When the user drags a feature, the parent
FeatureCollection
will also receive aFeatureDrag
event. Thefeature
parameter indicates which child feature was dragged. This event is run after theDrag
event on the corresponding feature and after thewhen any ... Drag
event if one is provided. - FeatureLongClick(feature)
- When a feature is long-clicked, the parent
FeatureCollection
will also receive aFeatureLongClick
event. Thefeature
parameter indicates which child feature was long-clicked. This event is run after theLongClick
event on the corresponding feature and after thewhen any ... LongClick
event if one is provided. - FeatureStartDrag(feature)
- When the user starts dragging a feature, the parent
FeatureCollection
will also receive aFeatureStartDrag
event. Thefeature
parameter indicates which child feature was dragged. This event is run after theStartDrag
event on the corresponding feature and after thewhen any ... StartDrag
event if one is provided. - FeatureStopDrag(feature)
- When the user stops dragging a feature, the parent
FeatureCollection
will also receive aFeatureStopDrag
event. Thefeature
parameter indicates which child feature was dragged. This event is run after theStopDrag
event on the corresponding feature and after thewhen any ... StopDrag
event if one is provided. - GotFeatures(url,features)
- The
GotFeatures
event is run when when a feature collection is successfully read from the givenurl
. Thefeatures
parameter will be a list of feature descriptions that can be converted into components using theFeatureFromDescription
method. - LoadError(url,responseCode,errorMessage)
- The
LoadError
event is run when an error occurs while processing a feature collection document at the givenurl
. TheresponseCode
parameter will contain an HTTP status code and theerrorMessage
parameter will contain a detailed error message.
Methods
- FeatureFromDescription(description)
- Converts a feature description into an App Inventor map feature. Points are converted into
Marker
components, LineStrings are converted intoLineString
components, and Polygons (and MultiPolygons) are converted intoPolygon
components. If the feature has properties, 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
- description becomes
- LoadFromURL(url)
- Loads a feature collection in GeoJSON format from the given
url
. On success, the eventGotFeatures
will be raised with the givenurl
and a list offeature
s parsed from the GeoJSON as a list of (key, value) pairs. On failure, theLoadError
event will be raised with any applicable HTTP response code and error message.
LineString
LineString
is a component for drawing an open, continuous sequence of lines on a Map
. To add
new points to a LineString
in the designer, drag the midpoint of any segment away from the
line to introduce a new vertex. Move a vertex by clicking and dragging the vertex to a new
location. Clicking on a vertex will delete the vertex, unless only two remain.
Properties
- Description
- Sets or gets the description displayed in the info window. The info window appears when the
user taps on the
LineString
. - Draggable
- Sets or gets whether or not the user can drag a map feature. This feature is accessed by
long-pressing and then dragging the
LineString
to a new location. - EnableInfobox
- Enables or disables the infobox window display when the user taps the
LineString
. - Points
- The list of points, as pairs of latitudes and longitudes, in the
LineString
. - PointsFromString
- Set the points of the LineString from a specially-coded character string of the form: [[latitude1, longitude1], [latitude2, longitude2], …]
- StrokeColor
- Sets or gets the color used to outline the
LineString
. - StrokeOpacity
- Sets or gets the opacity of the outline of the
LineString
. A value of 0.0 will be invisible and a value of 1.0 will be opaque. - StrokeWidth
- Sets or gets the width of the stroke used to outline the
LineString
. - Title
- Sets or gets the title displayed in the info window that appears when the user clicks on the map feature.
- Type
- Returns the type of the map feature. For LineString, this returns MapFeature.LineString (“LineString”).
- Visible
- Specifies whether the
LineString
should be visible on the screen. Value istrue
if theLineString
is showing andfalse
if hidden.
Events
- Click()
- The
Click
event runs when the user taps on theLineString
. - Drag()
- The
Drag
event runs in response to position updates of theLineString
as the user drags it. - LongClick()
- The
LongClick
event runs when the user presses and holds theLineString
and then releases it. This event will only trigger ifDraggable
isfalse
because it uses the same gesture asStartDrag
. - StartDrag()
- The
StartDrag
event runs when the user presses and holds theLineString
and then proceeds to move their finger on the screen. It will be followed by theDrag
andStopDrag
events. - StopDrag()
- The
StopDrag
event runs when the user releases theLineString
at the end of a drag.
Methods
- DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
LineString
and the givenmapFeature
. Ifcentroids
istrue
, the computation is done between the centroids of the two features. Otherwise, the distance will be computed between the two features based on the closest points. Further, whencentroids
isfalse
, this method will return 0 if theLineString
intersects or contains themapFeature
. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
LineString
and the givenlatitude
andlongitude
. Ifcentroids
istrue
, the distance is computed from the center of theLineString
to the given point. Otherwise, the distance is computed from the closest point on theLineString
to the given point. Further, this method will return 0 ifcentroids
isfalse
and the point is in theLineString
. If an error occurs, -1 will be returned. - HideInfobox()
- Hides the
LineString
’s info box if it is visible. Otherwise, no action is taken. - ShowInfobox()
- Shows the info box for the
LineString
if it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfobox
is false.
Map
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 use
PanTo
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.
Events
- BoundsChange()
- The
BoundsChange
event runs when the user changes the map bounds, either by zooming, panning, or rotating the view. - DoubleTapAtPoint(latitude,longitude)
- The
DoubleTapAtPoint
runs when the user double taps at a point on the map. The tapped location will be reported in map coordinates via thelatitude
andlongitude
parameters. - FeatureClick(feature)
- When a feature is clicked, the parent
Map
will also receive aFeatureClick
event. Thefeature
parameter indicates which child feature was clicked. This event is run after theClick
event on the corresponding feature and after thewhen any ... Click
event if one is provided. - FeatureDrag(feature)
- When the user drags a feature, the parent
Map
will also receive aFeatureDrag
event. Thefeature
parameter indicates which child feature was dragged. This event is run after theDrag
event on the corresponding feature and after thewhen any ... Drag
event if one is provided. - FeatureLongClick(feature)
- When a feature is long-clicked, the parent
Map
will also receive aFeatureLongClick
event. Thefeature
parameter indicates which child feature was long-clicked. This event is run after theLongClick
event on the corresponding feature and after thewhen any ... LongClick
event if one is provided. - FeatureStartDrag(feature)
- When the user starts dragging a feature, the parent
Map
will also receive aFeatureStartDrag
event. Thefeature
parameter indicates which child feature was dragged. This event is run after theStartDrag
event on the corresponding feature and after thewhen any ... StartDrag
event if one is provided. - FeatureStopDrag(feature)
- When the user stops dragging a feature, the parent
Map
will also receive aFeatureStopDrag
event. Thefeature
parameter indicates which child feature was dragged. This event is run after theStopDrag
event on the corresponding feature and after thewhen any ... StopDrag
event if one is provided. - GotFeatures(url,features)
- The
GotFeatures
event is run when a feature collection is successfully read from the givenurl
. Thefeatures
parameter will be a list of feature descriptions that can be converted into components using theFeatureFromDescription
method. - InvalidPoint(message)
- The
InvalidPoint
event runs when the program encounters an invalid point while processing geographical data. Points are considered invalid when the latitude or longitude for the point is outside the acceptable range ([-90, 90]
and[-180, 180]
, respectively). Themessage
parameter will contain an explanation for the error. - LoadError(url,responseCode,errorMessage)
- The
LoadError
event is run when an error occurs while processing a feature collection document at the givenurl
. TheresponseCode
parameter will contain an HTTP status code and theerrorMessage
parameter will contain a detailed error message. - LongPressAtPoint(latitude,longitude)
- The
LongPressAtPoint
runs when the user long-presses at a point on the map without moving their finger (which would trigger a drag). The location of the long-press will be reported in map coordinates via thelatitude
andlongitude
parameters. - Ready()
- The
Ready
event runs once theMap
has been initialized and is ready for user interaction. - TapAtPoint(latitude,longitude)
- The
TapAtPoint
runs when the user taps at a point on the map. The tapped location will be reported in map coordinates via thelatitude
andlongitude
parameters. - ZoomChange()
- The
ZoomChange
event runs when the user has changed the zoom level of the map, such as by pinching or double-tapping to zoom.
Methods
- CreateMarker(latitude,longitude)
- Creates a new
Marker
on theMap
at the specifiedlatitude
andlongitude
. - FeatureFromDescription(description)
- Converts a feature description into an App Inventor map feature. Points are converted into
Marker
components, LineStrings are converted intoLineString
components, and Polygons (and MultiPolygons) are converted intoPolygon
components. If the feature has properties, 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
- description becomes
- LoadFromURL(url)
- Loads a feature collection in GeoJSON format from the given
url
. On success, the eventGotFeatures
will be raised with the givenurl
and a list offeature
s parsed from the GeoJSON as a list of (key, value) pairs. On failure, theLoadError
event will be raised with any applicable HTTP response code and error message. - PanTo(latitude,longitude,zoom)
- Pans the map center to the given latitude and longitude and adjust the zoom level to the specified zoom.
- Save(path)
- Saves the features on the
Map
as a GeoJSON file at the specified path.
Marker
The Marker
component indicates points on a Map
, such as buildings or other points of
interest. Marker
s can be customized in many ways, such as using custom images from the app’s
assets or by changing the Marker
FillColor
. Marker
s can also be created
dynamically by calling the Map
’s CreateMarker
method and configured using
the “Any Component” blocks.
Properties
- AnchorHorizontal
- Sets or gets the horizontal offset of the
Marker
center relative to its image. Valid values are:1
(Left),2
(Right), or3
(Center). - AnchorVertical
- Sets or gets the vertical offset of the
Marker
center relative to its image. Valid values are:1
(Top),2
(Center), or3
(Bottom). - Description
- Sets or gets the description displayed in the info window. The info window appears when the
user taps on the
Marker
. - Draggable
- Sets or gets whether or not the user can drag a map feature. This feature is accessed by
long-pressing and then dragging the
Marker
to a new location. - EnableInfobox
- Enables or disables the infobox window display when the user taps the
Marker
. - FillColor
- Sets or gets the color used to fill in the
Marker
. - FillOpacity
- Sets or gets the opacity of the color used to fill the
Marker
. A value of 0.0 will be completely invisible and a value of 1.0 will be completely opaque. - Height
- Specifies the
Marker
’s vertical height, measured in pixels. - HeightPercent
- Specifies the
Marker
’s vertical height as a percentage of theScreen
’sHeight
. - ImageAsset
- Specifies the image shown for the
Marker
. If set to the empty string “”, then the default marker icon will be used. - Latitude
- Sets or gets the latitude of the
Marker
, in degrees, with positive values representing north of the equator and negative values representing south of the equator. To update theLatitude
andLongitude
simultaneously, use theSetLocation
method. - Longitude
- Sets or gets the longitude of the
Marker
, in degrees, with positive values representing east of the prime meridian and negative values representing west of the prime meridian. To update theLatitude
andLongitude
simultaneously, use theSetLocation
method. - StrokeColor
- Sets or gets the color used to outline the
Marker
. - StrokeOpacity
- Sets or gets the opacity of the outline of the
Marker
. A value of 0.0 will be invisible and a value of 1.0 will be opaque. - StrokeWidth
- Sets or gets the width of the stroke used to outline the
Marker
. - Title
- Sets or gets the title displayed in the info window that appears when the user clicks on the map feature.
- Type
- Return the type of the map feature. For Marker, this returns the text “Marker”.
- Visible
- Specifies whether the
Marker
should be visible on the screen. Value istrue
if theMarker
is showing andfalse
if hidden. - Width
- Specifies the horizontal width of the
Marker
, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
Marker
as a percentage of theScreen
’sWidth
.
Events
- Click()
- The
Click
event runs when the user taps on theMarker
. - Drag()
- The
Drag
event runs in response to position updates of theMarker
as the user drags it. - LongClick()
- The
LongClick
event runs when the user presses and holds theMarker
and then releases it. This event will only trigger ifDraggable
isfalse
because it uses the same gesture asStartDrag
. - StartDrag()
- The
StartDrag
event runs when the user presses and holds theMarker
and then proceeds to move their finger on the screen. It will be followed by theDrag
andStopDrag
events. - StopDrag()
- The
StopDrag
event runs when the user releases theMarker
at the end of a drag.
Methods
- BearingToFeature(mapFeature,centroids)
- Returns the bearing from the
Marker
to the given map feature, in degrees from due north. If thecentroids
parameter istrue
, the bearing will be to the center of the map feature. Otherwise, the bearing will be computed to the point in the feature nearest theMarker
. - BearingToPoint(latitude,longitude)
- Returns the bearing from the
Marker
to the givenlatitude
andlongitude
, in degrees from due north. - DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Marker
and the givenmapFeature
. Ifcentroids
istrue
, the computation is done between the centroids of the two features. Otherwise, the distance will be computed between the two features based on the closest points. Further, whencentroids
isfalse
, this method will return 0 if theMarker
intersects or contains themapFeature
. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude)
- Compute the distance, in meters, between a
Marker
and alatitude
,longitude
point. - HideInfobox()
- Hides the
Marker
’s info box if it is visible. Otherwise, no action is taken. - SetLocation(latitude,longitude)
- Sets the location of the
Marker
. - ShowInfobox()
- Shows the info box for the
Marker
if it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfobox
is false.
Navigation
The Navigation component generates directions between two locations using a service called OpenRouteService. You must provide a valid API key from that service in order for this component to work.
Properties
- API Key for Open Route Service. Obtain an API key at https://openrouteservice.org.
- The latitude of the end location.
- Set the end location.
- The longitude of the end location.
- The language to use for textual directions. Default is “en” for English.
- The raw response from the server. This can be used to access more details beyond what the
GotDirections
event provides. - The latitude of the start location.
- Set the start location.
- The longitude of the start location.
- The transportation method used for determining the route. Valid options are:
foot-walking
: Route based on walking pathsdriving-car
: Route based on vehicle pathscycling-regular
: Route based on bicycle pathswheelchair
: Route based on wheelchair accessible paths
Events
- Event indicating that a request has finished and has returned data. The following parameters
are provided:
directions
: A list of text directions, such as “Turn left at Massachusetts Avenue”.points
: A list of (latitude, longitude) points that represent the path to take. This can be passed toLineString
’sPoints
to draw the line on aMap
.distance
: Estimated distance for the route, in meters.duration
: Estimated duration for the route, in seconds.
Methods
- Request directions from the routing service using the values of
StartLatitude
,StartLongitude
,EndLatitude
, andEndLongitude
. On success, theGotDirections
event block will run. If an error occurs, the error will be reported via theScreen's ErrorOccurred
event.
Polygon
Polygon
encloses an arbitrary 2-dimensional area on a Map
. Polygon
s can be used for
drawing a perimeter, such as a campus, city, or country. Polygon
s begin as basic triangles.
New vertices can be created by dragging the midpoint of a polygon away from the edge. Clicking
on a vertex will remove the vertex, but a minimum of 3 vertices must exist at all times.
Properties
- Description
- Sets or gets the description displayed in the info window. The info window appears when the
user taps on the
Polygon
. - Draggable
- Sets or gets whether or not the user can drag a map feature. This feature is accessed by
long-pressing and then dragging the
Polygon
to a new location. - EnableInfobox
- Enables or disables the infobox window display when the user taps the
Polygon
. - FillColor
- Sets or gets the color used to fill in the
Polygon
. - FillOpacity
- Sets or gets the opacity of the color used to fill the
Polygon
. A value of 0.0 will be completely invisible and a value of 1.0 will be completely opaque. - HolePoints
- Specifies the points of any holes in the
Polygon
. TheHolePoints
property is a list of lists, with each sublist containing(latitude, longitude)
points representing a hole. - HolePointsFromString
- Specifies holes in a
Polygon
from a GeoJSON string. In contrast toHolePoints
, the longitude of each point comes before the latitude as stated in the GeoJSON specification. - Points
- Specifies the Points used for drawing the
Polygon
. The Points are specified as a list of lists containing latitude and longitude values, such as[[lat1, long1], [lat2, long2], ...]
. - PointsFromString
- Specifies the points for the
Polygon
from a GeoJSON string. UnlikePoints
, this property expects that the longitude comes first in the point rather than the latitude. - StrokeColor
- Sets or gets the color used to outline the
Polygon
. - StrokeOpacity
- Sets or gets the opacity of the outline of the
Polygon
. A value of 0.0 will be invisible and a value of 1.0 will be opaque. - StrokeWidth
- Sets or gets the width of the stroke used to outline the
Polygon
. - Title
- Sets or gets the title displayed in the info window that appears when the user clicks on the map feature.
- Type
- Returns the type of the feature. For polygons, this returns MapFeature.Polygon (“Polygon”).
- Visible
- Specifies whether the
Polygon
should be visible on the screen. Value istrue
if thePolygon
is showing andfalse
if hidden.
Events
- Click()
- The
Click
event runs when the user taps on thePolygon
. - Drag()
- The
Drag
event runs in response to position updates of thePolygon
as the user drags it. - LongClick()
- The
LongClick
event runs when the user presses and holds thePolygon
and then releases it. This event will only trigger ifDraggable
isfalse
because it uses the same gesture asStartDrag
. - StartDrag()
- The
StartDrag
event runs when the user presses and holds thePolygon
and then proceeds to move their finger on the screen. It will be followed by theDrag
andStopDrag
events. - StopDrag()
- The
StopDrag
event runs when the user releases thePolygon
at the end of a drag.
Methods
- Centroid()
- Gets the centroid of the
Polygon
as a(latitude, longitude)
pair. - DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Polygon
and the givenmapFeature
. Ifcentroids
istrue
, the computation is done between the centroids of the two features. Otherwise, the distance will be computed between the two features based on the closest points. Further, whencentroids
isfalse
, this method will return 0 if thePolygon
intersects or contains themapFeature
. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
Polygon
and the givenlatitude
andlongitude
. Ifcentroids
istrue
, the distance is computed from the center of thePolygon
to the given point. Otherwise, the distance is computed from the closest point on thePolygon
to the given point. Further, this method will return 0 ifcentroids
isfalse
and the point is in thePolygon
. If an error occurs, -1 will be returned. - HideInfobox()
- Hides the
Polygon
’s info box if it is visible. Otherwise, no action is taken. - ShowInfobox()
- Shows the info box for the
Polygon
if it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfobox
is false.
Rectangle
Rectangle
s are polygons with fixed latitudes and longitudes for the north, south, east, and
west boundaries. Moving a vertex of the Rectangle
updates the appropriate edges accordingly.
Properties
- Description
- Sets or gets the description displayed in the info window. The info window appears when the
user taps on the
Rectangle
. - Draggable
- Sets or gets whether or not the user can drag a map feature. This feature is accessed by
long-pressing and then dragging the
Rectangle
to a new location. - EastLongitude
- Specifies the east-most edge of the
Rectangle
, in decimal degrees east of the prime meridian. - EnableInfobox
- Enables or disables the infobox window display when the user taps the
Rectangle
. - FillColor
- Sets or gets the color used to fill in the
Rectangle
. - FillOpacity
- Sets or gets the opacity of the color used to fill the
Rectangle
. A value of 0.0 will be completely invisible and a value of 1.0 will be completely opaque. - NorthLatitude
- Specifies the north-most edge of the
Rectangle
, in decimal degrees north of the equator. - SouthLatitude
- Specifies the west-most edge of the
Rectangle
, in decimal degrees east of the prime meridian. - StrokeColor
- Sets or gets the color used to outline the
Rectangle
. - StrokeOpacity
- Sets or gets the opacity of the outline of the
Rectangle
. A value of 0.0 will be invisible and a value of 1.0 will be opaque. - StrokeWidth
- Sets or gets the width of the stroke used to outline the
Rectangle
. - Title
- Sets or gets the title displayed in the info window that appears when the user clicks on the map feature.
- Type
- Returns the type of the feature. For rectangles, this returns MapFeature.Rectangle (“Rectangle”).
- Visible
- Specifies whether the
Rectangle
should be visible on the screen. Value istrue
if theRectangle
is showing andfalse
if hidden. - WestLongitude
- Specifies the south-most edge of the
Rectangle
, in decimal degrees south of the equator.
Events
- Click()
- The
Click
event runs when the user taps on theRectangle
. - Drag()
- The
Drag
event runs in response to position updates of theRectangle
as the user drags it. - LongClick()
- The
LongClick
event runs when the user presses and holds theRectangle
and then releases it. This event will only trigger ifDraggable
isfalse
because it uses the same gesture asStartDrag
. - StartDrag()
- The
StartDrag
event runs when the user presses and holds theRectangle
and then proceeds to move their finger on the screen. It will be followed by theDrag
andStopDrag
events. - StopDrag()
- The
StopDrag
event runs when the user releases theRectangle
at the end of a drag.
Methods
- Bounds()
- Returns the bounding box of the
Rectangle
in the format((North West) (South East))
. - Center()
- Returns the center of the
Rectangle
as a list of the form(Latitude Longitude)
. - DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Rectangle
and the givenmapFeature
. Ifcentroids
istrue
, the computation is done between the centroids of the two features. Otherwise, the distance will be computed between the two features based on the closest points. Further, whencentroids
isfalse
, this method will return 0 if theRectangle
intersects or contains themapFeature
. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
Rectangle
and the givenlatitude
andlongitude
. Ifcentroids
istrue
, the distance is computed from the center of theRectangle
to the given point. Otherwise, the distance is computed from the closest point on theRectangle
to the given point. Further, this method will return 0 ifcentroids
isfalse
and the point is in theRectangle
. If an error occurs, -1 will be returned. - HideInfobox()
- Hides the
Rectangle
’s info box if it is visible. Otherwise, no action is taken. - SetCenter(latitude,longitude)
- Move the
Rectangle
to be centered on the givenlatitude
andlongitude
, attempting to keep the width and height (in meters) as equal as possible adjusting for changes in latitude. - ShowInfobox()
- Shows the info box for the
Rectangle
if it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfobox
is false.