Select to view content in your preferred language

Feature Layer not symbolizing properly

2752
7
06-04-2012 12:36 PM
BenStewart
Deactivated User
I'm adding a fairly basic feature layer to a map using the javascript API, however the symbology isn't coming along. After reading numerous other posts and blogs, I have deciphered that the issue is the fields aren't coming in when I create the feature layer, but why that is, I have no idea. Code is below, please help.

var initialExtent = esri.geometry.geographicToWebMercator(new esri.geometry.Extent(-40, -40, 40, 40, new esri.SpatialReference({wkid:4326}) ));
        map = new esri.Map("map", { 
            extent: initialExtent, 
            slider: true, 
            nav: true,
            wrapAround180: true
        });

        dojo.connect(map, "onLoad", initTools);
   
        var streetMap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer");
        map.addLayer(streetMap);
        
        var content = "<b>Name</b>: ${Name}" +
                  "<br><b>Current Carbon Production</b>: ${cPRes}" +
                  "<br><b>Current Energy Production</b>: ${ePres}";
        var infoTemplate = new esri.InfoTemplate("${FIELD_NAME}", content);
        
        //Add the country summary data
        var infoTemplate = new esri.InfoTemplate("${FIELD_NAME}", content);
        var cntryLyr = new esri.layers.FeatureLayer("http://sdnarc.worldbank.org/SDNARC/rest/services/benMisc/AfricanPowerPlants/MapServer/1",{
          infoTemplate: infoTemplate,
          outFields: ["*"]
        });

        var mapCntryLyr = map.addLayer(cntryLyr)
        
0 Kudos
7 Replies
BenFousek
Deactivated User
The code looks good. I went to check the map service but that's a 404 url.
0 Kudos
BenStewart
Deactivated User
I was hoping you would say it was shit, or that I made a stupid mistake. Sorry about the Link, it is behind a firewall. Is there something specific you are looking for in the documentation? I've copied it all below anyway

ArcGIS Services Directory
Home > benMisc > AfricanPowerPlants (MapServer) > africanCountryPoints  Help | API Reference
Layer: africanCountryPoints (ID: 1)
Display Field: NAME_ENGLI

Type: Feature Layer

Geometry Type: esriGeometryPoint

Description:

Definition Expression:

Copyright Text:

Min. Scale: 0

Max. Scale: 10000000

Default Visibility: True

Extent:

    XMin: -23.605139
    YMin: -37.112442752174
    XMax: 57.6817367500001
    YMax: 32.7273655072593
    Spatial Reference: 4326

Has Attachments: False

HTML Popup Type: esriServerHTMLPopupTypeAsHTMLText

