地图组件

« 返回首页

地图组件

目录:

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.

属性

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 is if the Circle is showing and if hidden.

事件

Click()
The Click event runs when the user taps on the Circle.
Drag()
The Drag event runs in response to position updates of the Circle as the user drags it.
LongClick()
The LongClick event runs when the user presses and holds the Circle and then releases it. This event will only trigger if Draggable is because it uses the same gesture as StartDrag.
StartDrag()
The StartDrag event runs when the user presses and holds the Circle and then proceeds to move their finger on the screen. It will be followed by the Drag and StopDrag events.
StopDrag()
The StopDrag event runs when the user releases the Circle at the end of a drag.

方法

DistanceToFeature(mapFeature,centroids)
Computes the distance between the Circle and the given mapFeature. If centroids is , 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, when centroids is , this method will return 0 if the Circle intersects or contains the mapFeature. If an error occurs, this method will return -1.
DistanceToPoint(latitude,longitude,centroid)
Computes the distance between the Circle and the given latitude and longitude. If centroids is , the distance is computed from the center of the Circle to the given point. Otherwise, the distance is computed from the closest point on the Circle to the given point. Further, this method will return 0 if centroids is and the point is in the Circle. 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 given latitude and longitude. This method is more efficient than setting Latitude and Longitude 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 if EnableInfobox is false.

特征集合

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.

属性

Features
Gets the list of features attached to the FeatureCollection (without regard to the value of the feature’s Visible property). This list also includes any features created on the FeatureCollection by calls to FeatureFromDescription.
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.
高度
设置特征集合的垂直高度,以像素px为单位。
高度百分比
设置特征集合的垂直高度相对于整个屏幕高度的百分比。
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.
可见性
设置特征集合是否显示在屏幕上,值是特征集合显示,则隐藏。
宽度
设置特征集合的水平宽度,以像素px为单位。
宽度百分比
设置特征集合的水平宽度相对于屏幕宽度的百分比。

事件

FeatureClick(feature)
When a feature is clicked, the parent FeatureCollection will also receive a FeatureClick event. The feature parameter indicates which child feature was clicked. This event is run after the Click event on the corresponding feature and after the when any ... Click event if one is provided.
FeatureDrag(feature)
When the user drags a feature, the parent FeatureCollection will also receive a FeatureDrag event. The feature parameter indicates which child feature was dragged. This event is run after the Drag event on the corresponding feature and after the when any ... Drag event if one is provided.
FeatureLongClick(feature)
When a feature is long-clicked, the parent FeatureCollection will also receive a FeatureLongClick event. The feature parameter indicates which child feature was long-clicked. This event is run after the LongClick event on the corresponding feature and after the when any ... LongClick event if one is provided.
FeatureStartDrag(feature)
When the user starts dragging a feature, the parent FeatureCollection will also receive a FeatureStartDrag event. The feature parameter indicates which child feature was dragged. This event is run after the StartDrag event on the corresponding feature and after the when any ... StartDrag event if one is provided.
FeatureStopDrag(feature)
When the user stops dragging a feature, the parent FeatureCollection will also receive a FeatureStopDrag event. The feature parameter indicates which child feature was dragged. This event is run after the StopDrag event on the corresponding feature and after the when 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 given url. The features parameter will be a list of feature descriptions that can be converted into components using the FeatureFromDescription method.
LoadError(url,responseCode,errorMessage)
The LoadError event is run when an error occurs while processing a feature collection document at the given url. The responseCode parameter will contain an HTTP status code and the errorMessage parameter will contain a detailed error message.

方法

FeatureFromDescription(description)
Converts a feature description into an App Inventor map feature. Points are converted into Marker components, LineStrings are converted into LineString components, and Polygons (and MultiPolygons) are converted into Polygon 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
LoadFromURL(url)
Loads 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 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.

线段

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.

属性

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 is if the LineString is showing and if hidden.

事件

Click()
The Click event runs when the user taps on the LineString.
Drag()
The Drag event runs in response to position updates of the LineString as the user drags it.
LongClick()
The LongClick event runs when the user presses and holds the LineString and then releases it. This event will only trigger if Draggable is because it uses the same gesture as StartDrag.
StartDrag()
The StartDrag event runs when the user presses and holds the LineString and then proceeds to move their finger on the screen. It will be followed by the Drag and StopDrag events.
StopDrag()
The StopDrag event runs when the user releases the LineString at the end of a drag.

