ThinkGeo.com    |     Documentation    |     Premium Support

Zooming (shift) and Selecting (ctrl)

Hello,
Standard function is using shift and left mouse button to zoom in on a location.
I needed to be able to use ctrl and left mouse button to select using a rectangular and found code
‘MyExtentInteractiveOverlay’ and it works fine.
But now the zoom with shift functionality does not work anymore, because the selection functionality uses
the TrackZoomInKey as ctrl to work around the selection method.

How can I use both functionalities?

Kind regards,
Guido van den Boom

Hi Guido,

Thanks for your post - I’ll be glad to help.

To make sure we’re on the same page, can you send me a link to the code you found? Or post your code below so I know we’re looking at the same Overlay?

Thanks,
John

Hi John,

I don’t have the link, so I post the code below (translated from C#).
I hope you can help !

Kind regards,
Guido van den Boom

Private Sub mapView_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) Handles Me.Loaded
Me.ExtentOverlay = New MyExtentInteractiveOverlay(Me)
end sub

Class MyExtentInteractiveOverlay
Inherits ExtentInteractiveOverlay

Private mapView As MapView
Private trackStartScreenPoint As System.Windows.Point
Private trackEndScreenPoint As System.Windows.Point

Public Sub New(ByVal mapView As MapView)
    Me.mapView = mapView

. Me.TrackZoomInKey = System.Windows.Input.Key.LeftCtrl
End Sub

Protected Overrides Function MouseDownCore(ByVal interactionArguments As InteractionArguments) As InteractiveResult
    trackStartScreenPoint = New System.Windows.Point(interactionArguments.ScreenX, interactionArguments.ScreenY)
    Return MyBase.MouseDownCore(interactionArguments)
End Function

Protected Overrides Function MouseMoveCore(ByVal interactionArguments As InteractionArguments) As InteractiveResult
    Return MyBase.MouseMoveCore(interactionArguments)
End Function

Protected Overrides Function MouseUpCore(ByVal interactionArguments As InteractionArguments) As InteractiveResult
Dim result As InteractiveResult = MyBase.MouseUpCore(interactionArguments)
Dim bSelectionDirectionRight As Boolean = True
Dim SelectableShapes As InMemoryFeatureLayer = New InMemoryFeatureLayer()

    trackEndScreenPoint = New System.Windows.Point(interactionArguments.ScreenX, interactionArguments.ScreenY)

    If ExtentChangedType = ExtentChangedType.TrackZoomIn Then
        Me.mapView.EditOverlay.EditShapesLayer.InternalFeatures.Clear()

        If Math.Abs(trackStartScreenPoint.X - trackEndScreenPoint.X) > MinimumTrackZoomInExtentInPixels AndAlso Math.Abs(trackStartScreenPoint.Y - trackEndScreenPoint.Y) > MinimumTrackZoomInExtentInPixels Then
            Dim rotatedTrackStartScreenPoint = MapUtil.GetRotatedScreenPoint(trackStartScreenPoint.X, trackStartScreenPoint.Y, MapArguments.RotationAngle, MapArguments.PivotScreenPoint)
            Dim rotatedTrackEndScreenPoint = MapUtil.GetRotatedScreenPoint(trackEndScreenPoint.X, trackEndScreenPoint.Y, MapArguments.RotationAngle, MapArguments.PivotScreenPoint)
            Dim startPointInDegree As PointShape = MapArguments.ToWorldCoordinate(rotatedTrackStartScreenPoint)
            Dim endPointInDegree As PointShape = MapArguments.ToWorldCoordinate(rotatedTrackEndScreenPoint)
            Dim minX As Double = If(startPointInDegree.X < endPointInDegree.X, startPointInDegree.X, endPointInDegree.X)
            Dim maxX As Double = If(startPointInDegree.X < endPointInDegree.X, endPointInDegree.X, startPointInDegree.X)
            Dim minY As Double = If(startPointInDegree.Y < endPointInDegree.Y, startPointInDegree.Y, endPointInDegree.Y)
            Dim maxY As Double = If(startPointInDegree.Y < endPointInDegree.Y, endPointInDegree.Y, startPointInDegree.Y)
            Dim newCurrentExtent As RectangleShape = New RectangleShape(minX, maxY, maxX, minY)

’ Rest of the code in this function

Hi Guido,

Thanks for the example. I checked our code in the ExtentInteractiveOverlay and the TrackZoomKey is a single property and not a collection. It’s not possible to set multiple keys as the Track Zoom Key.

If this is a show-stopper and you absolutely need multiple keys, contact support@thinkgeo.com and we can discuss the options for helping you build a completely new and customized InteractiveOverlay that doesn’t inherit from ExtentInteractiveOverlay.

Thanks,
John

Hi John,

is there anywhere a complete sample for TrackZoomIn in Version 13/14?
I had it working in Version 9 but somehow cannot get it to work in the new versions.

Thank you.
Peter

I’ve figured it out on my own.

But is it right, that when I want to Pan as standard operation for the left mouse button and TrackZoomIn when the left control key is pressed, I’ve to set the following properties?

MapView.ExtentOverlay.TrackZoomInKey = Key.LeftCtrl;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.Left;

And when I want to set TrackZoomIn as standard für the left mouse button the following?

MapView.ExtentOverlay.TrackZoomInKey = Key.None;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.Left;

So setting the TrackZoomInKey to None enables TrackZoomIn as standard operation for the defined mouse button?
That does not really seems to be very intuitive.
A bit more documentation or a sample would surely be highly appreciated by many.

Thank your for your support.

Regards,
Peter

Hi Peter,

You are right, it’s not intuitive, setting TrackZoomInKey to None should just disable the TrackZoomIn. This issue has been fixed in the latest Beta, please pull the latest (v14.2 - Beta034) and have another try.

Thanks,
Ben

Hello Ben,

thank your for your answer.

Now it is easy (in v14.3.0-beta007) to enable TrackZoomIn when (e.g.) the left Ctrl key is pressed:

MapView.ExtentOverlay.TrackZoomInKey = Key.LeftCtrl;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.Left;

But how do I now enable TrackZoomIn using the left mouse button without (!) the need to hold a key pressed?

I thought it would work like this:

MapView.ExtentOverlay.TrackZoomInKey = Key.None;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.Left;

But setting the key to None just disables TrackZoomIn completely.

Thank you in preface.

Regards,
Peter

Hi Peter,

I thought it through and I restored it to 8/16 version. Now in the latest beta:

To pan with the left mouse button and TrackZoomIn when the left control key is pressed:

MapView.ExtentOverlay.TrackZoomInKey = Key.LeftCtrl;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.Left;

To track zoom in without having to hold a key:

MapView.ExtentOverlay.TrackZoomInKey = Key.None;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.Left;

To Disable the TrackZoomIn:

MapView.ExtentOverlay.TrackZoomInKey = Key.None;
MapView.ExtentOverlay.TrackZoomInMouseButton = MapMouseButton.None;

I think the confusing part is setting TrackZoomInKey = Key.None means keys doesn’t matter for tracking zoom in, while setting TrackZoomInMouseButton = MapMouseButton.None means trackZoomIn doesn’t work at all. I think that makes sense though as we might need to track zoom in without holding a key, but we can never track zooming in with only keys.

Let me know if that makes sense.

Thanks,
Ben

Hi Ben,

now it works as advertised.
Thank you.

Regards,
Peter

No problem! let us know if you see any other issues.