Issue Upgrading to version 3.0

5501
18
06-14-2012 05:13 AM
AdamConner
New Contributor
I am attempting to upgrade to version 3.0 of the API, and I have started getting errors.  The error I get is seen in the sample http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html  I imagine this is a bug since the sample is broken as well.  Has anyone else seen or resolved this issue?

Thanks,
Adam Conner
City of Philadelphia
0 Kudos
18 Replies
RobertWinterbottom
Occasional Contributor
Robert,

Check out the 'Migrating to 3.0' doc for some tips on upgrading your app:

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/migration_30.htm

If that doesn't help can you provide a code snippet that shows the problem?


Sure, I actually spoke a hair too soon about the "Type Error: cannot call method 'setRenderer' of null", after I posted my first comment I closed the browser and restarted it and I was no longer receiving that error, so now the map is up and running but I am still getting an error on creating an extent, Uncaught ReferenceError: esri is not defined, it is pointing to this little bit of code :
var initExtent = new esri.geometry.Extent({
    "xmin":-15654227.28,
    "ymin":1644618.94,
    "xmax":-6848681.62,
    "ymax":7514982.71,
    "spatialReference":{
      "wkid":102100}
});
 
I have noticed that if I comment this section out, on the next line of this file I create a symbol object and then I get the same error saying esri is not defined pointing to the symbol object instead, Ill include that code as well just in case it can help
var sfs = new esri.symbol.SimpleFillSymbol(
          esri.symbol.SimpleFillSymbol.STYLE_SOLID,
          new esri.symbol.SimpleLineSymbol(
            esri.symbol.SimpleLineSymbol.STYLE_SOLID,
            new dojo.Color([0, 0, 0]), 
            0.5 
          ),
          null
);

Thanks in advance.
0 Kudos
KellyHutchins
Esri Frequent Contributor
The posted code looks fine. Can you post your complete app or better yet a simplified version that will demonstrate the problem?

Sure, I actually spoke a hair too soon about the "Type Error: cannot call method 'setRenderer' of null", after I posted my first comment I closed the browser and restarted it and I was no longer receiving that error, so now the map is up and running but I am still getting an error on creating an extent, Uncaught ReferenceError: esri is not defined, it is pointing to this little bit of code :
0 Kudos
MattLane
Occasional Contributor II
RWinter85, in my experience when you get that error, you are using the esri object before it has been downloaded and defined. Meaning you are probably calling it before the DOM is ready.
0 Kudos
RobertWinterbottom
Occasional Contributor
Thanks for the quick response everyone.  Matt that was it.  I had moved those two sections of code to a separate .js file where I kept all of my global variables, so I moved them again but this time into my onLoad function which get's added on load and that fixed it.  I am glad it turned out to be an easy fix.  Thanks again.
0 Kudos
JorgeFiallega
New Contributor
when trying to display any of the examples from the browser hitting directly the page by using file:///
I get 4 error that do NOT allow the map to display.
Version 2.8 works perfectly fine. and version 3.0 also works fine if I display it form a server as you guys have said.
I still would like to work locally hitting the page directly.
Here are the errors, two of which are the Access-Control-Allow-Origin but there are 2 more:

XMLHttpRequest cannot load http://serverapi.arcgisonline.com/jsapi/arcgis/3.0compact/js/esri/nls/jsapi_en-us.js. Origin null is not allowed by Access-Control-Allow-Origin.

Error
serverapi.arcgisonline.com:15
_428 serverapi.arcgisonline.com:15
dojo._ioSetArgs.ld serverapi.arcgisonline.com:15
_1c6 serverapi.arcgisonline.com:15
_1c4 serverapi.arcgisonline.com:15
dojo.Deferred.reject.errback serverapi.arcgisonline.com:15
dojo.Deferred._1c3.cancel.cancel serverapi.arcgisonline.com:15
dojo.xhr serverapi.arcgisonline.com:15
dojo.xhrGet serverapi.arcgisonline.com:15
_17e serverapi.arcgisonline.com:15
_4b9 serverapi.arcgisonline.com:15
_17e serverapi.arcgisonline.com:15
_14f._preloadLocalizations._19b serverapi.arcgisonline.com:15
_186 serverapi.arcgisonline.com:15
_199 serverapi.arcgisonline.com:15
_14f._preloadLocalizations serverapi.arcgisonline.com:15
(anonymous function) serverapi.arcgisonline.com:34
_c7 serverapi.arcgisonline.com:15
_36 serverapi.arcgisonline.com:15
_16 serverapi.arcgisonline.com:15
req serverapi.arcgisonline.com:15
(anonymous function) serverapi.arcgisonline.com:34

XMLHttpRequest cannot load http://serverapi.arcgisonline.com/jsapi/arcgis/3.0compact/js/dojo/dojox/gfx/svg.js. Origin null is not allowed by Access-Control-Allow-Origin.

Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101
0 Kudos
JeffPace
MVP Alum
Just to double check, you aren't running this file locally are you? You could do this at 2.8, you can not at 3.0.  You have to run it from a webserver.
0 Kudos
JorgeFiallega
New Contributor
Thanks for the response.
Yes I am. Could you tell me what the difference is between 2.8 and 3.0 that I can not run it as a local file ?
0 Kudos
JeffPace
MVP Alum
0 Kudos
AndrewRowe
New Contributor
I solved my error by moving my code into the function that is called by the dojo.ready(init) method.  Using some esri methods before dojo is ready seems to generate the:

     Uncaught ReferenceError: esri is not defined

error.
0 Kudos