📄 layercatalog.java
字号:
package com.esri.arcgis.webcontrols.test;
import com.esri.arcgis.webcontrols.ags.data.*;
import java.util.*;
import java.io.*;
import javax.faces.model.SelectItem;
import com.esri.arcgis.carto.*;
public class LayerCatalog {
//change the path to where you store the file.
private static String CATALOG_FILE = "com/esri/arcgis/webcontrols/test/catalog.properties";
AGSWebContext agsContext;
//layerName - shape file
LinkedHashMap availableLayers = new LinkedHashMap();
{
try {
InputStream stream = this.getClass().getClassLoader().getResourceAsStream(CATALOG_FILE);
Properties props = new Properties();
props.load(stream);
String name;
for(Enumeration e = props.propertyNames(); e.hasMoreElements();) {
name = (String)e.nextElement();
availableLayers.put(name, new File(props.getProperty(name)));
}
}
catch(Exception _) {
throw new IllegalStateException("Cannot load layer catalog.\n\t" + _);
}
}
ArrayList addLayerNames;
ArrayList addLayerIndices;
public LayerCatalog(AGSWebContext agsContext) {
this.agsContext = agsContext;
}
public Collection getAddLayerNames() {
if(addLayerNames != null)
return addLayerNames;
addLayerNames = new ArrayList();
for (Iterator iter = availableLayers.keySet().iterator(); iter.hasNext(); )
addLayerNames.add(new SelectItem(iter.next()));
return addLayerNames;
}
public Collection getAddLayerIndices() {
if(addLayerIndices != null)
return addLayerIndices;
fetchLayerIndices();
return addLayerIndices;
}
private void fetchLayerIndices() {
addLayerIndices = new ArrayList();
int layerCount = 1;
try {
IMapServer server = agsContext.getServer();
AGSWebMap agsMap = (AGSWebMap) agsContext.getWebMap();
layerCount = server.getServerInfo(agsMap.getFocusMapName()).getMapLayerInfos().getCount();
}
catch(Exception _) { layerCount = 1; }
for(int i = 0; i <= layerCount; ++i) {
if(i == 0)
addLayerIndices.add(new SelectItem(new Integer(i), "Top"));
else if(i == layerCount)
addLayerIndices.add(new SelectItem(new Integer(i), "Bottom"));
else
addLayerIndices.add(new SelectItem(new Integer(i), "Top + " + i));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -