Select to view content in your preferred language

Add a Graphic to Web Map in WAB

2267
12
Jump to solution
12-19-2018 09:29 AM
michael_vetter
Occasional Contributor

I'm trying to create a custom WAB widget that shows the locations of restaurants that are within a mile radius from an address that the user enters. I'm using the Yelp API through an esriRequest call. The results contain that lat/long of the restaurants. These lat/long values are what I want to use for the location of the graphics. It appears that creating the graphic is successful, but when I use this.map.graphics.add(graphic) I get an error message of init.js:114 TypeError: Cannot read property 'add' of undefined

Any help would be greatly appreciated!

0 Kudos
12 Replies
michael_vetter
Occasional Contributor

Robert,

I tried using the .applyEdits, but the layer didn't draw and there were no features in the feature layer.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Michael,

   You have to have something off in your widget code again then. I use a FeatureLayer from a collection in several of my custom widgets like the eSearch and Identify widget and I do not have an issue.

0 Kudos
michael_vetter
Occasional Contributor

Robert,

I ended up adding each graphic individually to the feature layer in my for loop. This might not be the most correct way of adding the graphics to the feature layer, but it worked.

I really appreciate all your help!