POST
|
Wow, thank you all! I looked at actions, but didn't see anything that made sense for a solution. But, that worked like a charm. Always good to learn something new!
... View more
04-28-2023
01:38 PM
|
0
|
0
|
661
|
POST
|
I'm working with a single group layer in the layer list widget. By default, the group layer is visible, but collapsed upon map load. For ease of use for the end user, I would like the group layer to be open/expanded when the map loads. I believe I can achieve this by changing the CSS for the widget. I've added this block of code to the style and have tried different things, but haven't been able to get the group layer to be open upon map load. Any assistance is appreciated. .esri-layer-list__child-toggle .esri-layer-list__child-toggle-icon--opened,
.esri-layer-list__child-toggle .esri-layer-list__child-toggle-icon--closed-rtl,
.esri-layer-list__child-toggle--open .esri-layer-list__child-toggle-icon--closed {
display: none;
}
.esri-layer-list__child-toggle--open .esri-layer-list__child-toggle-icon--opened {
display: block;
}
... View more
04-28-2023
12:29 PM
|
1
|
4
|
706
|
POST
|
Viktor, We've taken the code that Ken provided and have reworked it so it works with our data. Here it is: // Initialize variables
// This is the construct for telling the query which layer to pull from
const visibleLayer = counties;
let highlight, grid;
// call clearMap method when clear is clicked
const clearbutton = document.getElementById("clearButton");
clearbutton.addEventListener("click", clearMap);
view.on("click", function (event) {
clearMap();
queryFeatures(event);
});
function queryFeatures(screenPoint) {
const point = view.toMap(screenPoint);
// Query the for the feature ids where the user clicked
visibleLayer
.queryObjectIds({
geometry: point,
spatialRelationship: "intersects",
returnGeometry: false,
outFields: ["*"]
})
.then(function (objectIds) {
if (!objectIds.length) {
return;
}
// Highlight the area returned from the first query
view.whenLayerView(visibleLayer).then(function (layerView) {
if (highlight) {
highlight.remove();
}
highlight = layerView.highlight(objectIds);
});
// Query the for the related features for the features ids found
return visibleLayer.queryRelatedFeatures({
outFields: ["SpeciesGroup", "CommonName", "ProtectionLevels"],
relationshipId: visibleLayer.relationships[2].id,
objectIds: objectIds
});
})
.then(function (relatedFeatureSetByObjectId) {
if (!relatedFeatureSetByObjectId) {
return;
}
// Create a grid with the data
Object.keys(relatedFeatureSetByObjectId).forEach(function (
objectId
) {
// get the attributes of the FeatureSet
const relatedFeatureSet = relatedFeatureSetByObjectId[objectId];
const rows = relatedFeatureSet.features.map(function (feature) {
return feature.attributes;
});
if (!rows.length) {
return;
}
// create a new div for the grid of related features
// append to queryResults div inside of the gridDiv
const gridDiv = document.createElement("div");
const results = document.getElementById("queryResults");
results.appendChild(gridDiv);
// destroy current grid if exists
if (grid) {
grid.destroy();
}
// create new grid to hold the results of the query
grid = new Grid(
{
// create field aliases for query window
columns: Object.keys(rows[0]).map(function (fieldName) {
var fieldAliases = {
SpeciesGroup: "Species Group",
CommonName: "Common Name",
ProtectionLevels: "Protection Level"
};
return {
label: fieldAliases[fieldName] || fieldName,
field: fieldName,
sortable: true
};
})
},
gridDiv
);
// add the data to the grid
grid.renderArray(rows);
});
clearbutton.style.display = "inline";
})
.catch(function (error) {
console.error(error);
});
}
function clearMap() {
if (highlight) {
highlight.remove();
}
if (grid) {
grid.destroy();
}
clearbutton.style.display = "none";
} I've never tried to write queries before within the API, so I have had a few meetings with our IT group to get their assistance with this issue. We gave them the same code block above, with the idea of working from it to move towards a popup. So far, this is the closest we've come up with, and it isn't behaving properly. const visibleLayer3 = hex;
let highlight3, grid3;
// call clearMap method when clear is clicked
const clearbutton3 = document.getElementById("clearButton");
clearbutton3.addEventListener("click", clearMap);
view.on("click", function (event) {
clearMap();
queryFeatures(event);
});
function queryFeatures(screenPoint) {
var strResult = '';
//const strResult = document.getElementById("prpResults");
const point = view.toMap(screenPoint);
// Query the for the feature ids where the user clicked
visibleLayer3
.queryObjectIds({
geometry: point,
spatialRelationship: "intersects",
returnGeometry: false,
outFields: ["*"]
})
.then(function (objectIds) {
if (!objectIds.length) {
return;
}
// Highlight the area returned from the first query
view.whenLayerView(visibleLayer3).then(function (layerView) {
if (highlight3) {
highlight3.remove();
}
highlight3 = layerView.highlight3(objectIds);
});
// Query the for the related features for the features ids found
return visibleLayer3.queryRelatedFeatures({
outFields: ["SpeciesGroup", "CommonName", "ProtectionLevels"],
relationshipId: visibleLayer3.relationships[0].id,
objectIds: objectIds
});
})
.then(function (relatedFeatureSetByObjectId) {
if (!relatedFeatureSetByObjectId) {
return;
}
// Create a grid with the data
Object.keys(relatedFeatureSetByObjectId).forEach(function (
objectId
) {
// get the attributes of the FeatureSet
const relatedFeatureSet = relatedFeatureSetByObjectId[objectId];
const rows = relatedFeatureSet.features.map(function (feature) {
return feature.attributes;
});
if (!rows.length) {
return;
}
//**** Shane Code Beg ****
strResult = '<ul>';
//document.getElementById("prpResults").innerHTML = '<ul>';
//strResult.value = '<ul>';
var aobjRows = rows;
for (let z = 0; z < aobjRows.length; z++) {
let strCommonName = aobjRows[z].CommonName;
let strSpeciesGroup = aobjRows[z].SpeciesGroup;
let strProtectionLevel = aobjRows[z].ProtectionLevels;
//alert(aobjRows[z].CommonName);
strResult += '<li>' + strCommonName + ',' + strSpeciesGroup + ',' + strProtectionLevel + '<li>';
//strResult.value += '<li>' + strCommonName + ',' + strSpeciesGroup + ',' + strProtectionLevel + '<li>';
//document.getElementById("prpResults").innerHTML += '<li>' + strCommonName + ',' + strSpeciesGroup + ',' + strProtectionLevel + '<li>';
}
strResult += '</ul>';
//strResult.value += '</ul>';
//document.getElementById("prpResults").innerHTML += '</ul>';
//**** Shane Code End ****
//*** Begin Comment ***
// create a new div for the grid of related features
// append to queryResults div inside of the gridDiv
const gridDiv = document.createElement("div");
const results = document.getElementById("queryResults");
results.appendChild(gridDiv);
// destroy current grid if exists
if (grid3) {
grid3.destroy();
}
// create new grid to hold the results of the query
grid3 = new Grid(
{
// create field aliases for query window
columns: Object.keys(rows[0]).map(function (fieldName) {
var fieldAliases = {
SpeciesGroup: "Species Group",
CommonName: "Common Name",
ProtectionLevels: "Protection Level"
};
return {
label: fieldAliases[fieldName] || fieldName,
field: fieldName,
sortable: true
};
})
},
gridDiv
);
// add the data to the grid
grid3.renderArray(rows);
//**** End comment ****
});
alert(strResult);
//alert(document.getElementById("prpResults").value);
clearbutton3.style.display = "inline";
})
.catch(function (error) {
console.error(error);
});
alert(strResult);
//alert(document.getElementById("prpResults").innerHTML);
//alert(document.getElementById("prpResults"));
}
function clearMap() {
if (highlight3) {
highlight3.remove();
}
if (grid3) {
grid3.destroy();
}
clearbutton.style.display = "none";
} This code isn't clean, but will give an idea the direction we are heading.
... View more
04-17-2023
08:17 AM
|
0
|
0
|
595
|
POST
|
Actually, we did run across that script and have been playing around with it. It works for us, but the map has three layers we need to toggle between, and we haven't been able to get it to work/focus on just the layer that is turned on. We also tried to rework it so it would open in a popup, but have not had success with that either. Both of those issues are likely due to lack of experience with queries on our end.
... View more
04-07-2023
12:07 PM
|
0
|
2
|
640
|
POST
|
I do. But, per Esri, there is a limitation in ArcGIS Enterprise that doesn't allow it to work. It only works on hosted feature layers on AGOL. See the note here: RelationshipContent | API Reference | ArcGIS Maps SDK for JavaScript 4.26 | ArcGIS Developers
... View more
04-07-2023
11:09 AM
|
0
|
1
|
646
|
POST
|
I have, yes. We can't use that sample as a guide as the layer sits on our ArcGIS Server and not on ArcGIS Online. I believe the closest I can get is actually using Query Related Records (Feature Service)—ArcGIS REST APIs | ArcGIS Developers. I have no experience with writing queries, so that's acting as another wall at the moment.
... View more
04-07-2023
08:35 AM
|
0
|
1
|
653
|
POST
|
I am working with a non-hosted feature layer with a related table. The service is sitting on our REST endpoint, not on ArcGIS Online, because it contains data we consider sensitive. Because it is not hosted on AGOL, I am unable to use relationshipContent. Also, while I've been using the JavaScript API off and on for a while, I am still very much a beginner. I ran across this sample earlier - PopupTemplate with promise | Sample Code | ArcGIS Maps SDK for JavaScript 4.26 | ArcGIS Developers. It meets a lot of my needs I believe, but I am unsure how to rework the code to pull from a related table. I believe I need to change the queryURL, but that may not even be doable. Any guidance on reworking this code or suggestions on what I should consider instead?
... View more
04-06-2023
01:39 PM
|
0
|
8
|
681
|
POST
|
Thanks Justin! I've got labeling turned on, so it works around the issue. I had assumed it was a known issue, just couldn't find it mentioned anywhere. Thanks again!
... View more
03-01-2023
10:46 AM
|
0
|
0
|
758
|
POST
|
We have recently started using Location Sharing (formerly Tracker). In the map viewer on AGOL, each user's initials show on the symbol for last known location. This holds true on Track Viewer as well. However, in Field Maps (app version 23.1.0 build 984), each user shows the default 'AF' in the last known location symbology. This is occurring on iPhones, not sure about Androids. Anyone else encountered this? Is this a bug?
... View more
03-01-2023
07:06 AM
|
0
|
7
|
813
|
POST
|
Ken, That simplified code actually cleared up the problem. Now it's showing all 4 categories. Thank you! Ashley
... View more
02-18-2022
06:21 AM
|
0
|
0
|
1507
|
POST
|
I moved the isEmpty condition to the top and that did resolve the null dates. The expression will only show 3 of the 4 symbology types though after I've reworked the code to be sure I have data that falls in all categories: if(isEmpty($feature.cleandate)){ return "Not yet surveyed"} else if (DateDiff(Now(), Date($feature.cleandate), 'days') <= 20) { return "Surveyed within the last 20 days" } //areas which are surveyed more than 30 days but less than 100 days ago belong in the second group else if (DateDiff(Now(), Date($feature.cleandate), 'days') > 20 && DateDiff(Now(), Date($feature.cleandate), 'days') < 35) { return "Surveyed between 20 to 35 days ago" } //areas which are surveyed 100 days ago or more belong in the third group else if (DateDiff(Now(), Date($feature.cleandate), 'days') >= 35) { return "Surveyed more than 35 days ago" }
... View more
02-17-2022
01:10 PM
|
0
|
1
|
1538
|
POST
|
That explanation helped a lot and I was able to get the code to validate. However, I am having the same results and the empty features are still showing under the greater than 100 days. Here's my code: if (DateDiff(Now(), Date($feature.cleandate), 'days') <= 30) { return "Surveyed within the last 30 days" } //areas which are surveyed more than 30 days but less than 100 days ago belong in the second group else if (DateDiff(Now(), Date($feature.cleandate), 'days') > 30 && DateDiff(Now(), Date($feature.cleandate), 'days') < 100) { return "Surveyed between 30 to 100 days ago" } //areas which are surveyed 100 days ago or more belong in the third group else if (DateDiff(Now(), Date($feature.cleandate), 'days') >= 100) { return "Surveyed more than 100 days ago" } else if(isEmpty($feature.cleandate)){ return "Not yet surveyed"} Could this potentiallly be caused by trying to create the symbology off a field from a related table?
... View more
02-17-2022
12:35 PM
|
0
|
1
|
1544
|
POST
|
I am trying to write an expression for use in the new map viewer to show work that has been done within the last month, three months, etc. The expression found here does most of what I need. However, most of my locations have not yet been visited and with this expression they are showing up as having been visited over 100 days ago and not in 'other values'. I've tried a few different ways to add phrasing to the expression that will create a new symbol for locations with null date fields, but that isn't working. This is likely due to lack of knowledge on my part as this is the first time I am trying to use Arcade. Is it possible to create symbology for locations with null date fields?
... View more
02-17-2022
12:17 PM
|
0
|
6
|
1565
|
Title | Kudos | Posted |
---|---|---|
1 | 03-04-2024 01:50 PM | |
1 | 02-29-2024 04:26 AM | |
1 | 04-28-2023 12:29 PM | |
1 | 07-08-2016 06:08 AM | |
1 | 08-12-2015 12:15 PM |
Online Status |
Offline
|
Date Last Visited |
a month ago
|