Accessing the require block

586
2
06-22-2017 09:02 AM
JeffSauder
Occasional Contributor

Hi all,

Is there any way to "access" items in the require block from other javascript files?  I have created global variables for the view, for polygons & graphics, etc., and those are accessible, but one thing I need to access is the geometryEngine, and am unable to do that from another file.  I'm working on a pretty big application so I'm trying to keep things organized.  Or would I just put all my code in one file, inside the require block (that would be one really big fiile)?  I haven't done any major projects with js yet, this is the first, so I'm not sure how this is typically done.  The ESRI samples have all the code in one file but those are usually fairly small.

What I am actually trying to do is return geometry from a query, which works pretty well (I created a polygon / graphic / symbol as global variables).  However, sometimes the query returns multiple polygons, and I was trying to use the geometryEngine to merge them into one polygon (the other alternative would to be create a global array of polygons, but I didn't want to do that).

I was thinking maybe there's a way to "include" the javascript code from another file inside that block, instead of in the html header, so it's like one continuous inline file, but separated into multiple files? Is that possible?

Thanks in advance for your assistance.

Jeff

0 Kudos
2 Replies
SayakNag
New Contributor II

Not sure if this is what you're looking for, but you can have a look at this link.

0 Kudos
JeffSauder
Occasional Contributor

Hi Sayak,

Thanks for the reply. I am able to use global variables that are defined in the require block, that is working OK. However, using the geometryEngine is something that I haven’t been able to do. I don’t think I can declare a global variable as type GeometryEngine in the require block, and calling it from an html button doesn’t recognize it as the html is not in the require block (I even tried setting the html for that element in the require block, and didn’t work). If I put the function in the require block, the function call from the button doesn’t see it. If this isn’t possible I may just have to create an array of polygons in the require block, it just seems like that wouldn’t be the best solution, but maybe it’s the only way.

Thanks

Jeff

0 Kudos