Using Durandal dojoConfig and ESRI Maps

南楼画角 提交于 2019-12-11 05:29:07

问题


I'm trying to get ESRI maps working with Durandal and came across this link in the Durandal docs DurandalEsri

This seems to work but now Durandal is having problems finding some of my .js files. If I leave the following dojoConfig out my scripts are found but then the maps won't work.

`var dojoConfig = {
    baseUrl: './',
    async: true,
    tlmSiblingOfDojo: true,
    parseOnLoad: false,
    aliases: [['text', 'dojo/text']],
    packages: [
        { name: 'esri', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri' },
        { name: 'dojo', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojo' },
        { name: 'dojox', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox' },
        { name: 'dijit', location: '//serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit' },
        { name: 'durandal', location: 'App/durandal' },
        { name: 'views', location: 'App/views' },
        { name: 'viewmodels', location: 'App/viewmodels' },
        { name: 'lib', location: 'App/lib' }
    ]
};`

My app structure looks like this:

  • App
    • durandal
    • lib
    • services
    • viewmodels
    • views

So in my shell.js file if I try to pass in 'lib/config' I get a 404 because it tried to find the config file at localhost/lib/config.js instead of localhost/dashboard/app/lib/config.js

If I pass 'dashboard/app/lib/config' to shell.js the file will be found, but it doesn't seem like I should have to specify the entire path, since 'durandal/system' and anything else under the 'durandal' folder get found correctly.

Any ideas???


回答1:


I encountered a similar problem using AMD module loading with Esri. I solved it using a configuration similar to yours but with the following baseurl:

baseUrl: location.pathname.replace(/\/[^/]+$/, '') + '/path/to/app/main'

As described in Jeffrey Grajkowski's answer to my question here: https://stackoverflow.com/a/15390919/1014822




回答2:


So for my scenario of Durandal + Esri + Dojo, I had to leave out the require.js file that is included with Durandal and use the dojo AMD loader. Unfortunately I have no idea what future problems this might cause. More info can be found here



来源:https://stackoverflow.com/questions/16927104/using-durandal-dojoconfig-and-esri-maps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!