Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Arcgis Javascript dojoConfig relative path of packages

I am using Arcgis Javascript API. API is built on dojo toolkit. So I need to use dojo features in API. I am preparing dojo config file as following.

var pathRegex = new RegExp("/\/[^\/]+$/");
var locationPath = location.pathname.replace(pathRegex, '');

var dojoConfig = {
    async: true,
    parseOnLoad: false,
    baseUrl:"js/",
    packages: [
    {
        name: "application",
        location: locationPath + '/js/application'
    }]    
};

I created a bootstrapper.js like following.

require(["application/main", "dojo/domReady!"], function (application) {
    console.log("bootstrapper is running");

    application.Run();
})

And index.html file is like this.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Arcgis Javacsript API Samples</title>

        <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
        <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css">
    </head>

    <body class="claro">
        <div id="map"></div>

        <script src="//js.arcgis.com/3.6/"></script>
        <script src="js/application/djConfig.js"></script>
        <script src="js/application/bootstrapper.js"></script>
    </body>
</html>

My application is hosted on IIS and has addres like this htp://domain/Demo/Sample1/index.html

when I run application, this code giving error like following.

"NetworkError: 404 Not Found - http://js.arcgis.com/3.6/js/dojo/application/main.js" enter image description here

If I set bootstrapper.js file as following, problem is solwing.

require(["js/application/main.js", "dojo/domReady!"], function (application) {
    console.log("bootstrapper is running");

    application.Run();
})

enter image description here

like image 461
barteloma Avatar asked Sep 10 '13 08:09

barteloma


People also ask

What is ArcGIS dojo?

The Esri developers who created the ArcGIS API for JavaScript used Dojo to simplify their development process and to ensure that the applications you build behave the same in different browsers. For example, the map zoom and panning animations use Dojo, as does the graphics layer.

How do I find the relative path of a file in ArcGIS?

Summary. ArcGIS doesn't allow you to enter relative paths using dot/double-dot notation. Rather, relative paths are stored in the document or toolbox (once you check the Store relative path names option). Relative paths are relative to a current directory, which is the location of the saved document or toolbox.

How do I create a map in ArcGIS Pro?

Add your data to the map. Click the File menu and click Map Document Properties (ArcMap) or Globe Document Properties (ArcGlobe). Check the option to store relative path names and click OK to apply the settings. Click the Publisher menu and click Publish Map.

What is the ArcGIS API for JavaScript?

The Esri developers who created the ArcGIS API for JavaScript used Dojo to simplify their development process and to ensure that the applications you build behave the same in different browsers. For example, the map zoom and panning animations use Dojo, as does the graphics layer.


1 Answers

Try to change your script order in index.html file. Your config settings should load before CDN.

    <div id="map"></div>

    <script src="js/application/djConfig.js"></script>
    <script src="//js.arcgis.com/3.6/"></script>
    <script src="js/application/bootstrapper.js"></script>
</body>
like image 192
bayramucuncu Avatar answered Sep 19 '22 03:09

bayramucuncu