POST
|
@BlakeTerhuneThanks for your reply. I am not sure if I understood your question properly or not. I just uploaded a shapefile to arcgis for developers and got portalid from there. I didn't add any additional settings to it. Also, I don't want this code to make changes to the original data in server, I just want to make temporary change on workspace only.
... View more
a week ago
|
0
|
1
|
89
|
POST
|
Thank you very much @KenBuja, it works. One more question: once we update the attribute value, shouldn't the value in popup window update by itself? Also the value in featuretable widget (assuming we have it in this code)?
... View more
a week ago
|
0
|
0
|
89
|
POST
|
Hello Everyone! I am trying to update the existing value of "PCR_NBR" in featurelayer by looking at the sample code of ArcGIS API for JS using apply edits, but its not working. In this code I am just trying to replace the value by 20. Also is it possible to run loop to have conditional statement, for eg: if PCR_NBR is less than 50, replace it by 20, if it is more than 50, replace it by 100? Thanks in advance! <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>
Update Feature Attributes | Sample | ArcGIS API for JavaScript 4.18
</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.18/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.18/"></script>
<style>
html,
body,
#viewDiv {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
#info {
padding: 14px;
border-radius: 5px;
}
#update {
padding: 6px;
}
#form {
background: #fff;
}
/* replaces esri-widget--panel */
.scroller {
overflow-x: hidden;
overflow-y: auto;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/widgets/FeatureForm",
"esri/layers/FeatureLayer",
"esri/form/FormTemplate"
], function(Map, MapView, FeatureForm, FeatureLayer, FormTemplate) {
let highlight, editFeature;
var popupMajorRoads = {
title: "Pavement Condition Rating(PCR): " + "{PCR_NBR}",
content: [{
type: "fields",
fieldInfos: [{
fieldName: "PCR_YEAR",
label: "PCR Year",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "PCR_NBR",
label: "Pavement Condition (PCR)",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "NLFID",
label: "NLFID",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "JURISDICTI",
label: "Juristiction",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "ROUTE_TYPE",
label: "Route Type",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "ROUTE_NBR",
label: "Route Number",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "DIRECTION_",
label: "Direction",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
},
{
fieldName: "LANES",
label: "Number of Lanes",
isEditable: true,
tooltip: "",
visible: true,
format: null,
stringFieldOption: "text-box"
}
]
}]
};
const featureLayer = new FeatureLayer({
portalItem: {
id: "8108b08e5ec643388380599f82e84b96"
},
outFields: ["*"],
visible: true,
popupTemplate: popupMajorRoads
});
const map = new Map({
basemap: "topo-vector",
layers: [featureLayer]
});
let view = new MapView({
map: map,
container: "viewDiv",
center: [-82.9988, 39.9612],
zoom: 10,
});
featureLayer.queryFeatures({
outFields: ["*"],
returnGeometry: true
})
.then(function(results) {
if (results.features.length > 0) {
editFeature = results.features[0];
editFeature.attributes.PCR_NBR = 20;
}
});
const edits = {
updateFeatures: [editFeature]
};
featureLayer.applyEdits(edits);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<div id="info" class="esri-widget">
</div>
</body>
</html>
... View more
a week ago
|
0
|
6
|
120
|
POST
|
Actually, I need to do a tradeoff analysis with the data of this layer and present the resulting features in map and charts. I need to perform multiple queries and filtering according to my task requirement, which might be possible with ArcGIS JS API but I am not familiar with it, so it will take me a lot of time. I was hoping to extract the whole attribute table in the form of an object like this: attributeData = [ { "OBJECTID": 1, "NLFID": "CFRACR00125**C", "SUM_c_segm": 6.0, "SUM_w_segm": 11.0, "STREET_NAM": "FRANK RD"}, { "OBJECTID": 2, "NLFID": "CFRACR00114**C", "SUM_c_segm": 5.0, "SUM_w_segm": 6.0, "STREET_NAM": "COURTRIGHT RD"}, { "OBJECTID": 3, "NLFID": "CFRACR00602**C", "SUM_c_segm": 5.0, "SUM_w_segm": 7.0, "STREET_NAM": "TOWN ST"} ... ... ... }] After the analysis, I plan to pass the array of OBJECTID of resulting features to the query to display them in the map. Is it possible to extract all data in this way? I am sorry I couldn't make it clear earlier and I apologize for your trouble. Thank You!
... View more
2 weeks ago
|
0
|
1
|
133
|
POST
|
Thanks @BlakeTerhune for your reply. I used layerview-create event and tried to test the result by printing NLFID value of the first feature, but it didn't work. Can you please take a look at it? Does the 'fieldsList' variable contain all the fields (let's say the whole attribute table)? Thanks much! <html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>High Injury Network</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 50%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.18/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.18/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/layers/GraphicsLayer",
"esri/geometry/geometryEngine",
"esri/Graphic"
], function (
Map,
MapView,
FeatureLayer,
GraphicsLayer,
geometryEngine,
Graphic
) {
var Crashes = [1,2];
var HINLayer = new FeatureLayer({
url: "https://services1.arcgis.com/wb4Og4gH5mvzQAIV/arcgis/rest/services/HIN_Columbus/FeatureServer",
outFields: ["*"],
visible: true
});
var resultsLayer = new GraphicsLayer();
var map = new Map({
basemap: "topo-vector",
layers: [HINLayer, resultsLayer]
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [-82.9, 39.99], // longitude, latitude
zoom: 10
});
HINLayer.on("layerview-create", function(event){
var fieldsList= HINLayer.fields;
document.getElementById("List").innerHTML = fieldsList[0].NLFID;
});
var sortedList = Crashes.sort();
var sortedString = sortedList.join("','");
var whereClause = "VehCrashCo IN ('" + sortedString + "')";
var query = HINLayer.createQuery();
query.where = whereClause ;
// query.outStatistics = [ sumCost];
query.returnGeometry= true;
return HINLayer.queryFeatures(query).then(function(results){
resultsLayer.removeAll();
var features = results.features.map(function (graphic) {
graphic.symbol = {
color: "darkorange"
};
return graphic;
});
resultsLayer.addMany(features);
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<div id="List"></div>
</body>
</html>
... View more
2 weeks ago
|
0
|
0
|
142
|
POST
|
Hello Everyone, How do we extract all fields of featurelayer as an object? I tried this but didn't worked: var fieldslist = featureLayer . fields ; document . getElementById ( "List" ). innerHTML = fieldslist [ 0 ]. NLFID ; I require this to perform computations only using some of the fields. Thank you in advance!
... View more
2 weeks ago
|
1
|
6
|
167
|
POST
|
@RobertScheitlin__GISP I created an app using WAB directly from ArcGIS for Developers. I didn't write a single line of code while creating it. Now I want to interact with it from JS API just like we do with a webmap or a feature layer, for example.
... View more
12-04-2020
10:46 AM
|
0
|
1
|
146
|
POST
|
I have created ArcGIS WebAppBuilder which provides a lot of functionalities. However, I want to interact with it using API for JS so that I can import data for analysis. Is there a way to do that? Thanks!
... View more
12-04-2020
10:12 AM
|
0
|
3
|
154
|
POST
|
Thanks for replying @BlakeTerhune. I am not that familiar with Query, but I will try if that works or not.
... View more
12-03-2020
10:22 AM
|
0
|
0
|
125
|
Online Status |
Offline
|
Date Last Visited |
Tuesday
|