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
Circleto 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
SetLocationmethod. - 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
SetLocationmethod. - 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
Circleshould be visible on the screen. Value istrueif theCircleis showing andfalseif hidden.
Events
- Click()
- The
Clickevent runs when the user taps on theCircle. - Drag()
- The
Dragevent runs in response to position updates of theCircleas the user drags it. - LongClick()
- The
LongClickevent runs when the user presses and holds theCircleand then releases it. This event will only trigger ifDraggableisfalsebecause it uses the same gesture asStartDrag. - StartDrag()
- The
StartDragevent runs when the user presses and holds theCircleand then proceeds to move their finger on the screen. It will be followed by theDragandStopDragevents. - StopDrag()
- The
StopDragevent runs when the user releases theCircleat the end of a drag.
Methods
- DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Circleand the givenmapFeature. Ifcentroidsistrue, 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, whencentroidsisfalse, this method will return 0 if theCircleintersects or contains themapFeature. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
Circleand the givenlatitudeandlongitude. Ifcentroidsistrue, the distance is computed from the center of theCircleto the given point. Otherwise, the distance is computed from the closest point on theCircleto the given point. Further, this method will return 0 ifcentroidsisfalseand 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
Circleto the givenlatitudeandlongitude. This method is more efficient than settingLatitudeandLongitudeseparately. - ShowInfobox()
- Shows the info box for the
Circleif it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfoboxis 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.
FeatureCollections can be loaded from external resources to populate Maps 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’sVisibleproperty). This list also includes any features created on theFeatureCollectionby 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
Sourceproperty. - Height
- Specifies the
FeatureCollection’s vertical height, measured in pixels. - HeightPercent
- Specifies the
FeatureCollection’s vertical height as a percentage of theScreen’sHeight. - Left
- Specifies the position of the Left edge of the component relative to an AbsoluteArrangement.
- 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.
- Top
- Specifies the position of the Top edge of the component relative to an AbsoluteArrangement.
- Visible
- Specifies whether the
FeatureCollectionshould be visible on the screen. Value istrueif theFeatureCollectionis showing andfalseif hidden. - Width
- Specifies the horizontal width of the
FeatureCollection, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
FeatureCollectionas a percentage of theScreen’sWidth.
Events
- FeatureClick(feature)
- When a feature is clicked, the parent
FeatureCollectionwill also receive aFeatureClickevent. Thefeatureparameter indicates which child feature was clicked. This event is run after theClickevent on the corresponding feature and after thewhen any ... Clickevent if one is provided. - FeatureDrag(feature)
- When the user drags a feature, the parent
FeatureCollectionwill also receive aFeatureDragevent. Thefeatureparameter indicates which child feature was dragged. This event is run after theDragevent on the corresponding feature and after thewhen any ... Dragevent if one is provided. - FeatureLongClick(feature)
- When a feature is long-clicked, the parent
FeatureCollectionwill also receive aFeatureLongClickevent. Thefeatureparameter indicates which child feature was long-clicked. This event is run after theLongClickevent on the corresponding feature and after thewhen any ... LongClickevent if one is provided. - FeatureStartDrag(feature)
- When the user starts dragging a feature, the parent
FeatureCollectionwill also receive aFeatureStartDragevent. Thefeatureparameter indicates which child feature was dragged. This event is run after theStartDragevent on the corresponding feature and after thewhen any ... StartDragevent if one is provided. - FeatureStopDrag(feature)
- When the user stops dragging a feature, the parent
FeatureCollectionwill also receive aFeatureStopDragevent. Thefeatureparameter indicates which child feature was dragged. This event is run after theStopDragevent on the corresponding feature and after thewhen any ... StopDragevent if one is provided. - GotFeatures(url,features)
- The
GotFeaturesevent is run when when a feature collection is successfully read from the givenurl. Thefeaturesparameter will be a list of feature descriptions that can be converted into components using theFeatureFromDescriptionmethod. - LoadError(url,responseCode,errorMessage)
- The
LoadErrorevent is run when an error occurs while processing a feature collection document at the givenurl. TheresponseCodeparameter will contain an HTTP status code and theerrorMessageparameter will contain a detailed error message.
Methods
- FeatureFromDescription(description)
- Converts a feature description into an App Inventor map feature. Points are converted into
Markercomponents, LineStrings are converted intoLineStringcomponents, and Polygons (and MultiPolygons) are converted intoPolygoncomponents. 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 eventGotFeatureswill be raised with the givenurland a list offeatures parsed from the GeoJSON as a list of (key, value) pairs. On failure, theLoadErrorevent 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
LineStringto 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
LineStringshould be visible on the screen. Value istrueif theLineStringis showing andfalseif hidden.
Events
- Click()
- The
Clickevent runs when the user taps on theLineString. - Drag()
- The
Dragevent runs in response to position updates of theLineStringas the user drags it. - LongClick()
- The
LongClickevent runs when the user presses and holds theLineStringand then releases it. This event will only trigger ifDraggableisfalsebecause it uses the same gesture asStartDrag. - StartDrag()
- The
StartDragevent runs when the user presses and holds theLineStringand then proceeds to move their finger on the screen. It will be followed by theDragandStopDragevents. - StopDrag()
- The
StopDragevent runs when the user releases theLineStringat the end of a drag.
Methods
- DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
LineStringand the givenmapFeature. Ifcentroidsistrue, 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, whencentroidsisfalse, this method will return 0 if theLineStringintersects or contains themapFeature. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
LineStringand the givenlatitudeandlongitude. Ifcentroidsistrue, the distance is computed from the center of theLineStringto the given point. Otherwise, the distance is computed from the closest point on theLineStringto the given point. Further, this method will return 0 ifcentroidsisfalseand 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
LineStringif it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfoboxis 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, or a custom basemap URL can be provided.
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 Markers 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
PanTowith numerical latitude and longitude rather than convert to the string representation for use with this property. - CustomUrl
- Update the custom URL of the base tile layer in use by the map. e.g. https://tile.openstreetmap.org/{z}/{x}/{y}.png e.g. https://example.com/geoserver/gwc/service/tms/1.0.0/workspace:layername
- 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’sVisibleproperty). This list also includes any features created on theMapby 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
PanTomethod. - Left
- Specifies the position of the Left edge of the component relative to an AbsoluteArrangement.
- LocationSensor
- Uses the provided
LocationSensorfor 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
PanTomethod. - MapType
- Sets or gets the tile layer used to draw the Map background. Defaults to Roads. Valid values
are:
- Roads
- Aerial
- Terrain
- Custom
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.
- Top
- Specifies the position of the Top edge of the component relative to an AbsoluteArrangement.
- UserLatitude
- Returns the user’s latitude if ShowUser is enabled.
- UserLongitude
- Returns the user’s longitude if ShowUser is enabled.
- Visible
- Specifies whether the
Mapshould be visible on the screen. Value istrueif theMapis showing andfalseif hidden. - Width
- Specifies the horizontal width of the
Map, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
Mapas 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
BoundsChangeevent runs when the user changes the map bounds, either by zooming, panning, or rotating the view. - DoubleTapAtPoint(latitude,longitude)
- The
DoubleTapAtPointruns when the user double taps at a point on the map. The tapped location will be reported in map coordinates via thelatitudeandlongitudeparameters. - FeatureClick(feature)
- When a feature is clicked, the parent
Mapwill also receive aFeatureClickevent. Thefeatureparameter indicates which child feature was clicked. This event is run after theClickevent on the corresponding feature and after thewhen any ... Clickevent if one is provided. - FeatureDrag(feature)
- When the user drags a feature, the parent
Mapwill also receive aFeatureDragevent. Thefeatureparameter indicates which child feature was dragged. This event is run after theDragevent on the corresponding feature and after thewhen any ... Dragevent if one is provided. - FeatureLongClick(feature)
- When a feature is long-clicked, the parent
Mapwill also receive aFeatureLongClickevent. Thefeatureparameter indicates which child feature was long-clicked. This event is run after theLongClickevent on the corresponding feature and after thewhen any ... LongClickevent if one is provided. - FeatureStartDrag(feature)
- When the user starts dragging a feature, the parent
Mapwill also receive aFeatureStartDragevent. Thefeatureparameter indicates which child feature was dragged. This event is run after theStartDragevent on the corresponding feature and after thewhen any ... StartDragevent if one is provided. - FeatureStopDrag(feature)
- When the user stops dragging a feature, the parent
Mapwill also receive aFeatureStopDragevent. Thefeatureparameter indicates which child feature was dragged. This event is run after theStopDragevent on the corresponding feature and after thewhen any ... StopDragevent if one is provided. - GotFeatures(url,features)
- The
GotFeaturesevent is run when a feature collection is successfully read from the givenurl. Thefeaturesparameter will be a list of feature descriptions that can be converted into components using theFeatureFromDescriptionmethod. - InvalidPoint(message)
- The
InvalidPointevent 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). Themessageparameter will contain an explanation for the error. - LoadError(url,responseCode,errorMessage)
- The
LoadErrorevent is run when an error occurs while processing a feature collection document at the givenurl. TheresponseCodeparameter will contain an HTTP status code and theerrorMessageparameter will contain a detailed error message. - LongPressAtPoint(latitude,longitude)
- The
LongPressAtPointruns 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 thelatitudeandlongitudeparameters. - Ready()
- The
Readyevent runs once theMaphas been initialized and is ready for user interaction. - TapAtPoint(latitude,longitude)
- The
TapAtPointruns when the user taps at a point on the map. The tapped location will be reported in map coordinates via thelatitudeandlongitudeparameters. - ZoomChange()
- The
ZoomChangeevent 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
Markeron theMapat the specifiedlatitudeandlongitude. - FeatureFromDescription(description)
- Converts a feature description into an App Inventor map feature. Points are converted into
Markercomponents, LineStrings are converted intoLineStringcomponents, and Polygons (and MultiPolygons) are converted intoPolygoncomponents. 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 eventGotFeatureswill be raised with the givenurland a list offeatures parsed from the GeoJSON as a list of (key, value) pairs. On failure, theLoadErrorevent 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
Mapas a GeoJSON file at the specified path.
Marker
The Marker component indicates points on a Map, such as buildings or other points of
interest. Markers can be customized in many ways, such as using custom images from the app’s
assets or by changing the Marker FillColor. Markers 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
Markercenter relative to its image. Valid values are:1(Left),2(Right), or3(Center). - AnchorVertical
- Sets or gets the vertical offset of the
Markercenter 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
Markerto 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 theLatitudeandLongitudesimultaneously, use theSetLocationmethod. - 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 theLatitudeandLongitudesimultaneously, use theSetLocationmethod. - 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
Markershould be visible on the screen. Value istrueif theMarkeris showing andfalseif hidden. - Width
- Specifies the horizontal width of the
Marker, measured in pixels. - WidthPercent
- Specifies the horizontal width of the
Markeras a percentage of theScreen’sWidth.
Events
- Click()
- The
Clickevent runs when the user taps on theMarker. - Drag()
- The
Dragevent runs in response to position updates of theMarkeras the user drags it. - LongClick()
- The
LongClickevent runs when the user presses and holds theMarkerand then releases it. This event will only trigger ifDraggableisfalsebecause it uses the same gesture asStartDrag. - StartDrag()
- The
StartDragevent runs when the user presses and holds theMarkerand then proceeds to move their finger on the screen. It will be followed by theDragandStopDragevents. - StopDrag()
- The
StopDragevent runs when the user releases theMarkerat the end of a drag.
Methods
- BearingToFeature(mapFeature,centroids)
- Returns the bearing from the
Markerto the given map feature, in degrees from due north. If thecentroidsparameter 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
Markerto the givenlatitudeandlongitude, in degrees from due north. - DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Markerand the givenmapFeature. Ifcentroidsistrue, 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, whencentroidsisfalse, this method will return 0 if theMarkerintersects or contains themapFeature. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude)
- Compute the distance, in meters, between a
Markerand alatitude,longitudepoint. - 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
Markerif it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfoboxis 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
GotDirectionsevent 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’sPointsto 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, theGotDirectionsevent block will run. If an error occurs, the error will be reported via theScreen's ErrorOccurredevent.
Polygon
Polygon encloses an arbitrary 2-dimensional area on a Map. Polygons can be used for
drawing a perimeter, such as a campus, city, or country. Polygons 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
Polygonto 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. TheHolePointsproperty is a list of lists, with each sublist containing(latitude, longitude)points representing a hole. - HolePointsFromString
- Specifies holes in a
Polygonfrom 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
Polygonfrom 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
Polygonshould be visible on the screen. Value istrueif thePolygonis showing andfalseif hidden.
Events
- Click()
- The
Clickevent runs when the user taps on thePolygon. - Drag()
- The
Dragevent runs in response to position updates of thePolygonas the user drags it. - LongClick()
- The
LongClickevent runs when the user presses and holds thePolygonand then releases it. This event will only trigger ifDraggableisfalsebecause it uses the same gesture asStartDrag. - StartDrag()
- The
StartDragevent runs when the user presses and holds thePolygonand then proceeds to move their finger on the screen. It will be followed by theDragandStopDragevents. - StopDrag()
- The
StopDragevent runs when the user releases thePolygonat the end of a drag.
Methods
- Centroid()
- Gets the centroid of the
Polygonas a(latitude, longitude)pair. - DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Polygonand the givenmapFeature. Ifcentroidsistrue, 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, whencentroidsisfalse, this method will return 0 if thePolygonintersects or contains themapFeature. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
Polygonand the givenlatitudeandlongitude. Ifcentroidsistrue, the distance is computed from the center of thePolygonto the given point. Otherwise, the distance is computed from the closest point on thePolygonto the given point. Further, this method will return 0 ifcentroidsisfalseand 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
Polygonif it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfoboxis false.
Rectangle
Rectangles 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
Rectangleto 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
Rectangleshould be visible on the screen. Value istrueif theRectangleis showing andfalseif hidden. - WestLongitude
- Specifies the south-most edge of the
Rectangle, in decimal degrees south of the equator.
Events
- Click()
- The
Clickevent runs when the user taps on theRectangle. - Drag()
- The
Dragevent runs in response to position updates of theRectangleas the user drags it. - LongClick()
- The
LongClickevent runs when the user presses and holds theRectangleand then releases it. This event will only trigger ifDraggableisfalsebecause it uses the same gesture asStartDrag. - StartDrag()
- The
StartDragevent runs when the user presses and holds theRectangleand then proceeds to move their finger on the screen. It will be followed by theDragandStopDragevents. - StopDrag()
- The
StopDragevent runs when the user releases theRectangleat the end of a drag.
Methods
- Bounds()
- Returns the bounding box of the
Rectanglein the format((North West) (South East)). - Center()
- Returns the center of the
Rectangleas a list of the form(Latitude Longitude). - DistanceToFeature(mapFeature,centroids)
- Computes the distance between the
Rectangleand the givenmapFeature. Ifcentroidsistrue, 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, whencentroidsisfalse, this method will return 0 if theRectangleintersects or contains themapFeature. If an error occurs, this method will return -1. - DistanceToPoint(latitude,longitude,centroid)
- Computes the distance between the
Rectangleand the givenlatitudeandlongitude. Ifcentroidsistrue, the distance is computed from the center of theRectangleto the given point. Otherwise, the distance is computed from the closest point on theRectangleto the given point. Further, this method will return 0 ifcentroidsisfalseand 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
Rectangleto be centered on the givenlatitudeandlongitude, 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
Rectangleif it is not visible. Otherwise, this method has no effect. This method can be used to show the info box even ifEnableInfoboxis false.