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