map.js


function init() {
<!-- ESRIMap DIV -->

//var aField=new Array();

//var allFeatureUrl = new Array();//存放所有layer
//var allRasterUrl = new Array();//存放所有layer

//var allRasterId = new Array();//存放所有栅格layer的ID与养分下拉框对应
//var allFeatureId = new Array();//存放所有矢量layer的ID与养分下拉框对应
var initExtent = new esri.geometry.Extent({"spatialReference":{"wkid":102100}});
app.map = new esri.Map("map",
{
center:[118.1,37],
zoom: 8
});

app.Street = new esri.layers.ArcGISTiledMapServiceLayer("http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer",
{ id: "街道地图" });
app.Street.setVisibility(false);
app.map.addLayer(app.Street);

app.Image = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
{ id: "影像" });
app.map.addLayer(app.Image);

//var allRasterLayer = new Array();
for(i = 0;i < aField.length;i++){

allRasterLayer[i] = new esri.layers.ArcGISDynamicMapServiceLayer(allRasterUrl[i],{ id: allRasterId[i] });
allRasterLayer[i].setVisibility(false);

}
for(i = 0;i < aField.length;i++){

allFeatureLayer[i] = new esri.layers.ArcGISDynamicMapServiceLayer(allFeatureUrl[i],{ id: allFeatureId[i] });
allFeatureLayer[i].setVisibility(false);
}

<!-- ESRIMap DIV End -->
}
//切换为影像底图
function toImage(){
app.Image.setVisibility(true);
app.Street.setVisibility(false);
}
//切换为街道底图
function toStreet(){
app.Street.setVisibility(true);
app.Image.setVisibility(false);
}
//显示要进行点级查询的图层,将其他图层关闭
function searchRaster(){
var field = document.getElementById('optRasterField')[document.getElementById('optRasterField').selectedIndex].value;
layerType = "Raster";
for(var j = 0; j < allFeatureLayer.length; j++) {
allFeatureLayer[j].setVisibility(false);
app.map.removeLayer(allFeatureLayer[j]);
}
for(var j = 0; j < aField.length; j++) {
if(allRasterLayer[j].id != field){
allRasterLayer[j].setVisibility(false);
app.map.removeLayer(allRasterLayer[j]);
}else{
if(!allRasterLayer[j].visible){
app.map.addLayer(allRasterLayer[j]);
allRasterLayer[j].setVisibility(true);
//app.map.setExtent(allRasterLayer[j].fullExtent);
document.getElementById("currentRasterLayer").innerHTML = "栅格图层:"+field;
document.getElementById("currentFeatureLayer").innerHTML = "栅格图层:"+field;
}else{
allRasterLayer[j].setVisibility(false);
app.map.addLayer(allRasterLayer[j]);
allRasterLayer[j].setVisibility(true);
}
}
}
//开始查询
//将以前与map onClick绑定的事件清除
if(typeof(app.map.onClick) != "undefined"){
app.map.onClick = null;
}
//resultArray清空
resultArray = [];
document.getElementById("columnChartPlot").innerText = "";
identify( app.map.getLayer(app.map.layerIds[2]) );
dojo.byId("columnChart").style.display = "block";
}
function searchFeature(){
var field = document.getElementById('optFeatureField')[document.getElementById('optFeatureField').selectedIndex].value;
layerType = "Feature";
for(var j = 0; j < allRasterLayer.length; j++) {
//栅格不可见并移除
allRasterLayer[j].setVisibility(false);
app.map.removeLayer(allRasterLayer[j]);
}
for(var j = 0; j < aField.length; j++) {
if(allFeatureLayer[j].id != field){
//不是要显示的矢量 不可见、移除
allFeatureLayer[j].setVisibility(false);
app.map.removeLayer(allFeatureLayer[j]);
}else{
//是要显示的矢量
if(!allFeatureLayer[j].visible){
//不可见 添加,可见
app.map.addLayer(allFeatureLayer[j]);
allFeatureLayer[j].setVisibility(true);
document.getElementById("currentRasterLayer").innerHTML = "矢量图层:" +field;
document.getElementById("currentFeatureLayer").innerHTML = "矢量图层:"+field;
}else{
//已可见
allFeatureLayer[j].setVisibility(false);
app.map.addLayer(allFeatureLayer[j]);
allFeatureLayer[j].setVisibility(true);
}
}
}
//开始查询
//将以前与map onClick绑定的事件清除
if(typeof(app.map.onClick) != "undefined"){
app.map.onClick = null;
}
//resultArray清空
resultArray = [];
document.getElementById("columnChartPlot").innerText = "";
dojo.byId("columnChart").style.display = "block";
identify( app.map.getLayer(app.map.layerIds[2]) );
}
function getShowPointLayerNameId(){
return
}
function zoomTo(){
app.map.setExtent(app.map.getLayer(app.map.layerIds[2]).fullExtent);
}
function clearLayer(){

//将与map onClick绑定的事件清除
if(typeof(app.map.onClick) != "undefined"){
app.map.onClick = null;
}
app.map.getLayer(app.map.layerIds[2]).setVisibility(false);
app.map.removeLayer(app.map.getLayer(app.map.layerIds[2]));
document.getElementById("currentRasterLayer").innerHTML = "空";
document.getElementById("currentFeatureLayer").innerHTML = "空";
dojo.byId("columnChart").style.display = "none";
}

posted on 2013-08-11 19:22  Felixlovechina  阅读(265)  评论(0编辑  收藏  举报

导航