FeatureLayer not displayed and infoWindow not popup

2967
4
Jump to solution
01-24-2014 05:34 AM
ShaningYu
Frequent Contributor
By referring ESRI's sample, I added a FeatureLayer layer.  But the FeatureLayer does not display and the infoWindow does not popup.  The related code is below:

          var content = "<b>Service Line</b>: ${SERVICE_LINE} <br/>" +
                              "<b>Segment</b>: ${TRACK_SEGMENT}" +
         "<b>Length (ft)</b>: ${Shape_Length}";
          var infoTemplate = new esri.InfoTemplate("${TRACKNAME}", content);
          map.infoWindow.resize(200, 80);
          var featureLayer = new esri.layers.FeatureLayer(serverURL + "/0", {
              mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
              outFields: ["OBJECTID", "TRACKNAME", "Shape_Length", "TRACK_SEGMENT", "SERVICE_LINE"],
              infoTemplate: infoTemplate     });
          map.addLayers([basemap, featureLayer]);
I doubled checked and am sure the URL is correct.  I also load the required dojo items.  Did I miss something?  Thanks if you help.
0 Kudos
1 Solution

Accepted Solutions
JamieSimko
New Contributor III
One common mistake I know of is pointing to the MapServer url instead of the FeatureServer url. Even with double checking I've unknowingly done that before.

e.g.
[INDENT]"http://arcgis/arcgis/rest/services/path/name/MapServer/4" [/INDENT]
instead of
[INDENT]"http://arcgis/arcgis/rest/services/path/name/FeatureServer/4"[/INDENT]

Could that be it?

What response do you get back from the network request to the feature layer url? Depending on what this is it could help narrow down the causes of the error.

View solution in original post

4 Replies
JamieSimko
New Contributor III
One common mistake I know of is pointing to the MapServer url instead of the FeatureServer url. Even with double checking I've unknowingly done that before.

e.g.
[INDENT]"http://arcgis/arcgis/rest/services/path/name/MapServer/4" [/INDENT]
instead of
[INDENT]"http://arcgis/arcgis/rest/services/path/name/FeatureServer/4"[/INDENT]

Could that be it?

What response do you get back from the network request to the feature layer url? Depending on what this is it could help narrow down the causes of the error.
SubuSwaminathan1
Occasional Contributor

FeatureLayer | API Reference | ArcGIS API for JavaScript

The feature layer inherits from the graphics layer and can be used to display features from a single layer in either a Map Service or Feature Service. The layer can be either a (spatial) layer or (non-spatial) table. The features in a feature layer can be edited if the isEditable method is true.

The FeatureLayer will, by default, use the drawing information from the server (requires ArcGIS Server 10 or above). See for example the simple renderer in the Drawing Info at http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/...

___________________

As per the above - One should be able to use a single layer from a map service. Can anyone clarify -whether a FeatureLayer works only with a feature service or if it can consume a layer from a map service.

RobertScheitlin__GISP
MVP Emeritus

Subu,

   The FeatureLayer will work with a MapService too.

ShaningYu
Frequent Contributor
JSim:  Thanks for your answer.
0 Kudos