Search code examples
javascriptesriarcgis-js-apiopendata

Why is Feature layer not resolving DEBBaseMap given by NSW MapServer for javascript API 4.1.1?


I have been trying to implement javascript API given by NSW for DEPBaseMap. The layer can be added on ArcGIS Online too and works fine with it, but doing same thing with the JS API, no map has been resolved. I think i have been missing something with the code in my javascript because other feature layers including NSW planning portal works goods for me.

        var map = new Map({
            basemap: "topo-vector"

        });

        var view = new MapView({
            container: "viewDiv",
            map: map,
            center: [-118.27928, 34.13558],
            zoom: 18
        });

        var baseLayer= new FeatureLayer({
            url: "https://mapprod1.environment.nsw.gov.au/arcgis/rest/services/Basemap/DPEBasemap/MapServer"
        });

        map.add(baseLayer);

The expected output should be like thisExpected outcome hyperlink Expected outcome(Zoom out) Expected outcome(Zoom in)

This is what i have got with my code my output(Zoom out)


Solution

  • The url above points to a map service. So instead of adding it as a FeatureLayer, use a TileLayer and everything works as in the ArcGIS Online Map Viewer.

    var baseLayer= new TileLayer({
        url: "https://mapprod1.environment.nsw.gov.au/arcgis/rest/services/Basemap/OEHBasemapNPWSHillshade/MapServer"
    });
    map.add(baseLayer);
    

    See the following CodePen for a live demo using the latest ArcGIS API for JavaScript: https://codepen.io/arnofiva/pen/21dd5c26558b140fde4622862516cff4