Fields:

    FID (Type: esriFieldTypeOID, Alias: FID)
    Shape (Type: esriFieldTypeGeometry, Alias: Shape)
    OBJECTID (Type: esriFieldTypeInteger, Alias: OBJECTID)
    GADMID (Type: esriFieldTypeSmallInteger, Alias: GADMID)
    ISO (Type: esriFieldTypeString, Alias: ISO, Length: 5 )
    NAME_ENGLI (Type: esriFieldTypeString, Alias: NAME_ENGLI, Length: 50 )
    NAME_ISO (Type: esriFieldTypeString, Alias: NAME_ISO, Length: 54 )
    NAME_FAO (Type: esriFieldTypeString, Alias: NAME_FAO, Length: 50 )
    NAME_LOCAL (Type: esriFieldTypeString, Alias: NAME_LOCAL, Length: 54 )
    NAME_OBSOL (Type: esriFieldTypeString, Alias: NAME_OBSOL, Length: 150 )
    NAME_VARIA (Type: esriFieldTypeString, Alias: NAME_VARIA, Length: 160 )
    NAME_NONLA (Type: esriFieldTypeString, Alias: NAME_NONLA, Length: 50 )
    NAME_FRENC (Type: esriFieldTypeString, Alias: NAME_FRENC, Length: 50 )
    NAME_SPANI (Type: esriFieldTypeString, Alias: NAME_SPANI, Length: 50 )
    NAME_RUSSI (Type: esriFieldTypeString, Alias: NAME_RUSSI, Length: 50 )
    NAME_ARABI (Type: esriFieldTypeString, Alias: NAME_ARABI, Length: 50 )
    NAME_CHINE (Type: esriFieldTypeString, Alias: NAME_CHINE, Length: 50 )
    WASPARTOF (Type: esriFieldTypeString, Alias: WASPARTOF, Length: 100 )
    CONTAINS (Type: esriFieldTypeString, Alias: CONTAINS, Length: 50 )
    SOVEREIGN (Type: esriFieldTypeString, Alias: SOVEREIGN, Length: 40 )
    ISO2 (Type: esriFieldTypeString, Alias: ISO2, Length: 4 )
    WWW (Type: esriFieldTypeString, Alias: WWW, Length: 2 )
    FIPS (Type: esriFieldTypeString, Alias: FIPS, Length: 6 )
    ISON (Type: esriFieldTypeDouble, Alias: ISON)
    VALIDFR (Type: esriFieldTypeString, Alias: VALIDFR, Length: 12 )
    VALIDTO (Type: esriFieldTypeString, Alias: VALIDTO, Length: 10 )
    AndyID (Type: esriFieldTypeDouble, Alias: AndyID)
    POP2000 (Type: esriFieldTypeDouble, Alias: POP2000)
    SQKM (Type: esriFieldTypeDouble, Alias: SQKM)
    POPSQKM (Type: esriFieldTypeDouble, Alias: POPSQKM)
    UNREGION1 (Type: esriFieldTypeString, Alias: UNREGION1, Length: 254 )
    UNREGION2 (Type: esriFieldTypeString, Alias: UNREGION2, Length: 254 )
    DEVELOPING (Type: esriFieldTypeDouble, Alias: DEVELOPING)
    CIS (Type: esriFieldTypeDouble, Alias: CIS)
    Transition (Type: esriFieldTypeDouble, Alias: Transition)
    OECD (Type: esriFieldTypeDouble, Alias: OECD)
    WBREGION (Type: esriFieldTypeString, Alias: WBREGION, Length: 254 )
    WBINCOME (Type: esriFieldTypeString, Alias: WBINCOME, Length: 254 )
    WBDEBT (Type: esriFieldTypeString, Alias: WBDEBT, Length: 254 )
    WBOTHER (Type: esriFieldTypeString, Alias: WBOTHER, Length: 254 )
    CEEAC (Type: esriFieldTypeDouble, Alias: CEEAC)
    CEMAC (Type: esriFieldTypeDouble, Alias: CEMAC)
    CEPLG (Type: esriFieldTypeDouble, Alias: CEPLG)
    COMESA (Type: esriFieldTypeDouble, Alias: COMESA)
    EAC (Type: esriFieldTypeDouble, Alias: EAC)
    ECOWAS (Type: esriFieldTypeDouble, Alias: ECOWAS)
    IGAD (Type: esriFieldTypeDouble, Alias: IGAD)
    IOC (Type: esriFieldTypeDouble, Alias: IOC)
    MRU (Type: esriFieldTypeDouble, Alias: MRU)
    SACU (Type: esriFieldTypeDouble, Alias: SACU)
    UEMOA (Type: esriFieldTypeDouble, Alias: UEMOA)
    UMA (Type: esriFieldTypeDouble, Alias: UMA)
    PALOP (Type: esriFieldTypeDouble, Alias: PALOP)
    PARTA (Type: esriFieldTypeDouble, Alias: PARTA)
    CACM (Type: esriFieldTypeDouble, Alias: CACM)
    EurAsEC (Type: esriFieldTypeDouble, Alias: EurAsEC)
    Agadir (Type: esriFieldTypeDouble, Alias: Agadir)
    SAARC (Type: esriFieldTypeDouble, Alias: SAARC)
    ASEAN (Type: esriFieldTypeDouble, Alias: ASEAN)
    NAFTA (Type: esriFieldTypeDouble, Alias: NAFTA)
    GCC (Type: esriFieldTypeDouble, Alias: GCC)
    CSN (Type: esriFieldTypeDouble, Alias: CSN)
    CARICOM (Type: esriFieldTypeDouble, Alias: CARICOM)
    EU (Type: esriFieldTypeDouble, Alias: EU)
    CAN (Type: esriFieldTypeDouble, Alias: CAN)
    ACP (Type: esriFieldTypeDouble, Alias: ACP)
    Landlocked (Type: esriFieldTypeDouble, Alias: Landlocked)
    AOSIS (Type: esriFieldTypeDouble, Alias: AOSIS)
    SIDS (Type: esriFieldTypeDouble, Alias: SIDS)
    Islands (Type: esriFieldTypeDouble, Alias: Islands)
    LDC (Type: esriFieldTypeDouble, Alias: LDC)
    Shape_Leng (Type: esriFieldTypeDouble, Alias: Shape_Leng)
    Shape_Area (Type: esriFieldTypeDouble, Alias: Shape_Area)
    nPlants (Type: esriFieldTypeDouble, Alias: nPlants)
    nPower (Type: esriFieldTypeDouble, Alias: nPower)
    ORIG_FID (Type: esriFieldTypeInteger, Alias: ORIG_FID)

