Select to view content in your preferred language

Not able to load data NVZ data in map using 3.31 javascript api

311
1
02-03-2020 02:20 AM
JaydeepDhameliya
New Contributor

I have the code using javascript 3.31

With out zoom in and zoom out I am not able load the features on map

require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/layers/GraphicsLayer",
"esri/Graphic"
],
function(
Map, MapView, FeatureLayer, GraphicsLayer, Graphic
) {

var map = new Map({
basemap: "oceans"
});

var view = new MapView({
container: "viewDiv",
map: map,
center: [-0.118092, 51.509865],
zoom: 6
});


var featureLayer2 = new FeatureLayer({
url: "https://environment.data.gov.uk/arcgis/rest/services/EA/NitrateVulnerableZones2017Final/FeatureServer/0",
mode: FeatureLayer.MODE_ONDEMAND
});

var graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

The JSAPI 3.31 does not use MapView. This works (a modification of this sample😞

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>Intro to FeatureLayer - 4.14</title>

    <link
      rel="stylesheet"
      href="https://js.arcgis.com/4.14/esri/themes/light/main.css"
    />
    <script src="https://js.arcgis.com/4.14/"></script>

    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    </style>

    <script>
      require([
        "esri/Map",
        "esri/views/MapView",
        "esri/layers/FeatureLayer"
      ], function(Map, MapView, FeatureLayer) {
        var map = new Map({
          basemap: "hybrid"
        });

        var view = new MapView({
          container: "viewDiv",
          map: map,
          center: [-0.118092, 51.509865],
          zoom: 6
        });

        /********************
         * Add feature layer
         ********************/

        var featureLayer = new FeatureLayer({
          url:
            "https://environment.data.gov.uk/arcgis/rest/services/EA/NitrateVulnerableZones2017Final/FeatureServer/0"
        });

        map.add(featureLayer);
      });
    </script>
  </head>

  <body>
    <div id="viewDiv"></div>
  </body>
</html>
0 Kudos