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

📄 esri_edit.js

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JS
📖 第 1 页 / 共 4 页
字号:
      valueInput.setAttribute("value",att.getAttribute("value"));
      if(att.getAttribute("readOnly") == "true"){
        valueInput.setAttribute("disabled",true);
      }else{
        valueInput.onchange=function(){updateAttributeRequest(this.id,this.value);}
      }
      value_cell.appendChild(valueInput);
    }
    
    current_row.appendChild(name_cell);
    current_row.appendChild(value_cell);
        
    tablebody.appendChild(current_row);
  }
  table.appendChild(tablebody);
  
  attsDiv.appendChild(table);
}
/* show the attributes index */
function showAttributesIndex(selected){
  if(!selected){
    return;
  }
  var preSelect = document.getElementById("preOID");
  var firstSelect = document.getElementById("firstOID");
  var nextSelect = document.getElementById("nextOID");
  var lastSelect = document.getElementById("lastOID");
  var indexSelect = document.getElementById("indexSelect");
  
  if(!(firstSelect && preSelect && nextSelect && lastSelect && indexSelect)){
    return;
  }
  
  firstSelect.setAttribute("type","image");
  preSelect.setAttribute("type","image");
  nextSelect.setAttribute("type","image");
  lastSelect.setAttribute("type","image");
  
  var index = parseInt(selected.getAttribute("index")) + 1;
  var styleClass = (document.all ? "className" : "class");
  
  indexSelect.innerHTML = index + " of " + selected.getAttribute("size"); 
         
  if(selected.getAttribute("pre") == "true"){
     preSelect.removeAttribute(styleClass);
     preSelect.removeAttribute("disabled");

     firstSelect.removeAttribute(styleClass);
     firstSelect.removeAttribute("disabled");
  }else{
     preSelect.setAttribute(styleClass, "disabledButton");
     preSelect.setAttribute("disabled", true);
     firstSelect.setAttribute(styleClass, "disabledButton");
     firstSelect.setAttribute("disabled", true);
  }
  
  if(selected.getAttribute("next") == "true"){
     nextSelect.removeAttribute(styleClass);
     nextSelect.removeAttribute("disabled");
     
     lastSelect.removeAttribute(styleClass);
     lastSelect.removeAttribute("disabled");

  }else{
     nextSelect.setAttribute(styleClass, "disabledButton");
     nextSelect.setAttribute("disabled", true);
     lastSelect.setAttribute(styleClass, "disabledButton");
     lastSelect.setAttribute("disabled", true);
  }
}

function refreshEditorRequest(action, eventsource) {
  var map = EsriControls.maps[mapId];
  //Get server URL
  var url = EsriUtils.getServerUrl(map.formId);
  //Set request parameters
  var params = "EditBean=EditBean&ajaxServerAction=refresh";

  var changedLayer = document.getElementById("editSelectLayer_select");
  if(changedLayer){
    params = params + "&layerId=" + changedLayer.value;
  }

  var selectEditVersion = document.getElementById(selectEditVersionId);
  if(selectEditVersion){
    params = params + "&version=" + selectEditVersion.value;
  }

  if(action){
    params = params + "&action=" + action;
  }

  //Send AJAX request and set response processing function
  EsriUtils.sendAjaxRequest(url, params, false, function(xmlHttp) { self.updateEditorResponse(xmlHttp, eventsource);});
}

function updateAttributeRequest(id, value) {
  var map = EsriControls.maps[mapId];

  //Get server URL
  var url = EsriUtils.getServerUrl(map.formId);
  //Set request parameters
  var params = "EditBean=EditBean&ajaxServerAction=updateAttributes&id=" + id + "&value=" + value;
  //Send AJAX request and set response processing function
  EsriUtils.sendAjaxRequest(url, params, false, updateEditorResponse);
}

function updateSettingsRequest(name, value, layer) {
  var map = EsriControls.maps[mapId];

  //Get server URL
  var url = EsriUtils.getServerUrl(map.formId);
  //Set request parameters
  var params = "EditBean=EditBean&ajaxServerAction=updateSettings&name=" + name + "&value=" + value;
  if(layer){
    params = params + "&layer=" + layer;
  }
  //Send AJAX request and set response processing function
  EsriUtils.sendAjaxRequest(url, params, false, updateSnapRules);
}

/* Process AJAX request and update content */
function updateSnapRules(xmlHttp) {
  if (xmlHttp != null && xmlHttp.readyState == 4 && xmlHttp.status == 200) {
    //Get XML response
    var xml = xmlHttp.responseXML;

    //If error, show error message
    if (xml.getElementsByTagName("error").length > 0) {
      alert(xml.getElementsByTagName("error").item(0).firstChild.nodeValue);
      return;
    }
    
    var editTask = xml.getElementsByTagName("EditBean").item(0)

    if(editTask){
      var snapStatus = editTask.getElementsByTagName("ConfigBean").item(0);
      if(snapStatus){
         updateSnapStatus(snapStatus);
      }
    }
  }
}

