Re: [OpenMap Users] Setting Visibility of Terrain Data Layers

From: Don Dietrick <dietrick_at_bbn.com>
Date: Thu, 15 Nov 2007 16:05:17 -0500

Hi Marc,

I'd add a LayerHandler to the MapPanel, and call
layerHandler.turnLayerOn(...) to turn layers on or off for you. The
LayerHandler will set the visibility on the layers, and also add/remove
layers appropriately from the MapBean.

Hope this helps,

- Don


Marc A Criley wrote:
> I want to give users the opportunity to change the type of terrain data
> they want to view,
> so far either ESRI shape data or DTED. Right now the terrain data is
> controlled by a command
> line option that initializes the map with one format or the other. This
> works perfectly fine.
>
> Here's excerpts from the relevant parts:
>
> // Set up the projection:
>
> MapBean mapBean = mapPanel.getMapBean();
>
> if (dtedRequested) {
> mapBean.setProjection(new CADRG(new LatLonPoint(defaultLat,
> defaultLon), 1500000.0F, mapWidth,
> mapHeight));
> } else {
> mapBean.setProjection(new Orthographic(new LatLonPoint(defaultLat,
> defaultLon), 1500000.0F, mapWidth,
> mapHeight));
> }
>
>
> // DTED Terrain display
> dtedLayer = new DTEDLayer(dtedPaths) {
> public synchronized MapMouseListener getMapMouseListener() {
> return mapConsoleMouseListener;
> }
> };
> dtedLayer.setDtedLevel(1);
> dtedLayer.setVisible(dtedRequested);
> mapHandler.add(dtedLayer);
>
>
> // ESRI Shape Terrain display
> esriShapeLayer = new ShapeLayer() {
> public synchronized MapMouseListener getMapMouseListener() {
> return mapConsoleMouseListener;
> }
> };
>
> Properties esriShapeLayerProps = new Properties();
>
> // Various properties setting, not particular to this question...
>
> esriShapeLayer.setProperties(esriShapeLayerProps);
> esriShapeLayer.setVisible(!dtedRequested);
> mapHandler.add(esriShapeLayer);
>
>
> Like I said, this all sets up and runs just fine with dtedRequested coming
> in as either true or false.
>
>
> Now what I _thought_ I could do, to change formats, was just change the
> projection, since DTED requires CADRG and then call the layers'
> setVisible()
> functions:
>
> public void setTerrainFormat(TerrainFormats terrainFormat) {
> MapBean mapBean = mapPanel.getMapBean();
> float currentScale = mapBean.getScale();
> LatLonPoint currentLoc = new LatLonPoint(mapBean.getCenter());
>
> // Hide all terrain layers, so that only the selected one gets
> turned
> // back on.
> esriShapeLayer.setVisible(false);
> dtedLayer.setVisible(false);
>
> switch (terrainFormat) {
> case ESRI_SHAPE:
> mapBean.setProjection(new Orthographic(currentLoc,
> currentScale,
> mapWidth, mapHeight));
> esriShapeLayer.setVisible(true);
> break;
> case DTED:
> mapBean.setProjection(new CADRG(currentLoc, currentScale,
> mapWidth,
> mapHeight));
> dtedLayer.setVisible(true);
> break;
> }
> }
>
>
> What happens though when I invoke setTerrainFormat is the terrain data
> simply disappears,
> i.e. the setVisible(false) calls seems to take effect, but the selected
> layer doesn't get
> shown by setVisible(true).
>
> Maybe I'm missing something fundamental here, since I've haven't been
> using OpenMap for
> very long, but it's doing a great job with meeting the needs, and I
> haven't really run
> into any roadblocks yet.
>
> Thanks for any suggestions,
>
> Marc A. Criley
> Member, Senior Technical Staff
> Cohesion Force, Inc.
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message "unsubscribe openmap-users"]
>

--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Nov 15 2007 - 16:06:21 EST

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:08 EDT