3.1 api (local install) accessing files from http://serverapi.arcgisonline.com/j

945
10
Jump to solution
08-17-2012 11:33 AM
JeffPace
MVP Alum
I have a local install of 3.1

accessed via
http://jpgisdev.intranet/arcgis_js_api/library/3.1/arcgis/?v=3.1

however, tons of files seem to be hardcoded and pulling from

http://serverapi.arcgisonline.com/jsapi/


?????
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Occasional Contributor III
I thought I saw this happen the other day but was too involved in something else to track it down, haven't seen it happen since, will keep an eye out though!

Do you set baseUrl in your dojoConfig?

View solution in original post

0 Kudos
10 Replies
JeffPace
MVP Alum
Strange thing is my deployed versions (local intranet, public) work fine, it is only my development version running in netbeans
0 Kudos
__Rich_
Occasional Contributor III
I thought I saw this happen the other day but was too involved in something else to track it down, haven't seen it happen since, will keep an eye out though!

Do you set baseUrl in your dojoConfig?
0 Kudos
JeffPace
MVP Alum
no i have not set the base url.  The path depends on the server its running on, I use proxies to path to the api to avoid cross-domain issues.
0 Kudos
__Rich_
Occasional Contributor III
baseUrl can be relative, does not have to be absolute...
0 Kudos
JeffPace
MVP Alum
ok i was mistaken, all webservers are loading api from serverapi.arcgisonline.com

even though the api is loaded from a local webserver

so

my app runs at www.mymanatee.org/gisapps/mapviewer/index.jsp
the api location is defined in index.jsp as
<script type="text/javascript" src="../../arcgis_js_api/library/3.1/arcgis/?v=3.1"> </script>


the api is hosted at
www.mymanatee.org/arcgis_js_api/library/3.1/arcgis/

so how do i reference it with a baseUrl?

   dojoConfig = {
                    parseOnLoad: true,
                //    baseUrl:'./',
                    packages:[{name:'org/mymanatee',location:hostPath+'/js/org/mymanatee'},
                        {name:'agsjs',location:hostPath+'/agsjs'},
                         {name:'com/esri/solutions/jsviewer',location:hostPath+'/js/com/esri/solutions/jsviewer'},
                        {name:'com/studioat',location: hostPath+'/js/com/studioat'},
                        {name:'org/mymanatee/widgets',location:hostPath+'/js/org/mymanatee/widgets'},
                        {name:'org/mymanatee/common',location:hostPath+'/js/org/mymanatee/common'},
                        {name:'com/esri/solutions/jsviewer/widgets',location:hostPath+'/js/com/esri/solutions/jsviewer/widgets'}],
                    isDebug: false,
                    usePlainJson: true
                };
0 Kudos
JeffPace
MVP Alum
worlds wierdest base url, but it works.  thank you
0 Kudos
__Rich_
Occasional Contributor III
worlds wierdest base url, but it works.  thank you

Cool, glad to have helped.

Not weird IMHO 🙂

For anyone who doesn't understand what that does it just means all dojo module paths start (resolve) "from the current location".

In fact I used to use the same one in the first incarnation of our application, now that we use MVC areas I've had to expand a little as the 'real path' to files isn't the same as the MVC path.  (yes, I know I could fix this via routing and/or url rewriting but it's more visible to use something like Razor's Url.Content())

Doing this also means you don't need to trawl through the files doing the find and replace as per the instructions, obviously won't work for everyone - depends how you've hosted the API but for most common deployments it should be enough just to set this.
0 Kudos
JeffPace
MVP Alum
sorry i was brief, had been starting at the same code for 16 hours

it is wierd because my baseUrl is

baseUrl:'/arcgis_js_api/library/3.1/arcgis/js/dojo/dojo',
0 Kudos
__Rich_
Occasional Contributor III
sorry i was brief, had been starting at the same code for 16 hours

it is wierd because my baseUrl is

baseUrl:'/arcgis_js_api/library/3.1/arcgis/js/dojo/dojo',


Still not weird, Jeff 🙂

i.e. it's relative to the root of the domain.  (that's what the leading slash denotes)

Since both your app and the API are hosted under the same domain this will work for any page that wants to reference the API and lives on the same domain.

(apologies if this bears any resemblance to eggs and vacuums!)
0 Kudos