<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <link rel="stylesheet" type="text/css" href="https://community.esri.com/arcgis_js_api/library/2.6/jsapi/js/dojo/dijit/themes/tundra/tundra.css"> <script src="/arcgis_js_api/library/2.6/jsapi/" type="text/javascript"></script> <script type="text/javascript"> djConfig = { parseOnLoad: true }; </script> <style type="text/css"> #attrInspector {width: 250px;} .esriAttributeInspector {padding: 10px; width: 100px;} .esriAttributeInspector .atiLayerName {display:none;} </style> <script type="text/javascript"> dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.layers.FeatureLayer"); dojo.require("esri.dijit.AttributeInspector-all"); var map, featureLayerAlfaMMServer, featureLayerAlfaLinkedServer, featureLayerGeo; function init() { //map options and actions var initialExtent = new esri.geometry.Extent({"xmin":-1051697,"ymin":4386071,"xmax":-776524,"ymax":4569520,"spatialReference":{"wkid":102100}}); map = new esri.Map("map",{extent:initialExtent}); dojo.connect(dijit.byId('map'), 'resize', map,map.resize); dojo.connect(map, "onLayersAddResult", init2); //simple layer for visualization var sessaoProcesso = new esri.layers.ArcGISDynamicMapServiceLayer("http://localhost/ArcGIS_Server/rest/services/ARH_PROCESSOS_ALFA/MapServer",{id:"sessaoProcesso"}); map.addLayer(sessaoProcesso); //featurelayer with alphanumeric data from a view within the same server featureLayerAlfaMMServer = new esri.layers.FeatureLayer("http://localhost/ArcGIS_Server/rest/services/ARH_PROCESSOS_ALFA/FeatureServer/1",{ mode: esri.layers.FeatureLayer.MODE_SELECTION ,outFields: ["*"] }); //featurelayer with the spatial data featureLayerGeo = new esri.layers.FeatureLayer("http://localhost/ArcGIS_Server/rest/services/ARH_PROCESSOS/FeatureServer/0",{ mode: esri.layers.FeatureLayer.MODE_SELECTION ,outFields: ["*"] }); var selectionSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 1), new dojo.Color([0,255,0,0.25])); featureLayerGeo.setSelectionSymbol(selectionSymbol); //after the layers are added, go to init2 map.addLayers([featureLayerGeo]); } function init2(){ //get all the features for the alphanumeric layer var selectQuery = new esri.tasks.Query(); selectQuery.where = "1=1"; featureLayerAlfaMMServer.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW, function(features,selectionMethod){ spatialSearch(features[0].attributes.Lic_licenca); }); var layerInfosMMServer = [{'featureLayer':featureLayerAlfaMMServer, 'showAttachments':false, 'isEditable': true, 'showDeleteButton':false }]; var attInspectorMMServer = new esri.dijit.AttributeInspector({layerInfos:layerInfosMMServer}, "attrInspectorMMServer"); dojo.connect(attInspectorMMServer,"onNext", function(feature) { spatialSearch(feature.attributes.Lic_licenca); }); //save changes dojo.connect(attInspectorMMServer, "onAttributeChange", function(feature,fieldName,newFieldValue) { console.log("Edit",feature,fieldName,newFieldValue); feature.attributes[fieldName] = newFieldValue; feature.getLayer().applyEdits(null, [feature], null, function(add,update,del){ console.log("Success",add,update,del); }, function(error){ console.log("Error",error); }); }); } //function to "highlight" the feature related to the current record function spatialSearch(licenca){ featureLayerGeo.clearSelection(); var query = new esri.tasks.Query(); query.where = "Lic_licenca = " + licenca; featureLayerGeo.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function(){ if(featureLayerGeo.getSelectedFeatures().length > 0){ //Edit spatial }else{ //Create spatial } }); } dojo.addOnLoad(init); </script> </head> <body class="tundra"> <div id="map" style="float: left; width: 70%; height:700px; border-top:1px solid black; border-bottom:1px solid black; border-right:1px solid black;"></div> <div id="teste" style="float: right; width: 30%; height:700px; border-top:1px solid black; border-bottom:1px solid black; margin: 0px;"> <div style="width: 100%;" id="attrInspectorMMServer"></div> </div> </body> </html>
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.