/* Process AJAX request and update content */
function updateEditorResponse(xmlHttp, eventsource, action) {
  if (xmlHttp != null && xmlHttp.readyState == 4 && xmlHttp.status == 200) {
    //Get XML response
    var xml = xmlHttp.responseXML;

    //If error, show error message
    if (xml.getElementsByTagName("error").length > 0) {
      alert(xml.getElementsByTagName("error").item(0).firstChild.nodeValue);
      return;
    }
    
    var editTask = xml.getElementsByTagName("EditBean").item(0)

    if(editTask){
      editBeanHandler(editTask);
    }
    
    editTask = xml.getElementsByTagName("EditorEnterXYWin").item(0);
    if(editTask){
      editorEnterXYWindowHandler(editTask, eventsource);
    }

    editTask = xml.getElementsByTagName("EditorExitConfirmWindow").item(0);
    if(editTask){
      editorExitWindowHandler(editTask,eventsource);
    }
    
    editTask = xml.getElementsByTagName("EditorWindow").item(0);
    if(editTask){
      editorShowWindowHandler(editTask, eventsource, action);
    }

  }
}

/**************************************************************************
 *From editing task *******************************************************
 **************************************************************************/
function EsriEditingDrawAction() {
  this.inheritsFrom(new EsriAction());
  this.isEditing = true;

  this.lineOpacity = 0.5;
  this.fillColor = "#ff0";
  this.fillOpacity = 0.25;
  
  this.symbol.lineOpacity = 0.5;
  this.symbol.fillColor = "#ff0";
  this.symbol.fillOpacity = 0.25

  this.snapping = false;
  this.snapDistance = 5;
  this.snapColor = "#f90";
  this.snapWidth = 8;
  this.snapSymbol = new EsriGraphicsSymbol("#f90",1,8,'#fff',1);

  this.snappedPoint = null;
  this.snapGraphics = null;
  this.snapPoint = null;
  this.snapText = null;
  this.clickTolerance = 3;
  this.clearSnapGraphics = function() {
    if(this.snapPoint) { 
      this.snapGraphics.remove(this.snapPoint);
      this.snapGraphics.remove(this.snapText);
    }
  }
  
  
}

function EsriEditingDrawPointAction() {
  this.inheritsFrom(new EsriEditingDrawAction());
  this.name = "EsriEditingDrawPointAction";

  var element, callback, contCallback, bounds, timer, currPt, gr, graphic;
  var callbackTimeout = 250;
  var createGraphic = true;
  var self = this;

  this.activate = function(elem, cb, ccb, ge) {
    element = elem;
    callback = cb;
    contCallback = ccb;

    element.style.cursor = this.cursor;
    element.onmousemove = processMouseMove;
    element.onclick = processClick;

    if (this.snapping) {
      if(ge) {
        gr = this.snapGraphics = ge;
        createGraphic = false;
      }
      else {
        gr = EsriUtils.createGraphicsElement(element.id + "gr", element);
        EsriUtils.setElementStyle(gr.gc, "z-index:" + this.graphicsZIndex + ";");
        
        this.snapGraphics = EsriUtils.createGraphicsElement(element.id + "sGr", element);
        EsriUtils.setElementStyle(this.snapGraphics.gc, "z-index:" + (this.graphicsZIndex + 1) + ";");
      }

      gr.gc.onmousemove = this.snapGraphics.gc.onmousemove = processMouseMove;
      gr.gc.onclick = this.snapGraphics.gc.onclick = processClick;
    }
  }

  this.deactivate = function() {
    if (element != null) {
      element.onmousedown = element.onclick = element.onmousemove = null;
      element.style.cursor = "default";
    }
    if (gr != null) {
      if (graphic) gr.remove(graphic);
      if(createGraphic) {
        gr.destroy();
        this.snapGraphics.destroy();
      }
      gr.gc.onmousedown = gr.gc.onmousemove = gr.gc.onclick = this.snapGraphics.gc.onmousemove = this.snapGraphics.gc.onmousedown = this.snapGraphics.gc.onclick = null;
    }
    element = callback = gr = this.snapGraphics = this.snappedPoint = null;
  }

  this.reactivate = function() {
    var e = element;
    var c = callback;
    var cc = contCallback;
    var ge = createGraphic ? null : gr;
    this.deactivate();
    this.activate(e, c, cc, ge);
  }

  function getPoint(e) {
    var pt = EsriUtils.getXY(e).offset(-bounds.left, -bounds.top);
    if ((Math.abs(currPt.x - pt.x) <= self.clickTolerance && Math.abs(currPt.y - pt.y) <= self.clickTolerance) && self.snappedPoint) pt = self.snappedPoint;
    return pt;
  }

  function processMouseMove(e) {
    bounds = EsriUtils.getElementPageBounds(element);
    currPt = EsriUtils.getXY(e).offset(-bounds.left, -bounds.top);
    if (gr) {
      self.clearSnapGraphics();
      if (graphic) gr.remove(graphic);
      graphic = gr.drawCircle(currPt, self.snapDistance, self.symbol);
      restartTimer();
    }
    if (EsriUtils.isNav) EsriUtils.stopEvent(e);
    return false;
  }

  function processClick(e) {
    clearTimeout(timer);
    bounds = EsriUtils.getElementPageBounds(element);
    currPt = getPoint(e);
    EsriUtils.stopEvent(e);
    if (graphic) gr.remove(graphic);
    self.clearSnapGraphics();
    bounds = null;
    callback(currPt);
  }

  function restartTimer() {
    if (timer) clearTimeout(timer);
    var pt = currPt;
    timer = setTimeout(function() {if(self.snapGraphics) self.clearSnapGraphics();self.snappedPoint = null; contCallback(pt); }, callbackTimeout);
  }
}

