ArcGIS JavaScript在线编辑

代码:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Demo:Edit Features</title>
    <link rel="stylesheet" href="https://js.arcgis.com/3.17/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="https://js.arcgis.com/3.17/esri/css/esri.css">
    <script src="https://js.arcgis.com/3.17/"></script>
    <style type="text/css">
        html, body {
            height: 100%;
            width: 100%;
            margin: 0;
            padding: 0;
        }
        body {
            background-color: #fff;
            overflow: hidden;
            font-family: sans-serif;
        }
        #mainWindow {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        #header {
            font-size: 1.1em;
            font-family: sans-serif;
            padding-left: 1em;
            padding-top: 2px;
            color: #0026ff;
            text-align: center;
        }
        #templatePickerPane {
            width: 200px;
            height: 100%;
        }
        #panelHeader {
            background-color: #92A661;
            border-bottom: solid 1px #92A860;
            color: #FFF;
            font-size: 18px;
            height: 24px;
            line-height: 22px;
            margin: 2px;
            overflow: hidden;
            padding: 2px;
        }        
    </style>
    
    <script>
        var map;
        var widgetEditor;        
        require([
            "esri/geometry/Extent",
            "esri/map",
            "esri/layers/FeatureLayer",
            "esri/dijit/editing/Editor",
            "esri/tasks/GeometryService",
            "esri/dijit/editing/TemplatePicker",
            "dojo/ready",
            "dojo/parser",
            "dojo/on",
            "dojo/_base/array",
            "dijit/layout/BorderContainer",
            "dijit/layout/ContentPane",
            "dojo/domReady!"
        ],
          function (Extent, Map, FeatureLayer, Editor, GeometryService, TemplatePicker,
            ready, parser, on, array,
            BorderContainer, ContentPane) {
              parser.parse();
              var startExtent = new Extent({
                  "xmin": 73.441277,
                  "ymin": 34.334934,
                  "xmax": 96.388373,
                  "ymax": 49.178574,
                  "spatialReference": { "wkid": 4326 }
              });
              map = new Map("map", {
                  basemap: "topo",
                  extent: startExtent,
                  zoom: 5,
                  sliderStyle: "large",
                  logo: false
              });
              var token = "MPNBJEn-yBwnji4k9nkh-oMoYieNlFVzlx2-CZqJKN8pIuEcyGFYncPALY8PgPgv";
              var flFirePoints = new FeatureLayer("http://159.75.129.108:6080/arcgis/rest/services/MyGP/TestFeature/FeatureServer/0?token=" + token, {
                  outFields: ["*"]
              });
              var flFireLines = new FeatureLayer("http://159.75.129.108:6080/arcgis/rest/services/MyGP/TestFeature/FeatureServer/1?token=" + token, {
                  outFields: ["*"]
              });
              var flFirePolygons = new FeatureLayer("http://159.75.129.108:6080/arcgis/rest/services/MyGP/TestFeature/FeatureServer/2?token=" + token, {
                  outFields: ["*"]
              });
              // Listen for the editable layers to finish loading
              map.on("layers-add-result", initEditor);
              // add the editable layers to the map
              map.addLayers([flFirePolygons, flFireLines, flFirePoints]);
              //加载编辑方法
              function initEditor(results) {
                  // Map the event results into an array of layerInfo objects
                  var layerInfosWildfire = array.map(results.layers, function (result) {
                      return {
                          featureLayer: result.layer,
                          showAttachments: false,
                          isEditable: true,
                          fieldInfos: [
                              { fieldName: ‘SYMBOLID‘, visible: true, isEditable: true, label: ‘类型:‘ },
                              { fieldName: ‘DESCRIPTION‘, visible: true, isEditable: true, label: ‘名称:‘ }
                          ]
                      };
                  });
                  /*
                   * Step: Map the event results into an array of Layer objects
                   */
                  var layersWildfire = array.map(results.layers, function (result) {
                      return result.layer;
                  });
                  /*
                   * Step: Add a custom TemplatePicker widget
                   */
                  var tpCustom = new TemplatePicker({
                      featureLayers: layersWildfire,
                      columns: 2
                  }, ‘templatePickerDiv‘);
                  tpCustom.startup();
                  /*
                   * Step: Prepare the Editor widget settings
                   */
                  var editorSettings = {
                      map: map,
                      geometryService: new GeometryService("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer"),
                      layerInfos: layerInfosWildfire,
                      toolbarVisible: true,
                      templatePicker: tpCustom,
                      createOptions: { polygonDrawTools: [Editor.CREATE_TOOL_FREEHAND_POLYGON, Editor.CREATE_TOOL_RECTANGLE, Editor.CREATE_TOOL_TRIANGLE, Editor.CREATE_TOOL_CIRCLE] },
                      toolbarOptions: {
                          reshapeVisible: true
                      },
                      enableUndoRedo: true,
                      maxUndoRedoOperations: 20
                  };
                  /*
                   * Step: Build the Editor constructor‘s first parameter
                   */
                  var editorParams = {
                      settings: editorSettings
                  };
                  /*
                   * Step: Construct the Editor widget
                   */
                  var widgetEditor = new Editor(editorParams, ‘divEditor‘);
                  widgetEditor.startup();
              }
          });
    </script>
