How to determine best esri layer type for given data?

2527
5
Jump to solution
04-09-2016 04:34 PM
EricBianchi1
New Contributor III

Hello,

I am trying to implement the following rest endpoint data:

http://arcgis-central.gis.vt.edu/arcgis/rest/services/vtcampusmap/ParkingSpaces/MapServer

Onto my basemap. I would like to do this through ArcGIS java script. I thought that I was following all the steps correctly that I found on Feature Layer (basic) | ArcGIS API for JavaScript  , but it does not want to show up.

I am thinking it could be a problem with the type of layer that I am calling it? For example, it may need to be ArcGISgraphiclayer instead of FeatureLayer or something like that.

Maybe it is something entirely different, but I can't understand why it is not working.

My code is attached.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Eric,

  You had a couple of issue in your code:

  1. Your basemap choice of "osm" does not work for your min scale on your parking spaces layer.
  2. You had your maps zoom set to 16 and your layers min scale of 2100 would not show until a zoom of 19,
  3. And the most important is that you were using FeatureLayer and not specifying a specific layer id in the url.
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="http://js.arcgis.com/3.16/esri/css/esri.css">
    <link rel="stylesheet" href="https://js.arcgis.com/3.16/dijit/themes/claro/claro.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="http://js.arcgis.com/3.16/"></script>
    <title></title>
    <style>
        html,
        body,
        #mapDiv {
          padding: 0;
          margin: 0;
          height: 100%;
        }
    </style>
    <script>
      require(["esri/map", "esri/layers/FeatureLayer", "dojo/domReady!"],
        function(Map, FeatureLayer) {
          var map = new Map("mapDiv", {
            center: [-80.4178, 37.23],
            zoom: 19,
            basemap: "streets"
          });
          var featureLayer = new FeatureLayer("http://arcgis-central.gis.vt.edu/arcgis/rest/services/vtcampusmap/ParkingSpaces/MapServer/0");
          map.addLayer(featureLayer);
      });
    </script>
</head>

<body class="claro">
  <div id="mapDiv"></div>
</body>

</html>

View solution in original post

5 Replies
RobertScheitlin__GISP
MVP Emeritus

Eric,

  You had a couple of issue in your code:

  1. Your basemap choice of "osm" does not work for your min scale on your parking spaces layer.
  2. You had your maps zoom set to 16 and your layers min scale of 2100 would not show until a zoom of 19,
  3. And the most important is that you were using FeatureLayer and not specifying a specific layer id in the url.
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="http://js.arcgis.com/3.16/esri/css/esri.css">
    <link rel="stylesheet" href="https://js.arcgis.com/3.16/dijit/themes/claro/claro.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="http://js.arcgis.com/3.16/"></script>
    <title></title>
    <style>
        html,
        body,
        #mapDiv {
          padding: 0;
          margin: 0;
          height: 100%;
        }
    </style>
    <script>
      require(["esri/map", "esri/layers/FeatureLayer", "dojo/domReady!"],
        function(Map, FeatureLayer) {
          var map = new Map("mapDiv", {
            center: [-80.4178, 37.23],
            zoom: 19,
            basemap: "streets"
          });
          var featureLayer = new FeatureLayer("http://arcgis-central.gis.vt.edu/arcgis/rest/services/vtcampusmap/ParkingSpaces/MapServer/0");
          map.addLayer(featureLayer);
      });
    </script>
</head>

<body class="claro">
  <div id="mapDiv"></div>
</body>

</html>
EricBianchi1
New Contributor III

Thank you!

This was extremely helpful. Yes point three was definitely the most critical.

Yes the zoom was set out as far as it was becuase we are going to change the extents on the feature layer to accommodate a smaller zoom level. 

Much appreciated,

Eric Bianchi

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Eric,

  When a reply has answered your question you should click on the "correct answer" link on that reply to close the question.

0 Kudos
EricBianchi1
New Contributor III

Thank you,

Does AND do anything, or is it always "OR"?

Eric

On Sun, Apr 10, 2016 at 4:47 PM, Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos
AdrianWelsh
MVP Honored Contributor

Eric, I am guessing your AND vs OR question is directed at your other thread here:

Feature Layer multiple definition expressions

Robert has addressed that question.

For logic questions involving AND as well as OR (and others), you have to think like a computer.

"AND" works if BOTH of your conditions are true.

"OR" works if EITHER of your conditions are true.

For the OR statement

Type = redType = blueTrue?
YesNoYes
NoYesYes
YesYesYes
NoNoNo

For the AND statement

Type = redType = blueTrue?
YesNoNo
NoYesNo
NoNoNo
YesYesYes

Hopefully that makes sense.