Getting data from a feature layer point using a custom widget

867
7
03-21-2019 02:19 PM
NickHallal
New Contributor II

Hey all, 

I have a map set up with a layer including latitude, longitude, and an ID for each data point.  I've been trying to set it up so that my custom widget, while open, will receive the lat, lon, and ID from a layer point if I select it.  I've tried using the coordinate widget to select, but that doesn't take notice of the points in my layer at all, though it does give lat and lon to my custom widget at least.  Anyone happen to know a good way to go about this, or even just a direction to point me in? I've been browsing through similar built-in widgets like the Attribute Table widget, or the Select widget, but I haven't made much progress with those avenues yet. 

Thanks!

Tags (2)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus

Nicholas,

   So is your custom widget using the jimu drawBox dijit to enable the user to draw a geometry on the map like an extent or point and then using that geometry to execute a QueryTask against your features map service and thus return the attributes of the selected feature which would include the geometry(i.e. lat lon) and id?

0 Kudos
Arne_Gelfert
Occasional Contributor III

Not entirely sure what you're trying to do but if you're trying to return attributes for a feature when click on a map created using JSAPI, does something like this not accomplish that: https://developers.arcgis.com/javascript/latest/sample-code/featurelayer-query/index.html ?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Arne,

   The question is specific to WAB Which uses JS API 3.x.

0 Kudos
Arne_Gelfert
Occasional Contributor III

Didn't notice that but - OMG! - when will they ever get all these different versions of the API straightened out. How come 4.x still can't do what 3.x could! Who would release the new version of car when it has only 3 functioning wheels! Ok, I'll be quiet.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Arne,

   Many people have asked that question (why are they not in parity). Well the answer is simple the 3.x API has been out for Many years and the 4.x API is being built new and has only been out a few years and has yet to get all the features that the 3.x api has. 

0 Kudos
NickHallal
New Contributor II

I might very well be wrong, but my understanding of the Query widget was that it found points that had certain attributes and then returned those points, rather than the information I am looking for at each point.  Each point in the feature layer has a latitude, longitude, and a unique integer ID that corresponds to data in a separate file, which might contain a temperature at regular time intervals for each ID.  I can use that ID in my custom widget file to access the data set, which I keep in the same folder as the Widget.js file, which I'm creating a chart from.  So, the only problem I'm running into right now, is that when using this widget, I want the user to click on one point in the feature layer, then have that point send its ID to my Widget.js file, which I can then easily use to access my data and display a chart of temperatures over time at each ID. 

I can get the coordinates widget to send my Widget.js file the latitude and longitude, but can't seem to figure out through my toying around how to get a point from a feature layer to send its ID to the Widget.js file.  Maybe I'm misunderstanding something simple, but I'm very appreciative of any help I can get.  Thanks!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nicholas,

   I said QueryTask (JS API object) not Query widget.

0 Kudos