Type ID Field: N/A

Supported Interfaces:   REST

Supported Operations:   Query
0 Kudos
BenFousek
Deactivated User
Try:

var cntryLyr = new esri.layers.FeatureLayer("http://sdnarc.worldbank.org/SDNARC/rest/services/benMisc/AfricanPowerPlants/MapServer/1",{
  mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
  infoTemplate: infoTemplate,
  outFields: ["*"]
});


I'm not sure, but mode might be a required param. I never not used it.
0 Kudos
BenStewart
Deactivated User
Thanks for pointing that out, I always include it too, I was just randomly removing things I thought weren't necessary. Putting it back in doesn't change anything.

I adjusted the code so that there is an info template and I am only pulling out the fields I need. NAME_ENGLI defines the label, and nPower defines the size of the results icon

//Add the country summary data
        var content = "<b>Name</b>: ${NAME_ENGLI} <br> <b>Number of Plants</b>:${nPower}";       
        var infoTemplate = new esri.InfoTemplate("${FIELD_NAME}", content);
        var cntryLyr = new esri.layers.FeatureLayer("http://sdnarc.worldbank.org/SDNARC/rest/services/benMisc/AfricanPowerPlants/MapServer/1",{
          mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
          infoTemplate: infoTemplate,
          outFields: ["FID,NAME_ENGLI,nPower"]
        });
0 Kudos
BenFousek
Deactivated User
Did setting outFields to just the ones you want work?
0 Kudos
BenStewart
Deactivated User
No, but I think I figured something out. The layer I want to symbolize is using proportional symbols, but the individual layer on the ArcGIS Server doesn't have Drawing Info defined. If you check out another ArcGIS service, such as this http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/SuperTuesdaySample/MapServer/1 you can see a definition about how the items are to be drawn in the drawing info. For some reason, the layer I want to symbolize doesn't have any info. The other layers in the map do, but the one that I want to visualize doesn't.

Why is this happening? Why does ArcGIS Server not include the drawing info for my proportional symbols...I think I will cross post into ArcGIS Server.
0 Kudos
BenFousek
Deactivated User
I'm not sure. I checked some of my map services and they all have drawing info. I don't have any proportional symbology for any of them so I'm not sure if AGS supports it or not.

Bad mxd or msd?

What about a custom renderer in jsapi?

Just ideas. Do post an answer here when you figure it out. Good luck.
0 Kudos