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
I was able to get rid of the cross origin error by adding the allow cross origin header. I used the instructions here: http://enable-cors.org/ I still get the "Uncaught TypeError: Cannot read property 'className' of null " error even after this is fixed, this is the issue I am considering to be a bug until I hear otherwise.
This error can be ignored - here's a blurb from the help on this error:
Automatic detection of CORS support. This is done by attempting to access the /<instance-name>/rest/info endpoint of any ArcGIS server instance used in an ArcGIS API for JavaScript application. For servers that do not support CORS, this request will fail and an error will be logged to the browser's developer console. This can be observed in most of the API's samples as the majority of the servers used do not support CORS. This error can safely be ignored. There are cases where the API will not send a request to /<instance-name>/rest/info and are as follows:
The browser does not support CORS
The Server is already listed in esri.config.defaults.io.corsEnabledServers
esri.config.defaults.io.corsDetection is false
JSON is used instead of JSONP in the following cases:
The resource being fetched is on the same domain as the application
The resource being fetched is on a server that supports CORS
To read the blurb in context see the API reference for esri.request
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/namespace_esri.htm
var basemapGallery = new esri.dijit.BasemapGallery({ showArcGISBasemaps:false, basemaps:basemaps, map:map },"basemapGallery"); basemapGallery.startup();
esri.dijit.BasemapGallery.prototype._markSelected = function (basemap) { if (basemap) { // unselect all basemap gallery items dojo.forEach(dojo.query(".esriBasemapGallerySelectedNode", this.domNode), function (node) { dojo.removeClass(node, "esriBasemapGallerySelectedNode"); }); // select current basemap gallery item var basemapNode = dojo.byId("galleryNode_" + basemap.id); if (basemapNode) { dojo.addClass(basemapNode, "esriBasemapGallerySelectedNode"); } } }
Kelly,
the CORS issue I am fine with ignoring, the fact that the sample code for creating a basemap gallery breaks is not related to CORS. The link to the sample is here http://help.arcgis.com/en/webapi/javascript/arcgis/demos/widget/widget_basemapManual.html
on line 83var basemapGallery = new esri.dijit.BasemapGallery({ showArcGISBasemaps:false, basemaps:basemaps, map:map },"basemapGallery"); basemapGallery.startup();
that call causes an uncaught error: "Uncaught TypeError: Cannot read property 'className' of null "
this is the issue that still exists and cannot be ignored.
Im having a similar issue. I upgraded my map to 3.0 this morning and at first it would not work at all until I moved some variables around. Got it too work temporarily, went to lunch, and when I got back it was no longer working. The error is "Type Error: cannot call method 'setRenderer' of null". It is referring to where I call map.graphics.setRenderer(renderer), I had it working on 2.8 and even on 3.0 for a little but all of sudden the map stopped working. Also getting "Uncaught Error: esri is not defined" when I try to create an extent object to be used as my initial extent.