</head>
<body class="claro">
    <div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:‘headline‘">
        <div data-dojo-type="dijit/layout/ContentPane" id="header" data-dojo-props="region:‘top‘">
            Web地图在线编辑演示,当前登录用户为:<label id="userInfo">testc</label>
        </div>
        <div data-dojo-type="dijit/layout/ContentPane" id="map" data-dojo-props="region:‘center‘"></div>
        <div id="templatePickerPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:‘right‘">
            <div id="panelHeader">默认编辑器</div>
            <div id="templatePickerDiv"></div>
            <div id="divEditor"></div>
        </div>
    </div>
    <!--http://codepen.io/lorencem/pen/KdrEqP-->
</body>
</html>

运行结果:

相关文献:

https://developers.arcgis.com/javascript/3/jssamples/ed_feature_creation.html

http://blog.csdn.net/lrspace/article/details/41730707

时间: 2024-11-09 18:26:26

ArcGIS JavaScript在线编辑的相关文章

ArcGIS JavaScript在线打印

备注:防止中文乱码,中文字体选用"微软雅黑". function Print(printTitle) {     //var printTitle = $("#ipttitle").val();     var legend = $("#Checkbox1").prop("checked");     var printTask = new esri.tasks.PrintTask(printUrl);     //打印模板

ArcGIS Javascript API 加载高德在线地图扩展

利用ArcGIS JavaScript API加载高德在线地图的扩展 /** * Created by WanderGIS on 2015/7/15. */ define(["dojo/_base/declare", "esri/geometry/Extent", "esri/SpatialReference", "esri/geometry/Point", "esri/layers/TileInfo",

RunJS - 在线编辑、展示、分享、交流你的 JavaScript 代码

发现一个很好玩,很强大的网站 RunJS - 在线编辑.展示.分享.交流你的 JavaScript 代码   http://runjs.cn/ 比如: http://runjs.cn/detail/lp6rqcsr 或者: <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <title>登录</title> <

分享十个JavaScript在线调试工具

测试Javascript可能是网页开发中最让人忧伤的工作.这里我找一些比较好的工具来帮助大家进行测试工作.这10款是我精选的基于浏览器的JavaScript在线调试工具,希望你们对你们有用. 1.Opera Dragonfly一个Opera browser的跨设备及其平台的debugging环境 ,检查和编辑CSS和DOM,并且可以查看相关错误 2.JS Bin – Collaborative JavaScript Debugging这个工具类似于jsfiddle,可以帮助大家来在线分享和协作调

NET中weboffice组件在线编辑文档并保存到服务器上

页面中组件的引用以及控件触发事件: <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="9" background="images/tab_12.gif"> <asp:Button ID="btnuploadsave"

openlayers实现在线编辑

概述: 在前面有篇博文讲述了基于Arcgis for js和wkt实现在线数据的采集和编辑功能,在本文讲述如何在openlayers实现类似的功能.上一篇博文的地址为: http://blog.csdn.net/gisshixisheng/article/details/44310765 思路: 前后台的数据交互以wkt的形式,加载已完成对象用wkt,对象更新完成之后将geometry转换为wkt传给后台,将信息保存到数据库中.实现在线编辑主要为OpenLayers.Control.Modify

在线编辑代码[django]版本

再国内,做什么都这么吃力.连aliyun 的ssh 都被封这是什么世道,所以做一个在线编辑代码的忙忙碌碌有点粗糙.大家见谅?1. [代码]views.py #-*- coding:utf-8 -*- # jQuery File Tree# Python/Django connector script# By Martin Skou#import osimport urllibfrom django.http import HttpResponsefrom django.shortcuts imp

javascript 在线文本编辑器

javascript 在线文本编辑器实现代码.效果如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m

shell——bash在线编辑

无意中发现了一个bash在线编辑的网址,初学者可以用这个试着学习shell http://www.runoob.com/try/runcode.php?filename=helloworld&type=bash