POST
|
Unfortunately not. I am still unsure how to apply the queryTask.executeForExtent
... View more
06-05-2017
07:33 PM
|
0
|
1
|
725
|
POST
|
Just an update. I was able to get my definition query to adjust dynamically when an item is either selected or deselected.
... View more
06-05-2017
01:30 PM
|
0
|
3
|
725
|
POST
|
I am using the ArcGIS API for Javascript 4.3 and want to zoom to features that correspond to a definition expression. It was suggested by @RobErt Scheitlin that I use queryTask.executeForExtent to accomplish this. Although, this may be correct, I am still unsure how to incorporate this into my code. function selectionDefExpression(selectionArray) {
routeNameStr = selectionArray.join("', '");
var definitionExpression = corridorLayer.definitionExpression = "BOTH_ROUTE_NAME IN ('" + routeNameStr + "')";
return definitionExpression;
}
function deselectionDefExpression() {
return corridorLayer.definitionExpression = "BOTH_ROUTE_NAME IN ('" + "" + "')";
}
var routeName;
var routeNameStr;
var selectedRows = [];
grid.on('dgrid-select', function (event) {
routeName = event.rows[0].data.routeName;
var rows = event.rows;
for (i = 0; i < rows.length; i++) {
selectedRows.push(routeName);
selection = document.getElementById("selectedRoutes");
selection.innerHTML += "<li>" + routeName + "<a href='#'> Remove</a></li>";
}
selectionDefExpression(selectedRows);
if (!corridorURL.visible) {
corridorLayer.visible = true;
}
}, function (error) {
console.log(error)
});
});
grid.on('dgrid-deselect', function (event) {
//var x = [].slice.call(document.querySelectorAll("#selectedRoutes li"));
//x.filter(function(e){
// return e.firstChild.checked
//}).forEach(function (e) {
// e.remove();
//})
deselectionDefExpression();
}); I could also use some assistance on adjusting my definitionExpression based on what is deselected. The act of selection and deselection should make the extend of my features change, thus re-positioning the map as well. Any suggestions or samples would be greatly appreciated. Thanks!
... View more
06-05-2017
12:12 PM
|
0
|
4
|
1258
|
POST
|
Robert, That worked great. What do you suggest out zooming to the extent of the selection?
... View more
05-24-2017
01:19 PM
|
0
|
1
|
638
|
POST
|
Hi Robert, The reason I was looping twice was to create a list of the selected rows in my grid. My end goal with this is to dynamically create a definition expression out of the selected rows. As rows are selected and the definition expression is created, I would like my map to zoom and center on envelope (extent) of my selections. I know that this is a lot to do at once, but any suggestions would be great. By the way I am using 4.3. Thanks, Jacob
... View more
05-24-2017
12:52 PM
|
0
|
3
|
638
|
POST
|
Hi Robert, Thanks for looking at this. I think you are right about making sure I am calling a string, but unfortunately that change didn't fix the definition expression error.
... View more
05-22-2017
03:09 PM
|
0
|
5
|
638
|
POST
|
I am having issues setting a definitionExpression based on OnDemandGrid row selection with ArcGIS API for Javascript. I keep getting an error stating that definitionExpression is not a function and I don't understand why. Below is my code: var selectedRows = [];
grid.on('dgrid-select', function (event) {
var stateName = event.rows[0].data.stateName;
var rows = event.rows;
for (i = 0; i < rows.length; i++) {
selectedRows.push(stateName);
}
for (i = 0; i < selectedRows.length; i++) {
stateLayer.definitionExpression('STATE_NAME = "' + i + '"');
}
console.log(selectedRows);
});
... View more
05-22-2017
02:39 PM
|
0
|
7
|
1032
|
POST
|
I currently have a drop down that is used to filter a Feature Layer by unique field values. I would now like to view the results of my query in a table that displays only after the the drop down choice has been made. The table should then refresh if an additional value is chosen. I would like to implement this with dgrid/Grid so that I can add additional, 'grid related', functionality down the road. Has anyone done this before? If so, could you please provide some sort of sample as I am fairly new to working with dojo.
... View more
05-03-2017
11:20 AM
|
0
|
1
|
618
|
POST
|
Robert, This work sample code is exactly what I needed. Thank you for your input and patience!
... View more
05-02-2017
04:46 AM
|
0
|
1
|
2463
|
POST
|
Thanks for your help, but I am now sure exactly where to insert the return distinct values code. Do you have a sample that I could use as a learning guide?
... View more
04-27-2017
01:14 PM
|
0
|
7
|
2463
|
POST
|
Hi Robert, Thank you for your suggestion. My next question is; once the first value is chosen and you set the where clause for the second query, do you repeat the same steps for the second dropdown that you did for the first? Below is my code: require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"dojo/on",
"dojo/dom",
"dojo/dom-construct",
"dojo/domReady!"
],
function (
Map, MapView,
FeatureLayer,
on, dom, domConstruct
) {
var statesURL = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3"
var subRegionSelect = dom.byId("subRegion");
var stateNameSelect = dom.byId("stateName");
var statesLayer = new FeatureLayer({
url: statesURL,
outFields: ["SUB_REGION", "STATE_NAME"],
visible: false
});
var map = new Map({
basemap: "gray",
layers: [statesLayer]
});
var view = new MapView({
container: "viewDiv", // Reference to the scene div created in step 5
map: map, // Reference to the map object created before the scene
zoom: 4, // Sets the zoom level based on level of detail (LOD)
center: [-96.01956, 39.967514] // Sets the center point of view in lon/lat
});
view.then(function () {
return statesLayer.then(function () {
var subRegionQuery = statesLayer.createQuery();
return statesLayer.queryFeatures(subRegionQuery);
});
})
.then(getValues)
.then(getUniqueValues)
.then(addToSelect);
// return an array of all the values in the
// SUB_REGION field of the states layer
function getValues(response) {
var features = response.features;
var values = features.map(function (feature) {
return feature.attributes.SUB_REGION;
});
return values;
}
// return an array of unique values in
// the SUB_REGION field of the states layer
function getUniqueValues(values) {
var uniqueValues = [];
values.forEach(function (item, i) {
if ((uniqueValues.length < 1 || uniqueValues.indexOf(item) === -1) && (item !== "")) {
uniqueValues.push(item);
}
});
console.log("'" + uniqueValues + "'");
return uniqueValues;
}
// Add the unique values to the subregion
// select element. This will allow the user
// to filter states by subregion.
function addToSelect(values) {
values.sort();
values.forEach(function (value) {
var option = domConstruct.create("option");
option.text = value;
subRegionSelect.add(option);
});
return setSubRegionDefinitionExpression(subRegionSelect.value);
}
function setSubRegionDefinitionExpression(newValue) {
statesLayer.definitionExpression = "SUB_REGION = '" + newValue + "'";
if (!statesLayer.visible) {
statesLayer.visible = true;
}
console.log(newValue)
}
on(subRegionSelect, "change", function (evt) {
var type = evt.target.value;
setSubRegionDefinitionExpression(type)
//setStateNamenDefinitionExpression(type)
})
});
... View more
04-27-2017
10:10 AM
|
1
|
9
|
2463
|
POST
|
I am currently working with ArcGIS API for Javascript 4.3 and I am having issues with creating dependent drop downs as a means of filtering multiple fields. For instance, in the following Feature Service: Layer: states (ID: 3) , I am wanting to have one drop down that is populated by SUB_REGION and then another dependent drop down that is populated by STATE_NAME based on the first drop down's selection. I am fairly new to this so any suggestions or samples would be greatly appreciated.
... View more
04-21-2017
12:33 PM
|
0
|
11
|
5744
|
Title | Kudos | Posted |
---|---|---|
1 | 04-27-2017 10:10 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|