Hi, Nirish
We don’t have RestrictedExtent property in our Silverlight edition product. However, we provide users with more flexibility to implement their requeirments in our products. Maybe you could implement it easily through inheriting ExtentInteractiveOverlay. The code likes below:
public class RestrictedExtentInteractiveOverlay : ExtentInteractiveOverlay {
private bool isDragging;
public RectangleShape RestrictedExtent { get; set; }
protected override InteractiveResult MouseDownCore(InteractionArguments interactionArguments) {
isDragging = true;
return base.MouseDownCore(interactionArguments);
}
protected override InteractiveResult MouseUpCore(InteractionArguments interactionArguments) {
isDragging = false;
return base.MouseUpCore(interactionArguments);
}
protected override InteractiveResult MouseMoveCore(InteractionArguments interactionArguments) {
if (isDragging) {
double offsetWidth = interactionArguments.CurrentExtent.Width * .5;
double offsetHeight = interactionArguments.CurrentExtent.Height * .5;
double rleft = RestrictedExtent.UpperLeftPoint.X + offsetWidth;
double rtop = RestrictedExtent.UpperLeftPoint.Y - offsetHeight;
double rright = RestrictedExtent.LowerRightPoint.X - offsetWidth;
double rbottom = RestrictedExtent.LowerRightPoint.Y + offsetHeight;
if (rleft >= rright || rtop <= rbottom) {
return new InteractiveResult();
}
PointShape currentCenter = interactionArguments.CurrentExtent.GetCenterPoint();
RectangleShape newCenterRestrictExtent = new RectangleShape(rleft, rtop, rright, rbottom);
if (!newCenterRestrictExtent.Contains(currentCenter)) {
InteractiveResult result = base.MouseMoveCore(interactionArguments);
//InteractiveResult result = new InteractiveResult();
PointShape newCenter = currentCenter;
PointShape restrictCenter = newCenterRestrictExtent.GetCenterPoint();
double offsetX = currentCenter.X - restrictCenter.X;
double offsetY = currentCenter.Y - restrictCenter.Y;
if (Math.Abs(offsetX) > newCenterRestrictExtent.Width * .5) {
if (offsetX < 0) {
newCenter.X = RestrictedExtent.UpperLeftPoint.X + offsetWidth;
}
else {
newCenter.X = RestrictedExtent.LowerRightPoint.X - offsetWidth;
}
}
if (Math.Abs(offsetY) > newCenterRestrictExtent.Height * .5) {
if (offsetY < 0) {
newCenter.Y = RestrictedExtent.LowerRightPoint.Y + offsetHeight;
}
else {
newCenter.Y = RestrictedExtent.UpperRightPoint.Y - offsetHeight;
}
}
result.NewCurrentExtent = new RectangleShape(newCenter.X - offsetWidth, newCenter.Y + offsetHeight, newCenter.X + offsetWidth, newCenter.Y - offsetHeight);
return result;
}
else {
return base.MouseMoveCore(interactionArguments);
}
}
return new InteractiveResult();
}
protected override InteractiveResult MouseWheelCore(InteractionArguments interactionArguments) {
int restrictedZoomId = MapInfo.GetClosestZoomLevelIdFromScale(ExtentHelper.GetScale(RestrictedExtent, MapInfo.Width, GeographyUnit.DecimalDegree));
int zoomLevel = MapInfo.CurrentZoomLevelId;
if (interactionArguments.MouseWheelDelta <= 0) {
zoomLevel--;
}
else {
zoomLevel++;
}
if (zoomLevel >= restrictedZoomId) {
double deltaX = interactionArguments.MapWidth * .5 - interactionArguments.ScreenX;
double deltaY = interactionArguments.ScreenY - interactionArguments.MapHeight * .5;
double newResolution = MapInfo.GetResolutionFromZoomLevelId(zoomLevel);
PointShape centerWorldCoordinate = MapInfo.ToWorldCoordinate(interactionArguments.ScreenX, interactionArguments.ScreenY);
centerWorldCoordinate.X += deltaX * newResolution;
centerWorldCoordinate.Y += deltaY * newResolution;
MapInfo.ZoomTo(centerWorldCoordinate, zoomLevel);
return new InteractiveResult();
}
else {
return new InteractiveResult();
}
}
}
And then you need to add this InteractiveOverlay to map control, the code likes below:
RestrictedExtentInteractiveOverlay roverlay = new RestrictedExtentInteractiveOverlay();
roverlay.RestrictedExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);
Map1.ExtentInteractiveOverlay = null;
Map1.InteractiveOverlays.Add(roverlay);
If you still have any problem please let me know.
Thanks,
Khalil