RequireJS加载ArcGIS API for JavaScript

1.在main.js中配置ArcGIS API for JavaScript

require.config({
  paths : {
    //arcgisJS
    "esri": "libs/arcgisJS/esri",
    "dojo": "libs/arcgisJS/dojo",
    "dojox": "libs/arcgisJS/dojox",
    "dijit": "libs/arcgisJS/dijit",
  }
});

2.加载所需的模块

define([
        "esri/urlUtils",
        "esri/config",
        "esri/map",
        "esri/layers/ArcGISTiledMapServiceLayer",
        "esri/geometry/Point",
        "esri/graphic",
        "esri/SpatialReference",
        "esri/tasks/GeometryService",
        "esri/tasks/ProjectParameters",
        "esri/tasks/FeatureSet",
        "esri/dijit/PopupMobile",
        "esri/geometry/Extent",
        "dojo/dom-construct"
        ], function (app, urlUtils, esriConfig, Map, ArcGISTiledMapServiceLayer, Point, Graphic,
                SpatialReference, GeometryService, ProjectParameters, FeatureSet, PopupMobile,
                Extent, domConstruct) {
});

3.缺点

这样的方式不是官方推荐的方式,说白了就是一个无奈的办法。这样带来的一个大缺点就是页面加载之后就把所有有关的ArcGIS API for JavaScript文件全部下载下来,而不是按模块下载。

4.补充

鉴于上面的办法太搓了,建议还是在页面嵌入iframe,在iframe里面写gis的代码吧!互不干扰,方为上策!

posted @ 2015-11-12 14:50  laixiangran  阅读(3134)  评论(3编辑  收藏  举报