Esri / esri-loader

A tiny library to help load ArcGIS API for JavaScript modules in non-Dojo applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I'm pointing local hosted Esri API but The Library still making requests to argis.com?

phungxuanvuong opened this issue · comments

When I pointing the esri-loader to the local hosted api:

async initializeMap() {

    const option = this.getWmsService.getOption();
    const mywkid = this.getWmsService.getWKID();

    setDefaultOptions({ url: `http://localhost:4200/assets/3.31/init.js` });
    loadCss('http://localhost:4200/assets/3.31/esri.css');

But The library still make request to argis:

Request URL: https://js.arcgis.com/3.31/esri/layers/WMSLayerInfo.js
https://js.arcgis.com/3.31/dojox/gfx/svgext.js
https://js.arcgis.com/3.31/dojox/gfx/svg.js
...

And some things look like that.

How can I using full hosted localy?

are you certain that the above call to setDefaultOptions() is called before you call loadModules()?

also, can you provide the code for your loadModules() call(s)?

are you certain that the above call to setDefaultOptions() is called before you call loadModules()?

Yes, I have a service to get config of map, in the constructor I have called setDefaultOption:

constructor() {
    setDefaultOptions({ url: `http://localhost:3200/assets/3.31/init.js` });
    loadCss('http://localhost:3200/assets/3.31/esri.css');
    console.log("map share info contructor");
  }

Next: In the Map component, I inject the service to contructor.

constructor(
    private mapShareInfomationService: MapShareInfoService,
    private drawToolService: DrawingToolService,
    private layerListService: LayerPanelService,
    private mapUtilityService: MapUtilityService
  ) {
    super();
  }


  async ngOnInit() {
    await this.initMapCrop();
  }

In initMapCropt function:

    this.boudingBoxValue = this.mapShareInfomationService.getBoudingBox();
    this.extentValue = await this.mapShareInfomationService.getExtentValue();
    this.option = this.mapShareInfomationService.getOption();


    const [Map, GraphicsLayer, Draw] = await loadModules([
      'esri/map',
      'esri/layers/GraphicsLayer',
      'esri/toolbars/draw'
    ], this.option);

I was check by put a console log in constructor of service, It was runned before the loadModule had runned.

what version of esri-loader are you using?

what version of esri-loader are you using?

what version of esri-loader are you using?

The exact version of esri-loader which I'm using in project is: 2.13.0.

what is the value of this.option, i.e. what is returned by this.mapShareInfomationService.getOption();?

what is the value of this.option, i.e. what is returned by this.mapShareInfomationService.getOption();?

It was options = { version: '3.31', css: true }; I have checked by remove it from loadModule, but App still making request to arcgis.com

https://js.arcgis.com/3.31/esri/layers/WMSLayer.js
https://js.arcgis.com/3.31/esri/toolbars/_toolbar.js

passing { version: '3.31', css: true } to loadModules() would be incompatible setDefaultOptions({ url: http://localhost:4200/assets/3.31/init.js` });`.

Can you try passing { url: http://localhost:4200/assets/3.31/init.js` }toloadModules()`?

{ url: http://localhost:4200/assets/3.31/init.js` }

I have tried this, but some resouce still coming from arcgis:

https://js.arcgis.com/3.31/esri/nls/jsapi_en-us.js
https://js.arcgis.com/3.31/dojox/gfx/svg.js
https://js.arcgis.com/3.31/dojox/gfx/filters.js

...

const [Map, GraphicsLayer, Draw] = await loadModules([
      'esri/map',
      'esri/layers/GraphicsLayer',
      'esri/toolbars/draw'
    ], { url: `http://localhost:4200/assets/3.31/init.js` });

This is the first time I called the library.

I suggesting taking a sample page that uses the same modules that you are using, maybe Drawing Tools, and try replacing the script tag URL w/ that of your local build (http://localhost:4200/assets/3.31/init.js) and inspect the network traffic to see if you're still getting some coming from the CDN.

I suggesting taking a sample page that uses the same modules that you are using, maybe Drawing Tools, and try replacing the script tag URL w/ that of your local build (http://localhost:4200/assets/3.31/init.js) and inspect the network traffic to see if you're still getting some coming from the CDN.

I have tried, It still getting some resource from :

https://js.arcgis.com/3.31/dojox/gfx/svg.js
https://js.arcgis.com/3.31/esri/toolbars/draw.js
....

and some in local:

http://localhost:4200/assets/3.31/init.js
http://localhost:4200/assets/3.31/esri.css

...

To me that indicates that the issue is w/ your local build and not with esri-loader. Your build appears to be configured to load some modules from the CDN.

To me that indicates that the issue is w/ your local build and not with esri-loader. Your build appears to be configured to load some modules from the CDN.

Yes, can you suggest me some ideal to me to solve this problem? When I using this library in local server, I can't use internet to get resource from CDN.

That depends on how you generated the build.

If you used bower to build it, I'd suggest opening an issue here: https://github.com/Esri/jsapi-resources/issues.

If you used the web optimizer you can ask on geonet or may need to contact support.