Select to view content in your preferred language

How to get attribute from GraphicsLayer's popup

741
1
03-18-2013 04:48 PM
DawenXie
Regular Contributor
I have some point data in csv format with x, y and list of attributes and I use a GraphicsLayer to plot them on a basemap. (Similar to ESRI's example on "Map with CSV data", http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/ags_MapwithTable.html ) A popup window is added when a point is clicked. Things work fine until I need to create a dynamic link on the popup window to retrieve more data: here I need to use a field, e.g., ID, in the attributes. Below is a walk-around I'm using which I don't like and I'm wondering what's right way to handle it. Thanks in advance for any suggestion you might provide.

   var rawAttrList = globals.map.infoWindow._contentPane.innerHTML.split("<br>");
             for (var i = 0; i < rawAttrList.length; i++) {
                 if (rawAttrList.split(" = ")[0] == "ID") {   
                       ID = rawAttrList.split(" = ")[1];          
                 }
             }
0 Kudos
1 Reply
DawenXie
Regular Contributor
Some more details.

I have other layers in the application and they are typical feature layers returned from a GIS server. What I want to accomplish is to have a link on the popup to retrieve dynamic information for each layer. For a feature layer, I can use map.infoWindow.getSelectedFeature() and then query the attributes to get the ID I need. But I have trouble in doing this for a GraphicsLayer as map.infoWindow.getSelectedFeature() returns null .

I have some point data in csv format with x, y and list of attributes and I use a GraphicsLayer to plot them on a basemap. (Similar to ESRI's example on "Map with CSV data", http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/ags_MapwithTable.html ) A popup window is added when a point is clicked. Things work fine until I need to create a dynamic link on the popup window to retrieve more data: here I need to use a field, e.g., ID, in the attributes. Below is a walk-around I'm using which I don't like and I'm wondering what's right way to handle it. Thanks in advance for any suggestion you might provide.

   var rawAttrList = globals.map.infoWindow._contentPane.innerHTML.split("<br>");
             for (var i = 0; i < rawAttrList.length; i++) {
                 if (rawAttrList.split(" = ")[0] == "ID") {   
                       ID = rawAttrList.split(" = ")[1];          
                 }
             }
0 Kudos