* objects.
*/
MapPanel mapPanel = new BasicMapPanel();
// Get the default MapHandler the BasicMapPanel created.
MapHandler mapHandler = mapPanel.getMapHandler();
mapHandler.add(frame);
// Get the default MapBean that the BasicMapPanel created.
MapBean mapBean = mapPanel.getMapBean();
// Set the map's center
mapBean.setCenter(new LatLonPoint(43.0f, -95.0f));
// Set the map's scale 1:120 million
mapBean.setScale(120000000f);
/*
* Create and add a LayerHandler to the MapHandler. The
* LayerHandler manages Layers, whether they are part of
* the map or not. layer.setVisible(true) will add it to
* the map. The LayerHandler has methods to do this, too.
* The LayerHandler will find the MapBean in the
* MapHandler.
*/
mapHandler.add(new LayerHandler());
// Add a route layer.
RouteLayer routeLayer = new RouteLayer();
routeLayer.setVisible(true);
// The LayerHandler will find the Layer in the MapHandler.
/*
* Create a ShapeLayer to show world political boundaries.
* Set the properties of the layer. This assumes that the
* datafiles "dcwpo-browse.shp" and "dcwpo-browse.ssx" are
* in a path specified in the CLASSPATH variable. These
* files are distributed with OpenMap and reside in the
* toplevel "share" subdirectory.
*/
ShapeLayer shapeLayer = new ShapeLayer();
// Since this Properties object is being used just for
// this layer, the properties do not have to be scoped
// with marker name, like the layer properties in the
// ../hello/HelloWorld.properties file.
Properties shapeLayerProps = new Properties();
shapeLayerProps.put("prettyName", "Political Solid");
shapeLayerProps.put("lineColor", "000000");
shapeLayerProps.put("fillColor", "BDDE83");
shapeLayerProps.put("shapeFile", "data/shape/dcwpo-browse.shp");
shapeLayerProps.put("spatialIndex", "data/shape/dcwpo-browse.ssx");
shapeLayer.setProperties(shapeLayerProps);
shapeLayer.setVisible(true);
// Last on top.
mapHandler.add(shapeLayer);
mapHandler.add(new GraticuleLayer());
mapHandler.add(routeLayer);
// Create the directional and zoom control tool
OMToolSet omts = new OMToolSet();
// Create an OpenMap toolbar
ToolPanel toolBar = new ToolPanel();
/*
* Add the ToolPanel and the OMToolSet to the MapHandler.
* The OpenMapFrame will find the ToolPanel and attach it
* to the top part of its content pane, and the ToolPanel
* will find the OMToolSet and add it to itself.
*/
mapHandler.add(omts);
mapHandler.add(toolBar);
// Display the frame
frame.setVisible(true);
} catch (MultipleSoloMapComponentException msmce) {
// The MapHandler is only allowed to have one of certain