/** * Creates the javascript of the layers that are going to be shown separatly. Each layer is an * object first is the raster layers then the vector layers. * * @param idsBaseLayers * @param idsExtraLayers * @return */ private String createSeparateLayerScript(int[] idsBaseLayers, int[] idsExtraLayers) { String layersScript = ""; Layer actualLayer = null; int layerCount = 0; String backgroundLayer = mapConfig.getProperty("backgroundLayer"); switch (backgroundLayer) { case "wms": // Read the background layer from xml file // add the layers that are the background. for (int i = 0; i < layersManager.getBackgroundLayers().size(); i++) { actualLayer = layersManager.getBackgroundLayers().get(i); if (actualLayer.getName() != null) { layersScript += layerHelper(actualLayer, layerCount, true); layerCount++; } // If layer not null } break; case "osm": // Add OpenStreetMap as the background layer layersScript += addOpenStreetMapLayer(layersScript, layerCount); layerCount++; break; case "binga": // Add Aerial Bing layer as the background layer layersScript += addBingLayer(layersScript, layerCount, "Aerial"); layerCount++; break; case "bingr": // Add Road Bing layer as the background layer layersScript += addBingLayer(layersScript, layerCount, "Road"); layerCount++; break; case "bingh": // Add Hybrid Bing layer as the background layer layersScript += addBingLayer(layersScript, layerCount, "AerialWithLabels"); layerCount++; break; case "mapquesta": // Add MapQuest as the background layer case "mapquestr": // Add MapQuest as the background layer case "mapquesth": // Add MapQuest as the background layer layersScript += addMapQuest(layersScript, layerCount, backgroundLayer); layerCount++; break; } // Generates the layer configuration for OpenLayers // The name of the layer variable inside OpenLayers is of the form layer'number of layer' for (int i = 0; i < idsBaseLayers.length; i++) { actualLayer = layersManager.getMainLayers().get(idsBaseLayers[i]); if (actualLayer.getName() != null) { layersScript += layerHelper(actualLayer, layerCount, true); layerCount++; } // If layer not null } for (int i = 0; i < layersManager.getVectorLayers().size(); i++) { actualLayer = layersManager.getVectorLayers().get(i); if (StringAndNumbers.intArrayContains( idsExtraLayers, i)) { // Si esta en los seleccionados lo mostramos // Si no no layersScript += layerHelper(actualLayer, layerCount, true); } else { layersScript += layerHelper(actualLayer, layerCount, false); } layerCount++; } return layersScript; }
/** Class constructor, it defines the file that will store the layers info */ public OpenLayersManager() throws XMLFilesException { this.layersManager = LayerMenuManagerSingleton.getInstance(); mapConfig = OpenLayerMapConfig.getInstance(); }