The map view can be panned interactively by dragging it with the mouse. The user can also zoom into or out of the map via the mouse wheel. To implement a different scroll or zoom interaction logic, you can use the properties and methods exposed by MapView from various input event handlers. In order to change the scroll position, call the ScrollTo method. In order to change the zoom level, set the ZoomFactor property or call the SetZoomFactor method.
The following excerpt from the Markers sample project shows how to center the view on a specific decoration object:
C#
Copy Code
|
---|
mapView.ZoomFactor = 6;
// office is a reference to a DecorationBubble instance mapView.ScrollTo(office.Latitude, office.Longitude);
// focus is necessary in order to receive mouse wheel events mapView.Focus(); |
Zoom control
Zoom level and scroll position of
MapView can also be changed using the dedicated
ZoomControl widget. To set it up, add a
ZoomControl to the form, place it anywhere over a
MapView, and set the control's
Target property to that view. Set the
ZoomStep and
ScrollStep properties to specify the amount added to view's zoom level or scroll position by
ZoomControl's buttons. You can customize the control's appearance by setting properties such as
Fill,
BorderColor,
CornerRadius and
TickPosition.