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