-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex4.html
169 lines (145 loc) · 6.95 KB
/
index4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Editable FeatureLayer in Selection Only Mode with Attribute Inspector</title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css" />
<style>
html, body {
height: 98%; width: 98%;
padding: 0;
overflow:hidden;
}
#mapDiv{
padding:0;
border: solid 2px #705B35;
}
.roundedCorners {
-moz-border-radius: 4px;
border-radius: 4px;
}
#detailPane{
height:20px;
color:#570026;
font-size:12pt;
font-weight:600;
overflow:hidden;
}
.dj_ie .infowindow .window .top .right .user .content { position: relative; }
.dj_ie .simpleInfoWindow .content {position: relative;}
.esriAttributeInspector {height:100px;}
.esriAttributeInspector .atiLayerName {display:none;}
.saveButton {
padding-left:45px;
margin:0px;width:16px; height:16px;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("esri.dijit.AttributeInspector-all");
var map;
var updateFeature;
function init() {
//This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to
//replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
//for details on setting up a proxy page.
esri.config.defaults.io.proxyUrl = "/proxy";
var startExtent = new esri.geometry.Extent(-97.5328,37.4344,-97.2582,37.64041, new esri.SpatialReference({wkid:4326}) );
map = new esri.Map("mapDiv", {
basemap: "streets",
center: [-97.395, 37.537],
zoom: 11
});
dojo.connect(map, "onLayersAddResult", initSelectToolbar);
var petroFieldsMSL = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer");
petroFieldsMSL.setDisableClientCaching(true);
map.addLayer(petroFieldsMSL);
var petroFieldsFL = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/FeatureServer/0", {
mode: esri.layers.FeatureLayer.MODE_SELECTION,
outFields: ["approxacre","objectid","field_name","activeprod","cumm_oil","cumm_gas","avgdepth"]
});
var selectionSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, new esri.symbol.SimpleLineSymbol("dashdot", new dojo.Color("yellow"), 2),null);
petroFieldsFL.setSelectionSymbol(selectionSymbol);
dojo.connect(petroFieldsFL, "onEditsComplete", this, function() {
petroFieldsMSL.refresh();
});
map.addLayers([petroFieldsFL]);
}
function initSelectToolbar(results) {
var petroFieldsFL = results[0].layer;
console.log("petro field : " + petroFieldsFL);
var selectQuery = new esri.tasks.Query();
dojo.connect(map, "onClick", function(evt) {
selectQuery.geometry = evt.mapPoint;
petroFieldsFL.selectFeatures(selectQuery, esri.layers.FeatureLayer.SELECTION_NEW, function(features) {
if (features.length > 0) {
//store the current feature
updateFeature = features[0];
map.infoWindow.setTitle(features[0].getLayer().name);
map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
} else {
map.infoWindow.hide();
}
});
});
dojo.connect(map.infoWindow, "onHide", function() {
petroFieldsFL.clearSelection();
});
var layerInfos = [{
'featureLayer': petroFieldsFL,
'showAttachments': false,
'isEditable': true,
'fieldInfos': [
{'fieldName': 'activeprod', 'isEditable':true, 'tooltip': 'Current Status', 'label':'Status:'},
{'fieldName': 'field_name', 'isEditable':true, 'tooltip': 'The name of this oil field', 'label':'Field Name:'},
{'fieldName': 'approxacre', 'isEditable':false,'label':'Acreage:'},
{'fieldName': 'avgdepth', 'isEditable':false, 'label':'Average Depth:'},
{'fieldName': 'cumm_oil', 'isEditable':false, 'label':'Cummulative Oil:'},
{'fieldName': 'cumm_gas', 'isEditable':false, 'label':'Cummulative Gas:'}
]
}];
this.attInspector = new esri.dijit.AttributeInspector({
layerInfos:layerInfos
}, dojo.create("div"));
//add a save button next to the delete button
var saveButton = new dijit.form.Button({label:"Save","class":"saveButton"});
dojo.place(saveButton.domNode, this.attInspector.deleteBtn.domNode, "after");
dojo.connect(saveButton,"onClick",function(){
updateFeature.getLayer().applyEdits(null, [updateFeature], null);
});
dojo.connect(this.attInspector, "onAttributeChange", function(feature,fieldName,newFieldValue) {
//store the updates to apply when the save button is clicked
updateFeature.attributes[fieldName] = newFieldValue;
});
dojo.connect(this.attInspector,"onNext",function(feature){
updateFeature = feature;
console.log("Next " + updateFeature.attributes.objectid);
});
dojo.connect(this.attInspector, "onDelete",function(feature){
feature.getLayer().applyEdits(null,null,[feature]);
map.infoWindow.hide();
});
map.infoWindow.setContent(this.attInspector.domNode);
map.infoWindow.resize(325, 220);
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline', gutters:false" style="width:100%;height:100%;">
<div id="detailPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
Click a field to display the attribute inspector with customized fields.
</div>
<div data-dojo-type="dijit.layout.ContentPane" class="roundedCorners" data-dojo-props="region:'center'" id="mapDiv"></div>
</div>
</body>
</html>