function EsriEditingDrawLineAction() {
  this.inheritsFrom(new EsriEditingDrawAction());
  this.name = "EsriEditingDrawLineAction";

  var element, callback, bounds, timer, startPt, gr, tGr, currPt, contCallback, lineGraphic, circleGraphic;
  var callbackTimeout = 250;
  var createGraphic = true;
  var self = this;

  this.activate = function(elem, cbF, ccbF, ge) {
    element = elem;
    callback = cbF;
    contCallback = ccbF;
    
    if (ge) {
      gr = ge;
      createGraphic = false;
    }
    else {
      gr = EsriUtils.createGraphicsElement(element.id + "gr", element);
      EsriUtils.setElementStyle(gr.gc, "z-index:" + this.graphicsZIndex + ";");
    }

    element.style.cursor = this.cursor;
    element.onmousedown = gr.gc.onmousedown = processMouseDown;
    element.onmousemove = gr.gc.onmousemove = processMouseMove;

    if (this.snapping) {
      if (ge) tGr = this.snapGraphics = ge;
      else { 
        tGr = EsriUtils.createGraphicsElement(element.id + "tGr", element);
        EsriUtils.setElementStyle(tGr.gc, "z-index:" + (this.graphicsZIndex + 1) + ";");
      
        this.snapGraphics = EsriUtils.createGraphicsElement(element.id + "sGr", element);
        EsriUtils.setElementStyle(this.snapGraphics.gc, "z-index:" + (this.graphicsZIndex + 1) + ";");
      }

      tGr.gc.onmousedown = this.snapGraphics.gc.onmousedown = processMouseDown;
      tGr.gc.onmousemove = this.snapGraphics.gc.onmousemove = processMouseMove;
    }
  }

  this.deactivate = function() {
    if (element != null) {
      element.onmouseup = element.onmousemove = element.onmousedown = null;
      element.style.cursor = "default";
    }
    if (gr != null) {
      if (lineGraphic) gr.remove(lineGraphic);
      if (createGraphic) gr.destroy();
      gr.gc.onmouseup = gr.gc.onmousemove = gr.gc.onmousedown = null;
    }
    if (tGr) {
      if (circleGraphic) tGr.remove(circleGraphic);
      if (createGraphic) {
        tGr.destroy();
        this.snapGraphics.destroy();
      }
      tGr.gc.onmouseup = this.snapGraphics.gc.onmouseup = tGr.gc.onmousemove = this.snapGraphics.gc.onmousemove = tGr.gc.onmousedown = this.snapGraphics.gc.onmousedown = null;
    }
    element = startPt = gr = this.snapGraphics = this.snappedPoint = null;
  }

  this.reactivate = function() {
    var e = element;
    var c = callback;
    var ccb = contCallback;
    var ge = createGraphic ? null : gr;
    this.deactivate();
    this.activate(e, c, ccb, ge);
  }

  function getPoint(e) {
    var pt = EsriUtils.getXY(e).offset(-bounds.left, -bounds.top);
    if ((Math.abs(currPt.x - pt.x) <= self.clickTolerance && Math.abs(currPt.y - pt.y) <= self.clickTolerance) && self.snappedPoint) pt = self.snappedPoint;
    return pt;
  }

  function processMouseDown(e) {
    bounds = EsriUtils.getElementPageBounds(element);
    element.onmousedown = gr.gc.onmousedown = null;
    element.onmouseup = gr.gc.onmouseup = processMouseUp;
    if (tGr) {
      tGr.gc.onmousedown = self.snapGraphics.gc.onmousedown = null;
      tGr.gc.onmouseup = self.snapGraphics.gc.onmouseup = processMouseUp;
    }
    startPt = getPoint(e);
    if (lineGraphic) gr.remove(lineGraphic);
    EsriUtils.stopEvent(e);

⌨️ 快捷键说明

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