Kishor
Kishor

Reputation: 210

Not able to load ESRI ArcGIS JS API Map in React app

I'm using React [^17.0.1] and arcgis-js-api [^4.18.1] for the app,

After 'npm start' I'm receiving the below errors,

The console errors are below,

[esri.widgets.Widget] widget-intl:locale-error esri.widgets.Attribution TypeError: t is not a constructor
[esri.widgets.Widget] widget-intl:locale-error esri.widgets.Zoom TypeError: t is not a constructor
index.js:1 [esri.widgets.Widget] widget-intl:locale-error esri.widgets.Popup TypeError: t is not a constructor
[esri.Basemap] #load() Failed to load basemap (title: 'Basemap', id: 'gray-vector') TypeError: t is not a constructor
workerFactory.js:5 Uncaught (in promise) TypeError: e is not a function
Uncaught (in promise) TypeError: Cannot read property 'zoomIn' of null

Errors

The SalesChartCard.js

import React, { useRef, useEffect } from 'react';
import { Card, CardBody, CardTitle } from 'reactstrap';
import ArcGISMap from '@arcgis/core/Map';
import MapView from '@arcgis/core/views/MapView';
import esriConfig from '@arcgis/core/config';

import '../../assets/css/map.css';

const SalesChartCard = () => {
  esriConfig.assetsPath = '/assets';

  const mapDiv = useRef(null);

  useEffect(() => {
    if (mapDiv.current) {
      /**
       * Initialize application
       */
      const map = new ArcGISMap({
        basemap: 'gray-vector',
      });

      /* eslint-disable no-unused-vars */
      const view = new MapView({
        map,
        container: mapDiv.current,
        extent: {
          spatialReference: {
            wkid: 102100,
          },
          xmax: -13581772,
          xmin: -13584170,
          ymax: 4436367,
          ymin: 4435053,
        },
      });
      /* eslint-enable no-unused-vars */
    }
  }, []);

  return (
    <Card>
      <CardBody>
        <CardTitle>Map</CardTitle>
        <div className="mapDiv" ref={mapDiv} />
      </CardBody>
    </Card>
  );
};

export default SalesChartCard;

I followed below links for development,

  1. jsapi-resources
  2. build with ES modules
  3. Link

Still I'm getting same console errors.

Kindly look into updated Git-repo and suggest solution.

Clone the repo and run the app then navigate to the url

http://localhost:3000/app/dashboards/default

then the application breaks and starts to give errors.

Upvotes: 3

Views: 1142

Answers (1)

Andy Gup
Andy Gup

Reputation: 360

Try upgrading to 4.19. What you are seeing looks like a configuration issue that was changed at 4.19.

Upvotes: 3

Related Questions