Hello everyone,
I would like to add a layer (stored with arcgis server on localhost -as you can see with the url) on my map (and this SHOULD be quite simple).
can someone tell me why this simple script isn't working? (it loads the topo basemap, ok, but NO LAYER)
<script>
var map;
require
(["esri/map",
"esri/layers/FeatureLayer",
"dojo/domReady!"],
function(Map,
FeatureLayer)
{
var map = new Map("map",
{
basemap: "topo",
center: [0.694357, 47.395560],
zoom: 8
});
var rivers = new esri.layers.FeatureLayer("http://localhost:6080/arcgis/rest/services/CARTAGES/Lineaire_Hydro_Loire_Bretagne/MapServer");
map.addLayer(rivers);
}
);
</script>
thanx a lot in advance
vincent
Solved! Go to Solution.
When you add a FeatureLayer, you have to specify a single layer within the service.
var rivers = new FeatureLayer("http://localhost:6080/arcgis/rest/services/CARTAGES/Lineaire_Hydro_Loire_Bretagne/MapServer/0");
From the Help:
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.
Vincent,
try the following:
<script>
var map;
require
(["esri/map",
"esri/layers/ArcGISTiledMapServiceLayer",
"dojo/domReady!"],
function(Map,
ArcGISTiledMapServiceLayer)
{
var map = new Map("map",
{
basemap: "topo",
center: [0.694357, 47.395560],
zoom: 8
});
var rivers = new ArcGISTiledMapServiceLayer("http://localhost:6080/arcgis/rest/services/CARTAGES/Lineaire_Hydro_Loire_Bretagne/MapServer");
map.addLayer(rivers);
}
);
</script>
Hope this helps!
Tim
I had already tryed using the tiledmapservice but it doen't provide any display (at all, in my simple case, I mean).
Thanx a lot, Tim, for your answer & advice!
greetings from paris, anyway
vincent
When you add a FeatureLayer, you have to specify a single layer within the service.
var rivers = new FeatureLayer("http://localhost:6080/arcgis/rest/services/CARTAGES/Lineaire_Hydro_Loire_Bretagne/MapServer/0");
From the Help:
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.
THAT'S IT
thank you Ken, like, a million times!!!