I am using the "require" script to load layers into a map. I am able to successfully use the "esri/layers/ArcGISDynamicMapServiceLayer" script to load tiled layers but I am wondering how to add these two layers:
Cline/Regions_w_Country_Labels (MapServer)
http://services3.arcgis.com/HVjI8GKrRtjcQ4Ry/arcgis/rest/services/Major_World_Cities/FeatureServer/0
Any guidance is greatly appreciated.
Steve
Steve,
Sorry there was an error in my code it should be
outFields: ["CITY_NAME"]
An array of Strings not a string containing an array.
Robert -
I tried this:
var template = new InfoTemplate("Cities", "City: ${CITY_NAME}<br>Population: ${POP}");
var Cities = new FeatureLayer("http://services3.arcgis.com/HVjI8GKrRtjcQ4Ry/arcgis/rest/services/Cities_over_100000/FeatureServer/0", {
id: "Cities",
infoTemplate: template,
outFields: "[CITY_NAME]"
});
The result of this script is that the layer does not appear at all. When I remove the
It appears again but it only shows the population attribute, not the city attribute.
I am trying to integrate that into my script by doing this:
var template = new InfoTemplate("cities", "City: ${CITY_NAME}");
var cities = new FeatureLayer("http://services3.arcgis.com/HVjI8GKrRtjcQ4Ry/arcgis/rest/services/Major_World_Cities/FeatureServer/0", {
id: 'cities',
infoTemplate: template
legendLayers.push({
layer: cities,
title: 'World Cities'
Can you see what I am missing?
When I add http://services3.arcgis.com/HVjI8GKrRtjcQ4Ry/arcgis/rest/services/Major_World_Cities/FeatureServer/0 as a Feature layer it pulls the symbology in as well. Here is a simple sample:
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>Feature Layer Only Map</title> <link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css"> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } </style> <script src="http://js.arcgis.com/3.13/"></script> <script> require([ "dojo/dom-construct", "esri/map", "esri/layers/FeatureLayer", "esri/geometry/Extent", "esri/InfoTemplate", "dojo/domReady!" ], function( domConstruct, Map, FeatureLayer, Extent, InfoTemplate ) { var bounds = new Extent({ "xmin":-16045622, "ymin":-811556, "xmax":7297718, "ymax":11142818, "spatialReference":{"wkid":102100} }); var map = new Map("map", { extent: bounds }); var url = "http://services3.arcgis.com/HVjI8GKrRtjcQ4Ry/arcgis/rest/services/Major_World_Cities/FeatureServer/0"; var template = new InfoTemplate("Cities", "City: ${CITY_NAME}"); var fl = new FeatureLayer(url, { id: "Cities", infoTemplate: template }); map.addLayer(fl); } ); </script> </head> <body> <div id="map"></div> </body> </html>
That worked to bring the layer into the map. Is there a way to add the style created on ArcGIS.com?
Thanks for your help.
Normally you would use ArcGISTiledMapServiceLayer for tiled/cached layers. Use ArcGISDynamicMapServiceLayer for map services that are not tiled and you want to display the whole mapservice using the symbology from ArcGIS Server and not needing the geometry to be available on the client side. Use FeatureLayer for individual layers of a map service like http://services3.arcgis.com/HVjI8GKrRtjcQ4Ry/arcgis/rest/services/Major_World_Cities/FeatureServer/0 . A FeatureLayer actually downloads the geomerty to the client.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.