skip to main content
Defense > Programmer's documentation > Programming with JViews Maps > Creating a map application using the API > Map GUI interactors
 
Map GUI interactors
The source code for the Map Builder demonstration, which contains all of the code described in this section, can be found at <installdir> /jviews-maps/samples/mapbuilder/index.html
Pan
The IlvMapPanInteractor allows the user to pan a manager view by pressing and holding the space key. Once installed, it is always available.
To create this interactor and attach it to a IlvManagerView, you can use the following code:
 
IlvManagerView view = ...
...
IlvMapPanInteractor pan = new IlvMapPanInteractor();
pan.setView(view);
Zoom rectangle
The IlvMapZoomInteractor allows the user to select and zoom in on a rectangle in a manager view. The Zoom Rectangle interactor includes the Zoom In and Zoom Out interactors. It also provides simple click zoom and unzoom interactions.To create this interactor, you can use the following code:
 
IlvMapZoomInteractor interactor = new IlvMapZoomInteractor();
view.setInteractor(interactor);
Continuous zoom
The IlvContinuousZoomInteractor allows the user to continuously zoom into or out from a map by pressing and holding a mouse button. The zoom center, that is, the point in a map that will be zoomed on, is the point in the map where the mouse is clicked. By default, pressing the left button zooms into the zoom center, pressing the right mouse button zooms out from the zoom center. When you drag the mouse the current zoom activity is paused and the map is panned to follow mouse displacement.
This interactor also redirects mouse wheel actions. After this interactor is activated, the user scrolls the mouse wheel backwards to zoom in, and forwards to zoom out.
The delay and zoom factor can be configured for each interactor instance.
 
IlvContinuousZoomInteractor interactor = new IlvContinuousZoomInteractor();
interactor.setContinuousZoomFactor(factor);
interactor.setPeriod(period);
view.setInteractor(interactor);
To activate this interactor, use the following code:
Rotate
The IlvManagerViewRotateInteractor allows the user to rotate the entire content of a manager view. Various modes are available, such as immediate rotation, delayed rotation, and key controlled rotation.
To create this interactor, you can use the following code:
 
IlvManagerView view = …;
...
IlvManagerViewRotateInteractor interactor = new
   IlvManagerViewRotateInteractor();
interactor.setMode(IlvManagerViewRotateInteractor.DYNAMIC_CONTINUOUS_MODE);
view.setInteractor(interactor);
Distance measuring
The IlvMakeMeasureInteractor allows the user to draw a line on a map in a manager view and automatically display the distance represented by the line on the map.
 
final IlvMakeMeasureInteractor measure = new IlvMakeMeasureInteractor();
 JButton b = new JButton();
    b.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        view.setInteractor(measure);
      }
    });
To create a IlvMakeMeasureInteractoryou can use the following code:

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.