Hosted feature service is not visible from javascript api

1196
5
10-20-2016 04:50 AM
SOVANHALDER
New Contributor III

I have one hosted feature service on ArcGIS Online organizational account and it is shared with everyone. When I am trying to access this featurelayer from a javascript api the layer is not visible. Kindly help

0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor

Please post your code to show how you are attempting to access the feature service.

0 Kudos
SOVANHALDER
New Contributor III

Hi It is working after changing to https:// from http://

0 Kudos
BillChappell
Occasional Contributor II

I think your center coordinates are off. Try  center: [76.641536,12.316173],

This worked for me:

require([
    "esri/map",
    "esri/layers/FeatureLayer",
    "dojo/domReady!"
  ],
  function(
    Map,
    FeatureLayer
  ) {

    var map = new Map("map", {
      basemap: "hybrid",
      center: [76.641536,12.316173], 
      zoom: 10
    });

    /****************************************************************
     * Add feature layer - A FeatureLayer at minimum should point
     * to a URL to a feature service or point to a feature collection
     * object.
     ***************************************************************/

    // Carbon storage of trees in Warren Wilson College.
    var featureLayer = new FeatureLayer("http://services1.arcgis.com/ECFqcT5baCSej64y/ArcGIS/rest/services/mysore1/FeatureServer/0");

    map.addLayer(featureLayer);

  });

0 Kudos
BillChappell
Occasional Contributor II

Tough to see but there are 4 orange dots, may be easier to see if you turn basemap to streets.

0 Kudos
KenBuja
MVP Esteemed Contributor

You could also set the extent of the map from the feature layer itself, like in this example

JS Bin - Collaborative JavaScript Debugging 

0 Kudos