方法

DistanceToFeature(mapFeature,centroids)
Computes the distance between the LineString and the given mapFeature. If centroids is , 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, when centroids is , this method will return 0 if the LineString intersects or contains the mapFeature. If an error occurs, this method will return -1.
DistanceToPoint(latitude,longitude,centroid)
Computes the distance between the LineString and the given latitude and longitude. If centroids is , the distance is computed from the center of the LineString to the given point. Otherwise, the distance is computed from the closest point on the LineString to the given point. Further, this method will return 0 if centroids is and the point is in the LineString. 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 if EnableInfobox is false.

地图

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 Markers off-screen, then the "Reset Map to Initial Bounds" button can be used to re-center the Map at the starting location.

属性

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’s Visible property). This list also includes any features created on the Map by calls to FeatureFromDescription.
高度
设置地图的垂直高度,以像素px为单位。
高度百分比
设置地图的垂直高度相对于整个屏幕高度的百分比。
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:
  1. Roads
  2. Aerial
  3. 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.
可见性
设置地图是否显示在屏幕上,值是地图显示,则隐藏。
宽度
设置地图的水平宽度,以像素px为单位。
宽度百分比
设置地图的水平宽度相对于屏幕宽度的百分比。
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.

事件

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 the latitude and longitude parameters.
FeatureClick(feature)
When a feature is clicked, the parent Map will also receive a FeatureClick event. The feature parameter indicates which child feature was clicked. This event is run after the Click event on the corresponding feature and after the when any ... Click event if one is provided.
FeatureDrag(feature)
When the user drags a feature, the parent Map will also receive a FeatureDrag event. The feature parameter indicates which child feature was dragged. This event is run after the Drag event on the corresponding feature and after the when any ... Drag event if one is provided.
FeatureLongClick(feature)
When a feature is long-clicked, the parent Map will also receive a FeatureLongClick event. The feature parameter indicates which child feature was long-clicked. This event is run after the LongClick event on the corresponding feature and after the when any ... LongClick event if one is provided.
FeatureStartDrag(feature)
When the user starts dragging a feature, the parent Map will also receive a FeatureStartDrag event. The feature parameter indicates which child feature was dragged. This event is run after the StartDrag event on the corresponding feature and after the when any ... StartDrag event if one is provided.
FeatureStopDrag(feature)
When the user stops dragging a feature, the parent Map will also receive a FeatureStopDrag event. The feature parameter indicates which child feature was dragged. This event is run after the StopDrag event on the corresponding feature and after the when 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 given url. The features parameter will be a list of feature descriptions that can be converted into components using the FeatureFromDescription 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). The message 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 given url. The responseCode parameter will contain an HTTP status code and the errorMessage 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 the latitude and longitude parameters.
Ready()
The Ready event runs once the Map 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 the latitude and longitude 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.

方法

CreateMarker(latitude,longitude)
Creates a new Marker on the Map at the specified latitude and longitude.
FeatureFromDescription(description)
Converts a feature description into an App Inventor map feature. Points are converted into Marker components, LineStrings are converted into LineString components, and Polygons (and MultiPolygons) are converted into Polygon 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
LoadFromURL(url)
Loads 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 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.
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.

标记

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.

属性

