⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 esri_edit.js

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JS
📖 第 1 页 / 共 4 页
字号:
  hiddenOnlyIds[3] = "lastOID";
  
  var reshapeIds =new Array();
  reshapeIds[0]="addVertex";
  reshapeIds[1]="moveVertex";
  reshapeIds[2]="deleteVertex";

  var newFeatureIds =new Array();
  newFeatureIds[0]="addPoint";
  newFeatureIds[1]="addPolygon";
  newFeatureIds[2]="addPolyline";

  var newFeatureShapeTypes =new Array();
  newFeatureShapeTypes[0]="POINT";
  newFeatureShapeTypes[1]="POLYGON";
  newFeatureShapeTypes[2]="LINE";
  
  var indexSelect = document.getElementById("indexSelect");
  if(indexSelect){
    indexSelect.innerHTML="";
  }
  if(message){
    message.innerHTML=xml.getAttribute("message");
  }
  
  
  showLayerList(xml.getElementsByTagName("EditLayers").item(0));
  configBeanHandler(xml.getElementsByTagName("ConfigBean").item(0));
  
  for(var ind=0; ind< newFeatureIds.length; ind++){
     var addfeature = document.getElementById(newFeatureIds[ind]);
     if(addfeature){
       if(xml.getAttribute("shape") == newFeatureShapeTypes[ind]){
         addfeature.removeAttribute(styleClass);
         addfeature.removeAttribute("disabled");
       } else {
         addfeature.setAttribute(styleClass, "hiddenButton");
         addfeature.setAttribute("disabled", true);
       }
     }
  }

  if(xml.getAttribute("selected") == "true"){
     for(var ind=0; ind< ids.length; ind++){
       var elem = document.getElementById(ids[ind]);
       if(elem){
         if(shapeTypes[ind] == "" || xml.getAttribute("shape") == shapeTypes[ind]){
           elem.removeAttribute(styleClass);
           elem.removeAttribute("disabled");
         }
       }
     }
     if(attsDiv){
       attsDiv.innerHTML="";
       attsDiv.setAttribute(styleClass,"attributesPanel");
       self.showSelectedAttributes(xml,attsDiv);
     }
  }else{
     for(var ind=0; ind< ids.length; ind++){
       var elem = document.getElementById(ids[ind]);
       if(elem){
          elem.setAttribute(styleClass, "disabledButton");
          elem.setAttribute("disabled", true);
       }
     }
     for(var ind=0; ind< hiddenOnlyIds.length; ind++){
       var elem = document.getElementById(hiddenOnlyIds[ind])
       if(elem){
         elem.setAttribute(styleClass, "hiddenButton");
       }
     }
     if(attsDiv){
       attsDiv.innerHTML = editorNullFeatureMessage;
       attsDiv.setAttribute(styleClass,"noAttributesPanel");
     }
  }
  
  var notpoint = document.getElementById("showVertices");
  if(notpoint && xml.getAttribute("shape")=="POINT"){
    notpoint.setAttribute(styleClass, "hiddenButton");
  }
  
  for(var ind=0; ind< ids.length; ind++){
    var elem = document.getElementById(ids[ind]);
    if(elem){
      if(shapeTypes[ind] != "" && xml.getAttribute("shape") != shapeTypes[ind]){
          elem.setAttribute(styleClass, "hiddenButton");
          elem.setAttribute("disabled", true);
      }
    }
  }

  var item = document.getElementById("undo");
  if(item){
    if(xml.getAttribute("undo") == "true"){
       item.removeAttribute(styleClass);
       item.removeAttribute("disabled");
    }else{
       item.setAttribute(styleClass, "disabledButton");
       item.setAttribute("disabled", true);
    }
  }
  
  item = document.getElementById("redo");
  if(item){
    if(xml.getAttribute("redo") == "true"){
       item.removeAttribute(styleClass);
       item.removeAttribute("disabled");
    }else{
       item.setAttribute(styleClass, "disabledButton");
       item.setAttribute("disabled", true);
    }
  }

  if(xml.getAttribute("shape") == "POINT"){
     for(var ind=0; ind< reshapeIds.length; ind++){
       var elem = document.getElementById(reshapeIds[ind]);
       if(elem){
         elem.setAttribute(styleClass, "hiddenButton");
         elem.setAttribute("disabled", true);
       }
     }
  } else {
    if(xml.getAttribute("vertices") == "true"){
     for(var ind=0; ind< reshapeIds.length; ind++){
       var elem = document.getElementById(reshapeIds[ind]);
       if(elem){
         elem.removeAttribute(styleClass);
         elem.removeAttribute("disabled");
       }
     }
    }else{
     for(var ind=0; ind< reshapeIds.length; ind++){
       var elem = document.getElementById(reshapeIds[ind]);
       if(elem){
         elem.setAttribute(styleClass, "disabledButton");
         elem.setAttribute("disabled", true);
       }
     }    
    }
  }
}

