Standalone ArcGIS JS
See original GitHub issueWhen passing an Options object to loadScript using a URL that is pointed at a standalone ArcGIS JS installation, I receive the following error:
TypeError: Cannot read property ‘on’ of undefined
I’m using the npm package create-react-app version 1.1.4 and esri-loader version 2.4.0
The issue only occurs when I point to a local installation of ArcGIS JS. Removing the URL options or pointing it to https://js.arcgis.com/4.5/ or https://js.arcgis.com/4.8/ works without any problems.
Steps to replicate
- npm install create-react-app and esri-loader
- Run npx create-react-app my-test-app
- Open the App.js that has been generated and replace it with the code below and point the options url to a local ArcGIS JS installation
- Make sure the dev server is running and visit localhost:3000, open the debug console for your browser
import logo from './logo.svg';
import './App.css';
import * as esriLoader from 'esri-loader';
class App extends Component {
componentDidMount() {
var options = {
url: "http://localhost:13013/4.5/",
dojoConfig: {
async: true,
baseUrl: "http://localhost:13013/4.5/dojo"
}
};
// has the ArcGIS API been added to the page?
if (!esriLoader.isLoaded()) {
console.log("Is not Loaded");
// no, lazy load it the ArcGIS API before using its classes
esriLoader.loadModules(['esri/Map', 'esri/views/MapView'], options).then(([Map, MapView]) => {
console.log("Test");
var map = new Map({
basemap: "topo"
});
this.view = new MapView({
container: this.mapContainer,
map: map
});
});
}
}
render() {
return (
<div className="App">
<div style={{height:'100%'}} ref={node => this.mapContainer = node}/>
</div>
);
}
}
export default App;
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Build offline applications | Documentation - ArcGIS Developers
Offline applications run natively on phones, tablets, laptops, or desktop computers, and work where network connectivity is unreliable or unavailable. The data ...
Read more >Solved: Using the Javascript API, is it possible to downlo...
GitHub - Esri/offline-editor-js: ArcGIS JavaScript library for handling offline editing and tiling. It's not maintained anymore but wanted ...
Read more >Using ArcGIS webmap offline? - GIS Stack Exchange
The ArcGIS Javascript can be downloaded from My Esri. This will also include instructions on how it can be installed on a local...
Read more >Esri/offline-editor-js: ArcGIS JavaScript library for ... - GitHub
ArcGIS JavaScript library for handling offline editing and tiling. - GitHub - Esri/offline-editor-js: ArcGIS JavaScript library for handling offline editing ...
Read more >ArcGIS API for JavaScript: Getting Started with Web ... - YouTube
Join us for an overview on developing with the ArcGIS API for JavaScript. This session will cover the basics of setting up your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tomwayson
was the only thing that ran.
@davetimmins Thank you. Replacing the URL with that and leaving my dojoConfig solved my problem! Without the dojoConfig causes it to not work with different errors.
@DevChagrins I’ve used it with a local API using the full dojo.js file path for the url e.g.