Select to view content in your preferred language

how to require graphicsUtils in v3

3247
2
Jump to solution
05-19-2014 12:34 PM
LarsHuttar
New Contributor III
Hello,
I'd been using esri.graphicsExtent() back in API v1.5 or so.
I'm now migrating to JS API v3 (with ArcGIS 10.1 on the server side).

My code that uses esri.graphicsExtent() no longer works, but I see from https://developers.arcgis.com/javascript/jsapi/esri.graphicsutils-amd.html that the graphicsExtent() function is now under the esri/graphicsUtils namespace. The example there shows the use of

require([   "esri/graphicsUtils", ...  ], function(graphicsUtils, ... ) {   var myFeatureExtent = graphicsUtils.graphicsExtent(myFeatureSet.features);   ... });


But when I try following that pattern, I get the error

   NetworkError: 404 Not Found - https://js.arcgis.com/3.0/js/dojo/esri.graphicsUtils.js

in my javascript console.

I've also tried
dojo.require("esri.graphicsUtils");
, but it doesn't work either.

My JS API script loading tag looks like this:
<script type="text/javascript" src="https://js.arcgis.com/3.0/"></script>


What do I need to do to successfully load the graphicsUtils namespace?
Thanks for any suggestions.

P.S. my "require()" code is inside a function that's not called until a particular UI feature is used.
Could it be important that the require() code be outside of any functions, at the outer script level?
Currently, at that level I have a series of dojo.require() statements like

dojo.require("esri.tasks.query"); dojo.require("esri.tasks.identify");

Adding dojo.require("esri.graphicsUtils"); there doesn't work.
Nor does dojo.require("esri/graphicsUtils");

Either way, I get a 404 Not Found on
https://js.arcgis.com/3.0/js/esri/graphicsUtils.js

P.P.S. Did something about this namespace change between 3.0 and 3.9? The viewshed sample (https://developers.arcgis.com/javascript/jssamples/gp_viewshed.html) seems to use this module successfully.
0 Kudos
1 Solution

Accepted Solutions
LarsHuttar
New Contributor III
I called ESRI tech support, and the knowledgeable analyst helped me discover the problem.

  • the API documentation I was using was the variant for AMD

  • AMD is only available for v3.4+, or thereabouts. Not in v3.0.

  • for non-AMD code, you use esri.graphicsExtent().

I tried using esri.graphicsExtent(), and it worked!

So ... what was my problem originally, that started all this?
I really don't know why esri.graphicsExtent() didn't work before. Possibly because it was being used before the scripts had finished loading??

View solution in original post

2 Replies
LarsHuttar
New Contributor III
I called ESRI tech support, and the knowledgeable analyst helped me discover the problem.

  • the API documentation I was using was the variant for AMD

  • AMD is only available for v3.4+, or thereabouts. Not in v3.0.

  • for non-AMD code, you use esri.graphicsExtent().

I tried using esri.graphicsExtent(), and it worked!

So ... what was my problem originally, that started all this?
I really don't know why esri.graphicsExtent() didn't work before. Possibly because it was being used before the scripts had finished loading??
BWSCIM
by
New Contributor III

Struggled with this too until I found your post!  Good stuff - the devils in the details and with all the documentation ESRI provides sometimes you end up on the wrong page.

Thanks Lars...

0 Kudos