Circle元件 / Map

Circle元件 (MIT AI2 說明頁面)

Circle元件可接收緯度、經度為參數在Map元件上顯示一個圓形區域,半徑單位為公尺。其外觀可由FillColorStrokeColorStrokeWidth觀等屬性來調整。

Circle元件可做到像是an 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. 使用本元件的DistanceToPoint方法搭配LocationSensor,就可以判斷使用者的位置是在circle之內或之外。您可使用這個功能來觸發額外的動作。

屬性
DescriptionSets or gets the description displayed in the info window. The info window appears when the user taps on the circle.
DraggableSets 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.
EnableInfoboxEnables or disables the infobox window display when the user taps the circle.
FillColorSets or gets the color used to fill in the circle.
LatitudeSets or gets the latitude of the center of the circle, in degrees. 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.
LongitudeSets or gets the longitude of the center of the circle, in degrees. 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.
Radius
設定或取得circle半徑,單位為公尺。

StrokeColorSets or gets the color used to outline the circle.
StrokeWidthSets or gets the width of the stroke used to outline the circle.

TitleSets or gets the title displayed in the info window that appears when the user clicks on the map feature.

TypeGets the type of the feature. For Circle, this will always be "Circle",

VisibleSets or gets whether the component should be visible on the screen. Value is true if the component is showing and false if hidden.

事件

Click

當circle被點選時,呼叫本事件。

Drag
DragRuns during drag operations.

LongClick
Runs after the user long clicks on the circle but does not trigger a drag. Note that this event will only trigger if Draggable is false.

StartDrag
Runs before a drag operation begins. Use this to save the current position of the circle, for example.

StopDrag

Runs after a drag operation completes. Use this to save the new position of the circle, for example.

方法
number DistanceToFeature(component mapFeature, boolean centroids)Computes the distance between the Circle and the given mapFeature. If centroids is true, 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 false, this method will return 0 if the circle intersects or contains the mapFeature. If an error occurs, this method will return -1.number 

DistanceToPoint(number latitude, number longitude, boolean centroids)Computes the distance between the Circle and the given latitude and longitude. If centroids is true, 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 false and the point is in the circle. If an error occurs, -1 will be returned.

HideInfoboxHides the circle's info box if it is visible. Otherwise, no action is taken.

SetLocation(number latitude, number longitude)Moves the center of the circle to the given latitude and longitude. This method is more efficient than setting latitude and longitude separately.

ShowInfoboxShows 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.
Comments