0

I have a leaflet map consuming a dynamic map layer on ArcGIS server. The service is viewable on the map and exposes the following attributes:

Fields:
OBJECTID ( type: esriFieldTypeOID , alias: objectid )
cableid ( type: esriFieldTypeInteger , alias: Cable ID )
spanid ( type: esriFieldTypeInteger , alias: Span ID )
spantypeid ( type: esriFieldTypeInteger , alias: Span Type , Coded Values: [1: 36F] , [2: 6F] , [3: 12F] , ...14 more... )
placement ( type: esriFieldTypeString , alias: Placement , length: 50 , Coded Values: [aerial: aerial] , [buried: buried] , [transition: transition] , ...2 more... )
comments ( type: esriFieldTypeString , alias: Comments , length: 250 )
SHAPE_Length ( type: esriFieldTypeDouble , alias: Length (Ft.) )
MI_Style ( type: esriFieldTypeString , alias: MI_Style , length: 254 )

When I use the bindPopup() method, the popup works but all the values returned are undefined. I'm not sure why this is the case?

    Cable.bindPopup(function(error, featureCollection){
      if (error || featureCollection.features.length === 0){
        return false;
      }
      else {
        return "Span ID: "+featureCollection.features[0].properties.spanid+"<br>Span Type: "+featureCollection.features[0].properties.spantypeid+"<br>Placement: "+featureCollection.features[0].properties.placement+"<br> Comments: "+featureCollection.features[0].properties.comments+"<br> Length (Ft.): "+featureCollection.features[0].properties.SHAPE_Length;
      }
      });

1 Answer 1

1

OK so this issue has to do with the field alias. When your map service has field aliases that are different from your field names you must query the returned JSON using the alias instead of field name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.