Public Member Functions | Properties
Measuring Class Reference

Handles built-in distance and area measuring on the map. More...

List of all members.

Public Member Functions

void Clear ()
 Clears all measurements.
bool Deserialize (string state)
 Restores the state of object from the string.
void FinishMeasuring ()
 Finishes measuring. The measured path won't be cleared from map immediately.
double get_AreaWithClosingVertex (double lastPointProjX, double lastPointProjY)
 Gets an area within the path polygon including an additional point (typically the current position of mouse cursor).
string get_ErrorMsg (int ErrorCode)
 Gets the description of the specific error code.
bool get_PointXY (int PointIndex, out double x, out double y)
 Gets coordinates of specified point in the path.
string Serialize ()
 Saves the state of the class to the string.
bool UndoPoint ()
 Undoes entering of the last point in the path.

Properties

tkAngleFormat AngleFormat [get, set]
 Gets or sets angle format to be used to display bearing.
int AnglePrecision [get, set]
 Gets or sets the number of decimal degrees to be used to display bearing.
double Area [get]
 Gets the measured area (in square meters if WGS84 compatible projection is set for map and in current square map units otherwise).
int AreaPrecision [get, set]
 Gets or sets the number of decimal degrees to be used to display area.
tkAreaDisplayMode AreaUnits [get, set]
 Gets or sets the area units to be displayed.
tkBearingType BearingType [get, set]
 Gets or sets type of the bearing to be display for line segments.
uint FillColor [get, set]
 Gets or sets fill color for polygon display.
byte FillTransparency [get, set]
 Gets or sets fill transparency for polygon display.
ICallback GlobalCallback [get, set]
 Gets or sets a Callback object which handles progress and error messages.
bool IsEmpty [get]
 Returns true if measured path contains at least one point.
bool IsStopped [get]
 Gets value indicating whether measurement was stopped.
bool IsUsingEllipsoid [get]
 Gets a value indicating whether calculations are performed taking into account the shape of Earth (when map projection is defined), or on 2D plane (Euclidean geometry).
string Key [get, set]
 A text string associated with object. Any value can be stored by developer in this property.
int LastErrorCode [get]
 Gets the code of last error which took place inside this object.
double Length [get]
 Gets the length of measured path (in meters if WGS84 compatible projection is set for map and in current map units otherwise).
int LengthPrecision [get, set]
 Gets or sets the number of decimal degrees to be used to display length.
tkLengthDisplayMode LengthUnits [get, set]
 Gets or sets type of the length units to be displayed.
uint LineColor [get, set]
 Gets or sets line color to display measured path.
tkDashStyle LineStyle [get, set]
 Gets or sets line style to display measured path.
float LineWidth [get, set]
 Gets or sets line width to display measured path.
tkMeasuringType MeasuringType [get, set]
 The type of measurement, either distance or area.
bool Persistent [get, set]
 Gets or sets a value indicating whether the finished path will be preserved on map when map cursor changes to something other than cmMeasure.
int PointCount [get]
 Gets number of points in the measured path.
bool PointLabelsVisible [get, set]
 Gets or sets a value indicating whether labels with indices of points will be visible near the vertices.
bool PointsVisible [get, set]
 Gets or sets a value indicating whether vertices of the measured path will be visible.
bool ShowBearing [get, set]
 Gets or sets a value indicating whether bearing of the line segments will be displayed.
bool ShowLength [get, set]
 Gets or sets a value indicating whether length of the line segments will be displayed.
bool ShowTotalLength [get, set]
 Gets or sets a value indicating whether accumulated length will be shown in brackets for each line segment.
tkUndoShortcut UndoButton [get, set]
 Gets or sets the type of user input to be used to undo the last point of the measured path.

Detailed Description

Handles built-in distance and area measuring on the map.

To start measuring set AxMap.CursorMode to cmMeasure. Then the following buttons can be used.

There are 2 modes of measuring:

To toggle to area measuring mode:

 axMap1.Measuring.MeasuringType= tkMeasuringType.MeasureArea;

Measurements will be performed:

Current implementation support only metric units (meters, kilometers). The abbreviated name of units can be changed to a localized one using GlobalSettings.set_LocalizedString:

 GlobalSettings gs = new GlobalSettings();
 gs.set_LocalizedString(tkLocalizedStrings.lsKilometers) = "ΠΊΠΌ";

Custom logic to be executed during measuring can be added by handling AxMap.MeasuringChanged event. Area and length of measured path are available via Measuring.Length and Measuring.Area (in meters and square meters respectively; or map units if no projection is set). Measured points can be accessed using Measuring.get_PointXY and Measuring.PointCount. Use AxMap.ProjToDegrees to get latitude, longitude in decimal degrees.

 axMap1.MeasuringChanged += (s, e) =>
 {
     if (e.action  == tkMeasuringAction.PointAdded)
     {
         if (axMap1.Measuring.IsUsingEllipsoid)
         {
             Debug.WriteLine("Calculations on ellipsoid.");
             Debug.WriteLine("Area: " + axMap1.Measuring.Area + "sq.m");
             Debug.WriteLine("Distance: " + axMap1.Measuring.Length + "m");
         }
         else
         {
             Debug.WriteLine("Calculations on plane.");
             Debug.WriteLine("Area: " + axMap1.Measuring.Area + "map units");
             Debug.WriteLine("Distance: " + axMap1.Measuring.Length + "map units");
         }
  
         double x, y;
         Debug.WriteLine("Measured points (in map units.): " + axMap1.Measuring.PointCount);
         for (int i = 0; i < axMap1.Measuring.PointCount; i++)
         {
             if (axMap1.Measuring.get_PointXY(i, out x, out y))
             {
                 Debug.WriteLine("x={0}; y={1}", x, y);
             }
         }
     }
 };
New API 4.9.1:
Added in version 4.9.1

Member Function Documentation

void Measuring.Clear ( )

Clears all measurements.

bool Measuring.Deserialize ( string  state)

Restores the state of object from the string.

Parameters:
stateA string generated by Measuring.Serialize() method
Returns:
True on success.
New API 4.9.3:
Added in version 4.9.3

Finishes measuring. The measured path won't be cleared from map immediately.

double Measuring.get_AreaWithClosingVertex ( double  lastPointProjX,
double  lastPointProjY 
)

Gets an area within the path polygon including an additional point (typically the current position of mouse cursor).

Parameters:
lastPointProjXX coordinate of the last point (in map coordinates).
lastPointProjYY coordinate of the last point (in map coordinates).
Returns:
Area in square meters if WGS84 compatible projection is set for map and in current square map units otherwise.
string Measuring.get_ErrorMsg ( int  ErrorCode)

Gets the description of the specific error code.

Parameters:
ErrorCodeThe error code returned by LastErrorCode property.
Returns:
String with the description.
New API 4.9.3:
Added in version 4.9.3
bool Measuring.get_PointXY ( int  PointIndex,
out double  x,
out double  y 
)

Gets coordinates of specified point in the path.

Parameters:
PointIndexIndex of a point.
xX coordinate of the point in map coordinates.
yY coordinate of the point in map coordinates.
Returns:
True on success.
string Measuring.Serialize ( )

Saves the state of the class to the string.

Returns:
A string with the state or an empty string on failure.
New API 4.9.3:
Added in version 4.9.3

Undoes entering of the last point in the path.

Returns:
True on success.

Property Documentation

Gets or sets angle format to be used to display bearing.

New API 4.9.3:
Added in version 4.9.3
int Measuring.AnglePrecision [get, set]

Gets or sets the number of decimal degrees to be used to display bearing.

This setting is not used when AngleFormat is set to minutes or seconds.

New API 4.9.3:
Added in version 4.9.3
double Measuring.Area [get]

Gets the measured area (in square meters if WGS84 compatible projection is set for map and in current square map units otherwise).

int Measuring.AreaPrecision [get, set]

Gets or sets the number of decimal degrees to be used to display area.

New API 4.9.3:
Added in version 4.9.3

Gets or sets the area units to be displayed.

New API 4.9.3:
Added in version 4.9.3

Gets or sets type of the bearing to be display for line segments.

New API 4.9.3:
Added in version 4.9.3
uint Measuring.FillColor [get, set]

Gets or sets fill color for polygon display.

New API 4.9.3:
Added in version 4.9.3
byte Measuring.FillTransparency [get, set]

Gets or sets fill transparency for polygon display.

New API 4.9.3:
Added in version 4.9.3

Gets or sets a Callback object which handles progress and error messages.

New API 4.9.3:
Added in version 4.9.3
Deprecated:
v4.9.3 Use GlobalSettings.ApplicationCallback instead.
bool Measuring.IsEmpty [get]

Returns true if measured path contains at least one point.

New API 4.9.3:
Added in version 4.9.3
bool Measuring.IsStopped [get]

Gets value indicating whether measurement was stopped.

Gets a value indicating whether calculations are performed taking into account the shape of Earth (when map projection is defined), or on 2D plane (Euclidean geometry).

New API 4.9.1:
Added in version 4.9.1
string Measuring.Key [get, set]

A text string associated with object. Any value can be stored by developer in this property.

New API 4.9.3:
Added in version 4.9.3

Gets the code of last error which took place inside this object.

New API 4.9.3:
Added in version 4.9.3
double Measuring.Length [get]

Gets the length of measured path (in meters if WGS84 compatible projection is set for map and in current map units otherwise).

int Measuring.LengthPrecision [get, set]

Gets or sets the number of decimal degrees to be used to display length.

New API 4.9.3:
Added in version 4.9.3

Gets or sets type of the length units to be displayed.

New API 4.9.3:
Added in version 4.9.3
uint Measuring.LineColor [get, set]

Gets or sets line color to display measured path.

New API 4.9.3:
Added in version 4.9.3

Gets or sets line style to display measured path.

New API 4.9.3:
Added in version 4.9.3
float Measuring.LineWidth [get, set]

Gets or sets line width to display measured path.

New API 4.9.3:
Added in version 4.9.3

The type of measurement, either distance or area.

bool Measuring.Persistent [get, set]

Gets or sets a value indicating whether the finished path will be preserved on map when map cursor changes to something other than cmMeasure.

Gets number of points in the measured path.

Gets or sets a value indicating whether labels with indices of points will be visible near the vertices.

New API 4.9.3:
Added in version 4.9.3
bool Measuring.PointsVisible [get, set]

Gets or sets a value indicating whether vertices of the measured path will be visible.

New API 4.9.3:
Added in version 4.9.3
bool Measuring.ShowBearing [get, set]

Gets or sets a value indicating whether bearing of the line segments will be displayed.

New API 4.9.3:
Added in version 4.9.3
bool Measuring.ShowLength [get, set]

Gets or sets a value indicating whether length of the line segments will be displayed.

New API 4.9.3:
Added in version 4.9.3
bool Measuring.ShowTotalLength [get, set]

Gets or sets a value indicating whether accumulated length will be shown in brackets for each line segment.

New API 4.9.3:
Added in version 4.9.3
tkUndoShortcut Measuring.UndoButton [get, set]

Gets or sets the type of user input to be used to undo the last point of the measured path.

New API 4.9.3:
Added in version 4.9.3
 All Classes Files Functions Enumerations Properties Events