Select to view content in your preferred language

set layer name

1014
4
06-20-2014 07:28 AM
maximcouton
Deactivated User
Hi,

    I Wonder if it is possible to set a ArcGISTiledMapServiceLayer  layer name  when creating this layer ?


Thanks,
0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
Where would you like the new layer name to appear?  If it's the legend, this is possible.  Take a look at the 'title' property of the layerInfos parameter:

https://developers.arcgis.com/javascript/jsapi/legend-amd.html
0 Kudos
maximcouton
Deactivated User
Hi,  

   After adding a one ArcGISdynamicMapServiceLayer to my map , I can then get it name by :
  
   map.getLayer(map.layerIds[0]).layerInfos[0].name
  
   The ArcGIS API for javascript  sets  the name automatically after creating the layer.
  
   What I want to do is  to give that layer what ever name I wanted. So that when
    I make  map.getLayer(map.layerIds[0]).layerInfos[0].name It will give me the name I have set.
   
   Or may be there is another custome attribute inside the layer the developper can use ?
 
  Thanks
0 Kudos
ManishkumarPatel
Deactivated User
Hi Maxim,
           
            You can set the id for the layer you add to the map as follow:
           
            var TiledMapServiceLayer = new ArcGISTiledMapServiceLayer(baseMapServiceLyr, {
                "id": "LayerNamegoeshere"
            });
           
            You can refer to the below API documentation for further reference:
            https://developers.arcgis.com/javascript/jsapi/arcgistiledmapservicelayer-amd.html
           
            Hope this helps.
           
            Regards,
            Manish
0 Kudos
maximcouton
Deactivated User
Hi Manishkumar,

   Thanks for that, I can use it.

Regards,
Maxim
0 Kudos