I would like to disable the rotation that is allowed by default when using trackmode.square . Is this possible?
Can you disable rotation on trackmode.square?
Hi Puthear,
If you don’t want to let it rotation, you can try to set the TrackMode = TrackMode.Rectangle.
Regards,
Don
I need a square not a rectangle. Is it possible to force a rectangle to have all equal sides when drawing on the map?
Hi Puthear,
We haven’t implemented that because if you want to create a square and disable it rotation, how you can make sure your mouse keep move follow in the diagonal extension cord?
The same reason, if you force make the rectangle keep equal sides, you will found your mouse cannot keep in correct vertex of the shape.
As below is how to implement that:
public class MyTrackInteractiveOverlay : TrackInteractiveOverlay
{
protected override BaseShape GetTrackingShapeCore()
{
BaseShape shape = base.GetTrackingShapeCore();
if (this.TrackMode == ThinkGeo.MapSuite.WpfDesktopEdition.TrackMode.Rectangle)
{
RectangleShape rect = shape.GetBoundingBox();
if (rect.Width != rect.Height)
{
double newWidth;
double newHeight;
if (rect.Width > rect.Height)
{
newWidth = newHeight = rect.Width;
}
else
{
newWidth = newHeight = rect.Height;
}
rect = new RectangleShape(rect.UpperLeftPoint, new PointShape(rect.UpperLeftPoint.X + newWidth, rect.UpperLeftPoint.Y - newHeight));
shape = rect;
}
}
return shape;
}
}
private void WpfMap_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.DecimalDegree;
Map1.CurrentExtent = new RectangleShape(-155.733, 95.60, 104.42, -81.9);
Map1.TrackOverlay = new MyTrackInteractiveOverlay();
Map1.TrackOverlay.TrackMode = TrackMode.Rectangle;
}
Regards,
Don
Thank you for the code it worked. Unfortunately it removes my ability to use the trackmode.rectangle as a rectangle too. I was able edit you code and can now use both the square without rotation and the rectangle as normal. Thanks again.
In case you interested here is the edited code.
public
class
MyTrackInteractiveOverlay : TrackInteractiveOverlay
{
protected
override
BaseShape GetTrackingShapeCore()
{
BaseShape shape =
base
.GetTrackingShapeCore();
if
(
this
.TrackMode == ThinkGeo.MapSuite.WpfDesktopEdition.TrackMode.Square)
{
RectangleShape rect = shape.GetBoundingBox();
rect =
new
RectangleShape(rect.UpperLeftPoint,
new
PointShape(rect.UpperLeftPoint.X + rect.Width, rect.UpperLeftPoint.Y - rect.Height));
shape = rect;
}
return
shape;
}
}
Hi Puthear,
Thanks for share your enhancement!
Any question please let us know.
Regards,
Don