/* Process postback xml response and update content */
function configBeanHandler(xml) {
  if(!xml){
    return;
  }
  showSnapRules(document.getElementById(editSnappingRulesDiv),xml);
  updateSnapStatus(xml);  
}

function updateSnapStatus(xml){
  var snapEnabled = document.getElementById(snapEnabledId);
  if(snapEnabled){
    snapEnabled.setAttribute("value", xml.getAttribute("snapEnabled"));
  }
}

function showSnapRules(rulesDiv, xml){
  if(!rulesDiv){
    return;
  }
  
  var oldtable = document.getElementById("editorSnapRulesTable");
  if(oldtable){
    rulesDiv.removeChild(oldtable);
  }

  var table = document.createElement("table");
  
  table.setAttribute("id","editorSnapRulesTable");
  
  var thead = document.createElement("thead");
  var tr=document.createElement("tr");
  var td = document.createElement("td");
  var text = document.createTextNode("");
  td.appendChild(text);
  tr.appendChild(td);

  td = document.createElement("td");
  text = document.createTextNode("Vertex");
  td.appendChild(text);
  tr.appendChild(td);
  
  td = document.createElement("td");
  text = document.createTextNode("Edge");
  td.appendChild(text);
  tr.appendChild(td);

  td = document.createElement("td");
  text = document.createTextNode("End");
  td.appendChild(text);
  tr.appendChild(td);
  
  thead.appendChild(tr);
  table.appendChild(thead);
  
  var rules = xml.getElementsByTagName("SnapRules");
  var tbody = document.createElement("tbody");
  
  var isIE = EsriUtils.isIE;

  for(var k = 0; k < rules.length; k++) {
    var rule = rules[k];
    tr = document.createElement("tr");
    
    td = document.createElement("td");
    text = document.createTextNode(rule.getAttribute("layer"));
    td.appendChild(text);
    tr.appendChild(td);
    
    td = document.createElement("td");
    
    var input;
    if (isIE){
      if(rule.getAttribute("vertex") == "true"){
        input = td.appendChild(document.createElement("<input type=\"checkbox\" checked=\"checked\" />"));
      }else{
        input = td.appendChild(document.createElement("<input type=\"checkbox\"/>"));
      }
    }else {
      input = td.appendChild(document.createElement("input"));
      input.type = "CHECKBOX";
      input.checked = (rule.getAttribute("vertex") == "true");
    }
    input.setAttribute("type","checkbox");
    input.setAttribute("id",rule.getAttribute("id")+"_vertex");
    input.setAttribute("name",rule.getAttribute("id"));
    input.setAttribute("value",rule.getAttribute("vertex"));
    if(rule.getAttribute("vertex") != "true"){
      input.checked = false;
    }
    input.onclick=function(){updateSettingsRequest("vertex",this.value,this.name);}
    tr.appendChild(td);

    td = document.createElement("td");
    
    if (isIE){
      if(rule.getAttribute("edge") == "true"){
        input = td.appendChild(document.createElement("<input type=\"checkbox\" checked=\"checked\" />"));
      }else{
        input = td.appendChild(document.createElement("<input type=\"checkbox\"/>"));
      }
    }else {
      input = td.appendChild(document.createElement("input"));
      input.type = "CHECKBOX";
      input.checked = (rule.getAttribute("edge") == "true");
    }
    input.setAttribute("id",rule.getAttribute("id")+"_edge");
    input.setAttribute("name",rule.getAttribute("id"));
    input.setAttribute("value",rule.getAttribute("edge"));
    
    input.onclick=function(){updateSettingsRequest("edge",this.value,this.name);}
    tr.appendChild(td);

    td = document.createElement("td");
    if (isIE){
      if(rule.getAttribute("end") == "true"){
        input = td.appendChild(document.createElement("<input type=\"checkbox\" checked=\"checked\" />"));
      }else{
        input = td.appendChild(document.createElement("<input type=\"checkbox\"/>"));
      }
    }else {
      input = td.appendChild(document.createElement("input"));
      input.type = "CHECKBOX";
      input.checked = (rule.getAttribute("end") == "true");
    }
    input.setAttribute("id",rule.getAttribute("id")+"_end");
    input.setAttribute("name",rule.getAttribute("id"));
    input.setAttribute("value",rule.getAttribute("end"));
    input.onclick=function(){updateSettingsRequest("end",this.value,this.name);}    
    tr.appendChild(td);
    
    tbody.appendChild(tr);  
  }

  table.appendChild(tbody);

  rulesDiv.innerHtml = "";
  rulesDiv.appendChild(table);
}