AnchorHorizontal
Sets or gets the horizontal offset of the Marker center relative to its image. Valid values are: 1 (Left), 2 (Right), or 3 (Center).
AnchorVertical
Sets or gets the vertical offset of the Marker center relative to its image. Valid values are: 1 (Top), 2 (Center), or 3 (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.
高度
设置标记的垂直高度,以像素px为单位。
高度百分比
设置标记的垂直高度相对于整个屏幕高度的百分比。
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 the Latitude and Longitude simultaneously, use the SetLocation 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 the Latitude and Longitude simultaneously, use the SetLocation 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”.
可见性
设置标记是否显示在屏幕上,值是标记显示,则隐藏。
宽度
设置标记的水平宽度,以像素px为单位。
宽度百分比
设置标记的水平宽度相对于屏幕宽度的百分比。

事件

Click()
The Click event runs when the user taps on the Marker.
Drag()
The Drag event runs in response to position updates of the Marker as the user drags it.
LongClick()
The LongClick event runs when the user presses and holds the Marker and then releases it. This event will only trigger if Draggable is because it uses the same gesture as StartDrag.
StartDrag()
The StartDrag event runs when the user presses and holds the Marker and then proceeds to move their finger on the screen. It will be followed by the Drag and StopDrag events.
StopDrag()
The StopDrag event runs when the user releases the Marker at the end of a drag.

方法

BearingToFeature(mapFeature,centroids)
Returns the bearing from the Marker to the given map feature, in degrees from due north. If the centroids parameter is , the bearing will be to the center of the map feature. Otherwise, the bearing will be computed to the point in the feature nearest the Marker.
BearingToPoint(latitude,longitude)
Returns the bearing from the Marker to the given latitude and longitude, in degrees from due north.
DistanceToFeature(mapFeature,centroids)
Computes the distance between the Marker and the given mapFeature. If centroids is , 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, when centroids is , this method will return 0 if the Marker intersects or contains the mapFeature. If an error occurs, this method will return -1.
DistanceToPoint(latitude,longitude)
Compute the distance, in meters, between a Marker and a latitude, 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 if EnableInfobox is false.

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.

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 paths
  • driving-car: Route based on vehicle paths
  • cycling-regular: Route based on bicycle paths
  • wheelchair: Route based on wheelchair accessible paths
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 to LineString’s Points to draw the line on a Map.
  • distance: Estimated distance for the route, in meters.
  • duration: Estimated duration for the route, in seconds.
Request directions from the routing service using the values of StartLatitude, StartLongitude, EndLatitude, and EndLongitude. On success, the GotDirections event block will run. If an error occurs, the error will be reported via the Screen's ErrorOccurred event.

多边形

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.

属性

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. The HolePoints property 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 to HolePoints, 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. Unlike Points, 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 is if the Polygon is showing and if hidden.

事件

Click()
The Click event runs when the user taps on the Polygon.
Drag()
The Drag event runs in response to position updates of the Polygon as the user drags it.
LongClick()
The LongClick event runs when the user presses and holds the Polygon and then releases it. This event will only trigger if Draggable is because it uses the same gesture as StartDrag.
StartDrag()
The StartDrag event runs when the user presses and holds the Polygon and then proceeds to move their finger on the screen. It will be followed by the Drag and StopDrag events.
StopDrag()
The StopDrag event runs when the user releases the Polygon at the end of a drag.

方法

Centroid()
Gets the centroid of the Polygon as a (latitude, longitude) pair.
DistanceToFeature(mapFeature,centroids)
Computes the distance between the Polygon and the given mapFeature. If centroids is , 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, when centroids is , this method will return 0 if the Polygon intersects or contains the mapFeature. If an error occurs, this method will return -1.
DistanceToPoint(latitude,longitude,centroid)
Computes the distance between the Polygon and the given latitude and longitude. If centroids is , the distance is computed from the center of the Polygon to the given point. Otherwise, the distance is computed from the closest point on the Polygon to the given point. Further, this method will return 0 if centroids is and the point is in the Polygon. 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 if EnableInfobox is false.

矩形

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.

属性

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 is if the Rectangle is showing and if hidden.
WestLongitude
Specifies the south-most edge of the Rectangle, in decimal degrees south of the equator.

事件

Click()
The Click event runs when the user taps on the Rectangle.
Drag()
The Drag event runs in response to position updates of the Rectangle as the user drags it.
LongClick()
The LongClick event runs when the user presses and holds the Rectangle and then releases it. This event will only trigger if Draggable is because it uses the same gesture as StartDrag.
StartDrag()
The StartDrag event runs when the user presses and holds the Rectangle and then proceeds to move their finger on the screen. It will be followed by the Drag and StopDrag events.
StopDrag()
The StopDrag event runs when the user releases the Rectangle at the end of a drag.

方法

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 given mapFeature. If centroids is , 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, when centroids is , this method will return 0 if the Rectangle intersects or contains the mapFeature. If an error occurs, this method will return -1.
DistanceToPoint(latitude,longitude,centroid)
Computes the distance between the Rectangle and the given latitude and longitude. If centroids is , the distance is computed from the center of the Rectangle to the given point. Otherwise, the distance is computed from the closest point on the Rectangle to the given point. Further, this method will return 0 if centroids is and the point is in the Rectangle. 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 given latitude and longitude, 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 if EnableInfobox is false.