+ Reply to Thread
Results 1 to 5 of 5

Thread: Why doesn't my layer show labels?

  1. #1
    Ben Stewart
    Join Date
    Apr 2010
    Posts
    31
    Points
    0
    Answers Provided
    0


    0

    Default Why doesn't my layer show labels?

    I'm adding a feature layer to an esri.map, and I can't understand why labels aren't showing up. This is the layer I'm trying to add, and it has a labeling definition. Am I missing something in the definition of the map? Or of the feature layer?

    Code:
            var map = new esri.Map("map", { extent: esri.geometry.geographicToWebMercator(initialExtent), slider: true, nav: false });
            dojo.connect(map, "onLoad", initSelectToolbar);
    		
            var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
            map.addLayer(baseMapLayer);
    		
    		//Add regional summation data
    		var content = "<b>Region</b>: ${Region_1}" +
                            "<br><b>Value USD(Millions)</b>: ${SUM_MAX_TotalAmt}" +
                            "<br><b>Number of Projects</b>: ${SUM_COUNT_ProjectID}";
    		var infoTemplate = new esri.InfoTemplate("${FIELD_NAME}", content);		
    		featureLayer = new esri.layers.FeatureLayer("http://maps4.arcgisonline.com/ArcGIS/rest/services/World_Bank/WB_World_Bank_Projects/MapServer/1",{
              mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
              infoTemplate: infoTemplate,
    		  outFields: ["*"]		  
            });
    	map.addLayer(featureLayer);

  2. #2
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,741
    Points
    732
    Answers Provided
    138


    0

    Default Re: Why doesn't my layer show labels?

    Feature Layers don't support a layer's labels. When you create a feature layer from a layer in a map service, you get the geometry and attributes. If you want to label feautres, look into using a Text Symbol.
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  3. #3
    Ben Stewart
    Join Date
    Apr 2010
    Posts
    31
    Points
    0
    Answers Provided
    0


    0

    Default Re: Why doesn't my layer show labels?

    Is there a better way to add a feature layer to my map then? I feel like I must be missing something. Placing each label with the TextSymbol function seems like an incredibly in-efficient way to add labels to a map service.

  4. #4
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,741
    Points
    732
    Answers Provided
    138


    0
    This post is marked as the answer

    Default Re: Why doesn't my layer show labels?

    Use a dynamic map service layer. You can control individual layer visibility with setVisibileLayers.
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  5. #5
    jonathan lee
    Join Date
    Nov 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: Why doesn't my layer show labels?

    Quote Originally Posted by swingley View Post
    Use a dynamic map service layer. You can control individual layer visibility with setVisibileLayers.
    hi i know this thread is months old, but i am wondering if you guys can help out. I bumped into the same problem as the TS and I tried using the visible layers, but the problem is that i have several hundred layers, if i add one layer the rest disappear and I cannot add more than like 10 layers to it as the old map just hangs there.

    I have been trying to set the default visibility to a layer of the dynamic map service but to no avail as the map does not take the value of the default visibility and set the layer i want to be visible.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts