Closed shuai-zh closed 10 years ago
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
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: https://github.com/tomwayson/esri-require-js/issues/1#issuecomment-40753284
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.
@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?
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).
@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...
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.
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.
@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.
I tried your sample but got this error:
Should I add dojo as one of the dependencies?