hi,
i want to calculate distance between two and more point where the user clicks.
the code i have written is as follow...
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.DesktopEdition;
namespace CustomTrackLine
{
class CustomTrackInteractiveOverlay : TrackInteractiveOverlay
{
private const string currentFeatureKey = "CurrentFeature";
private LineShape rulerLineShape;
private int mouseDown;
public CustomTrackInteractiveOverlay()
: base()
{
this.TrackMode = TrackMode.Line;
}
protected override InteractiveResult MouseDownCore(InteractionArguments interactionArguments)
{
if (interactionArguments.MouseButton != MapMouseButton.Right)
return base.MouseDownCore(interactionArguments);
else
RemoveLastVertexAdded();
return new InteractiveResult();
}
private void RemoveLastVertexAdded()
{
int minVertex = 2;
if (this.Vertices.Count > minVertex)
{
this.Lock.EnterWriteLock();
try
{
Vertex lastVertex = this.Vertices[this.Vertices.Count - 2];
this.Vertices.Remove(lastVertex);
}
finally
{
this.Lock.ExitWriteLock();
}
}
}
protected override void DrawCore(GeoCanvas canvas)
{
//Draws the line and update the distance text of the ruler.
Collection<SimpleCandidate> labelingInAllLayers = new Collection<SimpleCandidate>();
try
{
if (rulerLineShape != null)
{
Feature feature = new Feature(rulerLineShape);
double length = rulerLineShape.GetLength(GeographyUnit.DecimalDegree, DistanceUnit.Feet);
feature.ColumnValues.Add("length", ((int)length).ToString() + " feet");
Lock.EnterWriteLock();
{
if (TrackShapeLayer.InternalFeatures.Contains(currentFeatureKey))
{
TrackShapeLayer.InternalFeatures[currentFeatureKey] = feature;
}
else
{
TrackShapeLayer.InternalFeatures.Add(currentFeatureKey, feature);
}
}
Lock.ExitWriteLock();
}
TrackShapeLayer.Open();
TrackShapeLayer.Draw(canvas, labelingInAllLayers);
canvas.Flush();
}
finally
{
TrackShapeLayer.Close();
}
}
}
}
but it is not calculating distance...