Class MVDistanceTool
MVDistance defines a distance tool instance with which the user can calculate the straight-line distance between the points generated by clicking and moving the mouse on the map repeatedly. The total distance info is displayed in a tooltip around the last shape point in readable way.
When get all the distance info, the user can double click the map to finish the distance tool; When finished the distance tool, click on the map will not create any shape points and lines
Once created, the line and distance info tooltip stays on the map until the application invokes function MVDistanceTool.clear to remove these feature from the map.
Constructor Attributes | Constructor Name and Description |
---|---|
MVDistanceTool(unitStandard, foiServerURL)
|
Method Attributes | Method Name and Description |
---|---|
attachEventListener(event, listener)
This method attaches an event listener to handle one of the following distance tool events:
MVEvent.NEW_SHAPE_POINT , MVEvent.FINISH and MVEvent.MODIFY
|
|
clear()
This method clears any lines or foi rendered by the current MVDistance instance.
|
|
detachEventListener(event, listener)
This method detaches an event listener that has previously been attached to the distance tool
by #attachEventListener.
|
|
finish(evt)
This method finish the current MVDistance instance.
|
|
This method returns the array of ordinates of the distance shape points.
|
|
This method gets the status of the distance tool.
|
|
init()
This method initializes the distance tool instance.
|
|
setRenderingStyle(objType, objStyle)
This method sets the style for the distance tool shape points, lines or polygon area.
|
|
setTextStyle(style)
This method set the distance tool's distance info box div style.
|
Class Detail
MVDistanceTool(unitStandard, foiServerURL)
- Parameters:
- {Integer} unitStandard
- A Integer that specifies the unit standard uesd to display the distance info, the value should be MVDistanceTool.METRIC ; or MVDistanceTool.IMPERIAL ; When use MVDistanceTool.METRIC , the distance will be displayed in KM,M and CM; when use MVDistanceTool.METRIC, the distance will be displayed in mi,yd,ft.
- {String} foiServerURL
- An optional String parameter that specifies the URL of the FOI server that renders the distance features(line). The FOI server URL should be in the form http://host:port/mapviewer/foi. If omitted, the URL of the FOI server is derived from the MapViewer base URL.
- Returns:
- The newly created MVDistanceTool object.
Method Detail
{void}
attachEventListener(event, listener)
This method attaches an event listener to handle one of the following distance tool events:
MVEvent.NEW_SHAPE_POINT , MVEvent.FINISH and MVEvent.MODIFY
- A MVEvent.NEW_SHAPE_POINT event is fired when the user creates a new distance shape point by clicking the mouse on the map. No parameter is passed to this function when it is invoked.
- A MVEvent.FINISH event is fired when the user deactives/finishes the distance tool.
- A MVEvent.MODIFY event is fired when the user moves any of the existing shape points or lines of the distance tool.
- Parameters:
- {String} event
- a String that specifies the type of event to be handled by the listener. It can only be MVEvent.NEW_SHAPE_POINT or MVEvent.FINISH or MVEvent.MODIFY
- {Function} listener
- a javascript listener function. There is no parameter passed to the listener when it is called.
- Returns:
- none
{void}
clear()
This method clears any lines or foi rendered by the current MVDistance instance.
- Returns:
- none
{void}
detachEventListener(event, listener)
This method detaches an event listener that has previously been attached to the distance tool
by #attachEventListener.
- Parameters:
- {String} event
- a String that specifies the type of event to be handled by the listener. It can only be MVEvent.NEW_SHAPE_POINT or MVEvent.FINISH or MVEvent.MODIFY
- {Function} listener
- a javascript listener function. There is no parameter passed to the listener when it is called.
- Returns:
- none
{void}
finish(evt)
This method finish the current MVDistance instance. After this method
is called, mouse clicks no longer draw any shape points or lines on the map.
- Parameters:
- evt
- Returns:
- none
{Array}
getOrdinates()
This method returns the array of ordinates of the distance shape points.
- Returns:
- the array of ordinates for the distance shape points.
{int}
getStatus()
This method gets the status of the distance tool. At any give time, the distance
tool can be in one of the following statuses:
- 0: Not ready
- 1: Ready and initialized
- 2: Distance tool finished distance info got
- Returns:
- the status of the distance tool.
{void}
init()
This method initializes the distance tool instance. It should be the last method to call
before drawing on the map. After this function is invoked, the user can start getting
distance info on the map by clicking and moving the mouse repeatedly.
- Returns:
- none
{void}
setRenderingStyle(objType, objStyle)
This method sets the style for the distance tool shape points, lines or polygon area.
- Parameters:
- {String} objType
- It specifies the object for which a style is applied to. Its value can only be MVRedlineTool.STYLE_POINT, MVRedlineTool.STYLE_LINE or MVRedlineTool.STYLE_AREA.
- {Object} objStyle
- A string or style object which specifies the rendering style.
If it is a string, the string should be in the form of
. , where is the name of the style which is defined in the USER_SDO_STYLES view, and is the name of the data source in which the style is defined. If it is a style object, it should be of type MVStyleMarker, MVStyleColor and MVXMLStyle etc.
- Returns:
- none
{void}
setTextStyle(style)
This method set the distance tool's distance info box div style. It should
be in CSS style string. eg:"font-family:Tahoma;"
- Parameters:
- {String} style
- CCS style format
- Returns:
- none