The source code for the Map Builder demonstration, which contains
all of the code described in this section, can be found at <installdir> /jviews-maps89/samples/mapbuilder/index.html.
The IlvAbstractBaseGrid class
The IlvAbstractBaseGrid base class has
subclasses IlvMGRSGrid and IlvLatLonGrid. It is a manager layer that,
instead of drawing graphic objects (
IlvGraphic
instances) added to it, displays a grid adapted to the current
zoom level of the map.
This base grid also implements the IlvManagerViewDecoration interface, which
allows you to display the grid on the screen, but prevents it
from being displayed on printed material.
The IlvMGRSGrid class
The IlvMGRSGrid class displays a set of
auto-adaptive MGRS standard grids and labels on top of a
geographic view. This grid displays a list of Grid zones (either
UPS or UTM zones), and their sub grids (100000m,
10000m, 1000m). Each grid or sub-grid is labeled using the
standardized MGRS name for the current area.
You can create and add an MGRS grid on any geo-referenced manager
view (that is, any view that supports the IlvCoordinateSystemProperty). For example,
to add an MGRS grid containing all MGRS zones as a decoration of
the view:
IlvMGRSGrid grid = new IlvMGRSGrid(); IlvMGRSGridZone.addAllZones(grid); view.addViewDecoration(grid);
The IlvLatLonGrid class
The IlvLatLonGrid class displays a set of
auto-adaptive grids and labels along latitude or longitude lines
on top of a geographic view. If the grid is auto-adaptive, the
step between each successive lat/lon line is dependant on the
scale of the current view.
You can create and add an MGRS grid on any geo-referenced manager
view (that is, any view that supports the IlvCoordinateSystemProperty). For example,
to create a lat/lon grid layer:
view.getManager().addLayer(new IlvLatLonGrid()-1);
By default, the IlvLatLonGrid creates only the points at
the corners of each grid square. If you are using a coordinate
system that transforms the map in a non-linear way (such as
Orthographic projection, UTM projection, and so on), you can
increase the number of intermediate points on each grid square in
order to show a smoother version of the grid:
lgrid.setSmoothness(4);
Writing specific grids
The easiest way to implement your own grid system is to start
with an empty MGRS grid and then add your own zones to it. For
examples of this, see the Map Builder
GridManager
class.
Integrating grids into map layers
As the grids are implemented as manager layers, you only need to
connect these to an IlvMapLayer.
This map layer must be created, styled and
integrated in the map layer tree model:
IlvMapLayerTreeModel ltm = IlvMapLayerTreeProperty.GetMapLayerTreeModel(view.getManager()); IlvMapLayer mapInsertionLayer = new IlvMapLayer(); mapInsertionLayer.setStyle(new IlvGridStyle()); ltm.addChild(null, mapInsertionLayer);
Then you can integrate the grid manager
layer into it:
mapInsertionLayer.insert(grid);
You can also use an IlvDelayedDecoration manager layer to
encapsulate the grid. Whenever the user moves or zooms the grid
rapidly, a simplified version of the grid is used, which displays
more quickly. When the user stops moving or zooming the grid, the
full grid is displayed:
IlvDelayedDecoration delayedGrid = new IlvDelayedDecoration(200); delayedGrid.setDecoration(grid); mapInsertionLayer.insert(delayedGrid);
The IlvGridStyle class
The IlvGridStyle class is used when displaying
grids. It defines the following attributes:
Property
name |
Content |
---|---|
GRID_COLOR |
The
Color
used to display grid lines.
|
TEXT_FONT |
The
Font
of grid labels.
|
TEXT_COLOR |
The
Color
used to display grid labels.
|
OUTLINE_COLOR |
The
Color
of the outline of the grid labels.
|