0

I am trying to display an ArcGIS Map on my webpage.

Whenever I try to use the 'extent' Attribute next to the 'center' and 'zoom' Attributes, I get the following error:

GET https://js.arcgis.com/4.8/esri/SpatialReference.js net::ERR_ABORTED 404

So apparently the SpatialReference.js can not be loaded, but is a part of the ArcGIS API.

Am I misunderstanding something?

I have my code from https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#using where the use of 'extent' is explained.

<code>
<script src="https://js.arcgis.com/4.8/"></script>
// ...
require([
 "esri/views/MapView",
 "esri/geometry/Extent",
 "esri/SpatialReference",
 "esri/WebMap",
 "dojo/domReady!"
 ], function (MapView, WebMap, Extent, SpatialReference) {
 var webmap = new WebMap({portalItem: { id: "f7f....."}});
 var view = new MapView({
 map: webmap,
 container: "mapdiv",
 center: [7.16809, 51.94349],
 zoom: 14 
 });
 // Set the extent on the view
 view.extent = new Extent({
 xmin: -9177882,
 ymin: 4246761,
 xmax: -9176720,
 ymax: 4247967,
 spatialReference: new SpatialReference({ wkid: 102667 })
 });
 }); 
</code>
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 19, 2018 at 12:53

1 Answer 1

3

There are couple of issues in your code, but not too bad.

It's esri/geometry/SpatialReference not esri/SpatialReference. https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html

Plus the order matters when you require the modules, you had a couple of modules out of order.

require([
 "esri/views/MapView",
 "esri/geometry/Extent",
 "esri/geometry/SpatialReference",
 "esri/WebMap",
 "dojo/domReady!"
], function(MapView, Extent, SpatialReference, WebMap

Also because of autocasting in the API, you don't need to initialize all those classes.

require([
 "esri/views/MapView",
 "esri/WebMap",
], function(MapView, WebMap) {
 var webmap = new WebMap({portalItem: { id: "f7f....."}});
 var view = new MapView({
 map: webmap,
 container: "viewDiv",
 center: [7.16809, 51.94349],
 zoom: 14
 });
 // Set the extent on the view
 view.extent = {
 xmin: -9177882,
 ymin: 4246761,
 xmax: -9176720,
 ymax: 4247967,
 spatialReference:{ wkid: 102667 }
 };
});
answered Sep 19, 2018 at 14:24
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.