Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dojo is not defined #1

Closed
shuai-zh opened this issue Apr 17, 2014 · 8 comments
Closed

dojo is not defined #1

shuai-zh opened this issue Apr 17, 2014 · 8 comments
Labels

Comments

@shuai-zh
Copy link

I tried your sample but got this error:

Resource interpreted as Script but transferred with MIME type text/plain: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer?f=json&callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback". script.js:38
Uncaught ReferenceError: dojo is not defined MapServer?f=json&callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback:1

Should I add dojo as one of the dependencies?

@tomwayson
Copy link
Owner

Did you first run the bower install? It's listed as a dependency in bower.json:

https://github.com/tomwayson/esri-require-js/blob/master/bower.json

Tom

@shuai-zh
Copy link
Author

Yes, I installed all the bower components, the error was thrown from the jsonp callback of the ArcGIS Server, I think the dojo object was not in the 'window' scope, however when I manually add the dojo dependency and expose the dojo object to window.dojo in main.js, some other error just occurs.

Are you sure your codes still work now?

Please help me with it, thanks.

从我的android设备发送。

-----Original Message-----
From: Tom Wayson notifications@github.com
To: tomwayson/esri-require-js esri-require-js@noreply.github.com
Cc: Nicolas Zhang nicolasloco@gmail.com
Sent: 星期五, 18 4月 2014 3:31
Subject: Re: [esri-require-js] dojo is not defined (#1)

Did you first run the bower install? It's listed as a dependency in bower.json:

https://github.com/tomwayson/esri-require-js/blob/master/bower.json

Tom


Reply to this email directly or view it on GitHub:
#1 (comment)

@tomwayson
Copy link
Owner

You are correct. I just tried cloning and installing on a new machine and I see the same error.

At first I thought it was the dojo version, but it turned out to be the requirejs version (2.1.11) that was causing the issue. To get it working, use bower to uninstall 2.1.11, get the latest bower.json and then install 2.1.8 by running bower install again.

This should give you a good idea of how unstable this code is. I should put a bigger warning in the README. Besides the fact that this is not a supported way to use the Esri JS API, I can't even say I'd recommend it.

@shuai-zh
Copy link
Author

@tomwayson
Thanks for your effort, that really works for me.

And the reason why we tried to combine Require.js and ArcGIS API for JavaScript is that we already built our app with Require.js and Angular.js, we do not want to break our architecture in order to leverage the map things. I think that ESRI should really think about decouple its JS API with dojo for there may be lots of people who do not use dojo either, I think.

BTW, is there any known issue you would like to share when combining these two frameworks, as you mentioned that you would not recommend it?

@tomwayson
Copy link
Owner

There were some good examples of how to integrate the Esri JS API w/ Angular demoed at the recent Esri DevSummit. You can see the videos and repos here:

@patrickarlt's Example of how to get the 2 libraries to work together and write directives:
video (start around 23 min)
repo

@mpriour expands on the above example by adding more events and updating other parts of the UI outside the map:
repo

FYI - as far as I know, there are no plans to decouple the Esri API from Dojo. That said, there are a lot of efforts within Esri to demonstrate how to integrate our APIs w/ other frameworks. If all you need to do is add some Esri map services to a map on a page w/ simple navigation, you might also look into the Esri leaflet plugin (if you haven't already).

@patrickarlt
Copy link

@chocstarfish I'll chime in here too.

The JS API doesn't support Require JS in any way shape or form. The problem is mostly with the slightly different implementations of the AMD spec especially plugins.

There is some good news...

  1. You could switch to using Dojos AMD loader and plugins and drop Require JS. If you are only using the JS API in one small section of your application this probably isn't practical. In my examples with Angular JS I'm using the AMD loader from Dojo. It might be impractical but it is the most stable option.
  2. Take a look at the Esri Leaflet plugin (which I maintain). Its not as fully featured as the JS API but has a lot of nice features and is improving rapidly. I gave a talk on it at Dev Summit here is the video and slides
  3. Continue using the examples that @tomwayson has laid out here understanding that they are experimental and you might run into issues and you cant update RequireJS.

I agree that those aren't the most attractive options. But for integrating into a large existing application those are probably your options.

Maybe @mpriour can comment. I know he has done some work on this.

@mpriour
Copy link

mpriour commented Apr 22, 2014

Praveen Ponnusamy has been working to alter some build options and configuration settings to allow RequireJS to work properly with the esri js api. These changes made it in to the 3.9 version of the api.
I believe he is working on a blog post to demonstrate the correct usage and configuration required.

@peluja1012
Copy link

@mpriour Do you know if Praveen Ponnusamy published the blog post showing how to get RequireJS to work properly with the esri api? Our team wants to leverage the api but we also can't change our RequireJS based architecture at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants