POST
|
Thanks! But the correct solution was to use response.results[i].layer.title, not name.
... View more
06-22-2023
09:29 AM
|
0
|
0
|
859
|
POST
|
Thanks, but when I do that it just returns "[object Object]"
... View more
06-22-2023
09:17 AM
|
0
|
0
|
870
|
POST
|
I have a web map with multiple feature layers loaded in it. I need the user to click on a specific layer, though I can never be sure which other layers they may or may not have turned on. I need to extract some info from the one particular layer, but because it might not be the top layer I can't always be sure it's going to be the zeroth layer they clicked on. So I'm thinking if I could get the layer name(s) that were clicked on I could then get the index of the correct layer and extract my info from there. The problem is I can't find anything in the API for hitTest or FeatureLayer or anywhere else that tells me how I can get the layer name. var parcels = new FeatureLayer({
url: myURL1,
title: "Parcels"
});
var schools = new FeatureLayer({
url: myURL2,
title: "School Districts"
});
myMap.add(parcels);
myMap.add(schools);
myView.on("click", (event) =>
{
myView.hitTest(event).then((response) =>
{
// need something in here to grab layer name(s), but first get total # of layers
var layerCount = response.results.length;
for(var i = 0; i < layerCount; i++)
{
// how do I get the layer name(s) here?
var layername = response.results[i].???????
}
});
});
... View more
06-22-2023
09:00 AM
|
0
|
4
|
877
|
POST
|
Hello, I'm new-ish to experience builder and am coming up blank trying to figure out how to do something that might be pretty basic. I have a custom widget I'm trying to make to export the data from a feature layer in the map to a .csv file. But before I do that I'm first just trying to figure out how to access the layers in the map widget from my custom widget. I've looked over the EB docs and some examples but they aren't very useful. To start I have the code below. I have a pull-down which I want to get the layer names from the map widget. I don't want to have to hard-code the layer sources or anything because the layers in the map might change. import { React, AllWidgetProps, jsx } from 'jimu-core';
import { JimuMapViewComponent, JimuMapView } from 'jimu-arcgis';
import { IMConfig } from '../config';
function tableToCSV()
{
// will do something here
}
export default class Widget extends React.PureComponent<AllWidgetProps<IMConfig>, state> {
constructor (props)
{
super(props)
this.state = {
value1: "test1",
value2: "test2",
value3: "test3"
}
}
render ()
{
return (
<br/>
<div style={{ padding:10;margin:10;}}>
<label for="toolSelect"><b>Select Layer to Download CSV:</b></label><br/>
<select id="toolSelect" class="btn btn-primary dropdown-toggle">
<option>{this.state.value1}</option>
<option>{this.state.value2}</option>
<option>{this.state.value3}</option>
</select>
<br/>
<br/>
<br/>
<button onClick={tableToCSV}>Download CSV</button>
</div>
);
}
} I want to load the layer names where the value1: "test1" (and so on) lines are. How do I do that? Also, for my next step after that, if I want to convert the data in the layer table to a csv, will I need to load a Table widget into my map, or can I just use a feature layer?
... View more
07-27-2022
10:38 AM
|
0
|
0
|
336
|
POST
|
Still getting the "TypeError: highlightSelect.remove is not a function" error message. However, at least it's clearing the newest selected feature instead of the one I want to be selected (which is the previous selected feature), so maybe at least it's doing *something*
... View more
07-27-2021
03:03 PM
|
0
|
1
|
2394
|
POST
|
^ I've already tried that. My feature is already selected before I even enter my function. If I try to just do ... if(highlightSelect)
highlightSelect.remove(); ... it has no idea what highlightSelect is. So I have to define it beforehand ... somehow. I could try this: function unselectParcel()
{
myView.whenLayerView(myLayer).then(function(layerView)
{
myLayer.queryFeatures(query).then(function(result)
{
let query = myLayer.createQuery();
query.where = "MyFieldName = '" + myVariable + "'";
let highlightSelect;
highlightSelect = myView.highlight(result.attributes["OBJECTID"]);
if(highlightSelect) highlightSelect.remove();
});
});
} ... but of course that doesn't work because I'm passing in a query to myLayer.queryFeatures that isn't even declared or defined yet. So I next try this: function unselectParcel()
{
myView.whenLayerView(myLayer).then(function(layerView)
{
let query = myLayer.createQuery();
query.where = "MyFieldName = '" + myVariable + "'";
myLayer.queryFeatures(query).then(function(result)
{
let highlightSelect = result.features[0];
highlightSelect.remove();
});
});
} Which gives me the error message: "TypeError: highlightSelect.remove is not a function." Which is what I mentioned in my first post here.
... View more
07-27-2021
01:57 PM
|
0
|
0
|
2405
|
POST
|
This is sort-of a follow-up to my thread here: https://community.esri.com/t5/arcgis-api-for-javascript-questions/querying-one-feature-layer-to-use-to-query-another/m-p/1076044#M73742 I'm now trying to do the opposite: I need to unselect/clear an already selected feature in a feature layer, using a query or anything else besides getting the Popup involved. I have looked through the 4.X API as well as some examples on this board, but can't find anything that works. In the API for FeatureLayerView.highlight there is a snippet that uses highlight.remove(), but every time I try to use it, my developer console tells me that the .remove() is not a function, which doesn't surprise me because there is no .remove function anywhere I can find in the API. I am trying to do something like this. FYI the myVariable variable is something I've already retrieved earlier that will represent the feature that's been highlighted. function unselectParcel()
{
var myQuery = myLayer.createQuery();
myQuery.where = "MyFieldName = '" + myVariable + "'";
myLayer.queryFeatures(myQuery).then(function(response)
{
myView.whenLayerView(myLayer).then(function(layerView)
{
var feature = response.features[0];
layerView.highlight.remove(feature.attributes["OBJECTID"]);
});
});
} As I said, the .remove() does not work, and I've tried all kinds of different iterations of it, to no avail. I've also tried putting the queryFeatures inside of the whenLayerView and all kinds of other arrangements, but since my selecting-the-feature function works fine and all I want to do is the reverse of that, it seems like I should just be able to make a minor change to that selecting-the-feature code - right? I can't believe they have a "highlight" function but no "clear" or "un-highlight" function.
... View more
07-27-2021
11:03 AM
|
0
|
5
|
2459
|
POST
|
Thanks, that works. Specifically I've got this: myView.on("click", (event) =>
{
myView.hitTest(event).then((response) =>
{
var result = response.results[0].graphic.attributes;
var myVar = result.Thing;
});
});
... View more
07-23-2021
07:59 AM
|
0
|
0
|
803
|
POST
|
I have a feature layer and I'm trying to grab an attribute from a feature the user clicked on. The standard way to do that would be to do something like: myView.popup.watch("selectedFeature", function()
{
if(myView.popup.selectedFeature != null)
{
var myVar = myView.popup.selectedFeature.attributes.Thing;
}
} The problem with doing that is that every time the popup pops up, it runs that code. For example, if you also have a search widget that searches for something and selects something in another layer, it thus has a popup, and then runs that code anyway simply because it has a popup. But of course since that search is dealing with a totally different layer, you don't want that code to be invoked. That is, it's running that listener for no reason at all. What I would like to do is something like this: myView.on("click", function ()
{
var myVar = myView.selectedFeature.attributes.Thing;
} This would let me deal with the selected feature totally independent of any popup. Unfortunately, as far as I can tell that's impossible because for some reason ESRI decided to make the selected feature an attribute of the popup instead of an attribute of the view or the feature layer (which would make a ton more sense, but I digress). Anybody have any ideas?
... View more
07-22-2021
03:28 PM
|
0
|
2
|
879
|
POST
|
Actually, I take that back. I need to strip out the city and zip from my search term! Unfortunately that creates other problems, since I want the city and zip i the search term.
... View more
07-06-2021
03:08 PM
|
0
|
0
|
376
|
POST
|
Sorry, ADDPTKEY is PARCELNUM. I changed the name in the code here for clarity but forget to do so in the last post. I just fixed it here.
... View more
07-06-2021
02:50 PM
|
0
|
0
|
1821
|
POST
|
Actually, I was testing that on the code you gave me. In my original code nothing comes up at all in that section. If I do ... addressPtsLayerSearch.queryFeatures(ptsQuery).then(function(response)
{
alert(response.features[0]);
var feat = response.features[0].attributes;
parcelnum = feat.PARCELNUM;
});
alert("parcelnum is " + parcelnum); ... the parcelnum popup comes first (undefined) and then the popup with response.features[0] comes up second as undefined also.
... View more
07-06-2021
02:31 PM
|
0
|
2
|
1868
|
POST
|
No. If I stick a popup in there with something like: alert(response.features[0]); I get "undefined" on the popup. If I do: alert(response.features[0].attributes["PARCELNUM"]); nothing comes up at all, not even a blank popup. Not sure what else to try (I like using popups for debugging).
... View more
07-06-2021
02:25 PM
|
0
|
3
|
1868
|
POST
|
That didn't work. I even stuck an alert popup at various points in that code and it never even got invoked. I also tried: parcelnum = response.features[0].attributes.ADDPTKEY; per Blake's suggestion above to no avail.
... View more
07-06-2021
02:11 PM
|
0
|
5
|
1876
|
Online Status |
Offline
|
Date Last Visited |
05-20-2024
09:23 PM
|