/* show layer list*/
function showLayerList(xml){
  if(!xml){
    return;
  }

  var layers = document.getElementById(selectEditLayerId);
  if(!layers){
    return;
  }
  
  var select_input = document.createElement("select");
  select_input.setAttribute("id","editSelectLayer_select");
  select_input.setAttribute("size","1");
  
  layers.innerHtml = "";
  var childnode = document.getElementById("editSelectLayer_select");
  if(childnode){
    layers.removeChild(childnode);
  }
  
  layers.appendChild(select_input);
  
  if(xml.getAttribute("size") == "0"){
    return;
  }
  
  select_input.onchange=refreshEditor;
    
  var options = xml.getElementsByTagName("option");
  
  for(var k = 0; k < options.length; k++) {
    var option = document.createElement("option");
    option.setAttribute("value",options[k].getAttribute("index"));
    if(options[k].getAttribute("selected") == "selected"){
        option.setAttribute("selected","selected");
    }
    var optiontext = document.createTextNode(options[k].getAttribute("name"));    
    option.appendChild(optiontext);
    select_input.appendChild(option);
  }
}

/* refresh editor window*/
function refreshEditor(){
  refreshEditorRequest(null,null);
}

/* show the attributes div*/
function showSelectedAttributes(xml, attsDiv){
  if(!xml){
    return;
  }
  var selected = xml.getElementsByTagName("selectedAttributes").item(0);
  var attributes = xml.getElementsByTagName("selectedAttribute");
  
  if(!attributes){
    return;
  }
  showAttributesIndex(selected);
  
  var table = document.createElement("table");
  var tablebody = document.createElement("tbody");
  
  var current_row=document.createElement("tr");
  
  var name_cell = document.createElement("td");
  var nametext = document.createTextNode("OID");
  name_cell.appendChild(nametext);
  current_row.appendChild(name_cell);
  
  name_cell = document.createElement("td");
  if(selected){
    nametext = document.createTextNode(selected.getAttribute("oid"));
    name_cell.appendChild(nametext);
  }
  current_row.appendChild(name_cell);
        
  tablebody.appendChild(current_row);

  for(var j = 0; j < attributes.length; j++) {
    var att = attributes[j];
    
    current_row=document.createElement("tr");
    
    name_cell = document.createElement("td");
    nametext = document.createTextNode(att.getAttribute("name"));

    name_cell.appendChild(nametext);
    
    var value_cell = document.createElement("td");
    
    var options = att.getElementsByTagName("option");
 
    if(options != null && options.length > 0){
      var select_input = document.createElement("select");
      select_input.setAttribute("id", att.getAttribute("index")+"_"+att.getAttribute("name"));
      select_input.setAttribute("size","1");
      if(att.getAttribute("readOnly") == "true"){
        select_input.setAttribute("disabled",true);
      }else{
        select_input.onchange=function(){updateAttributeRequest(this.id,this.value);}
      }
      
      for(var k = 0; k < options.length; k++) {
        var option = document.createElement("option");
        option.setAttribute("id", "_att_option_"+att.getAttribute("name"));
        option.setAttribute("value",options[k].getAttribute("value"));
        var optiontext = document.createTextNode(options[k].getAttribute("text"));
        if(options[k].getAttribute("selected") == "selected"){
            option.setAttribute("selected","selected");
        }    
        option.appendChild(optiontext);
        select_input.appendChild(option);
      }
      value_cell.appendChild(select_input);
    }else{
      var valueInput = document.createElement("input");
      valueInput.setAttribute("id", att.getAttribute("index")+"_"+att.getAttribute("name"));
      valueInput.setAttribute("type","text");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -