Android1

Instanciating Popup offline

Discussion created by Android1 on Sep 10, 2012
Hello,

I'm currently trying to instanciate PopupViews, doing it offline.
I'm basing my work on the PopupInWebmapForEditing sample.

To put the popup infos into my layer, I'm using the setPopupInfos method.
The parameter is a Map :

popupMap.put(0, PopupInfo.fromJson(jsonParserPopup));


The json parser is based on the following json definition file :
    {
    \"featureCollection\": {
        \"layers\": [
            {
                \"layerDefinition\": {
                 \"currentVersion\" : 10.01, 
      \"id\" : 5, 
       \"name\" : \"Batiments\", 
                    \"type\": \"Feature Layer\",
                    \"geometryType\": \"esriGeometryPolygon\",
                    \"extent\": {                     
                        \"spatialReference\": {
                            \"wkid\": 102100,
                            \"latestWkid\": 3857
                        }
                    },
                    \"objectIdField\": \"OBJECTID\",
                    \"displayFieldName\": \"Batiments\",
                    \"drawingInfo\": {\"renderer\": 
            {\"type\": \"simple\", 
            \"symbol\": 
              {\"type\": \"esriSFS\",
                \"style\": \"esriSLSSolid\",
                \"color\": [255,132,0,200],
                \"outline\": {
               \"type\": \"esriSLS\",
              \"style\": \"esriSLSSolid\",
               \"color\": [0,34,255,200],
               \"width\": 2}
              }
            }
           },
       
           
                    \"fields\": [
                        {
                            \"name\": \"OBJECTID\",
                            \"alias\": \"OBJECTID\",
                            \"type\": \"esriFieldTypeOID\"
                        },
                        {
                            \"name\": \"name\",
                            \"alias\": \"Name\",
                            \"type\": \"esriFieldTypeString\"
                        },
                        {
                            \"name\": \"type\",
                            \"alias\": \"Type\",
                            \"type\": \"esriFieldTypeString\"
                        }                       
                    ]
                },          
                \"popupInfo\": {
                    \"title\": \"{title} ({type})\",
                    \"fieldInfos\": [
                        {
                            \"fieldName\": \"OBJECTID\",
                            \"label\": \"ID\",
                            \"visible\": false
                        },
                        {
                            \"fieldName\": \"name\",
                            \"label\": \"Name\",
                            \"visible\": true
                        }                        
                    ],
                    \"description\": null,
                    \"showAttachments\": false,
                    \"mediaInfos\": [
                            {
                            \"type\": \"image\",
                            \"caption\": \"Caption\",
                            \"value\": {
                                \"sourceURL\": \"http://www.blank.com/fr/uploads/pics/60.jpg\",
                                \"linkURL\": \"http://www.blank.com/fr/uploads/pics/60.jpg\"
                            }
                            },
                            {
                            \"type\": \"image\",
                            \"caption\": \"Caption\",
                            \"value\": {
                                \"sourceURL\": \"http://upload.wikimedia.org/wikipedia/en/f/ff/123.jpg\",
                                \"linkURL\": \"http://upload.wikimedia.org/wikipedia/en/f/ff/145_logo.jpg\"
                            }
                            }                      
                    ]
                }
            }
        ]
    }
} [


and to instanciate my layer, I create a FeatureSet also with a json definition file:

 {"currentVersion" : 10.01, 
    "id" : 4, 
    "name" : "Batiments", 
    "type" : "Feature Layer", 
    "displayField" : "OBJECTID", 
    "description" : "", 
    "copyrightText" : "", 
    "relationships" : [
     ], 
       
         "geometryType":"esriGeometryPolygon",
         "objectIdField":"ObjectID",
        "drawingInfo": 
         {"renderer": 
          {"type": "simple", 
          "symbol": 
            {"type": "esriSFS",
              "style": "esriSLSSolid",
              "color": [255,132,0,200],
              "outline": {
             "type": "esriSLS",
             "style": "esriSLSSolid",
             "color": [0,34,255,200],
             "width": 2}
        }}},
        "hasAttachments" : true, 
    "htmlPopupType" : "esriServerHTMLPopupTypeAsHTMLText", 
    "objectIdField" : "OBJECTID", 
        "fields":[
        {"name":"OBJECTID","alias":"OBJECTID","type":"esriFieldTypeOID"},
        {"name":"name","alias":"Name","type":"esriFieldTypeString", "editable" : true},
        {"name":"type","alias":"type","type":"esriFieldTypeString", "editable" : true}],
        
        "capabilities" : "Query,Editing"}


Then i do this :
fLayer = new ArcGISFeatureLayer(jsonDefinition, featureSet, options); 
fLayer.setPopupInfos(popupMap);


The layer shows up, the popup mechanism works also.
The problem I have is that when I touch a graphics object, the popup shows up, but without anything in it. While testing, I know that the popupContainer (that I send to my PopupDialog view) has a PopupView and has genuine contents in it.

Do you think is it a problem with my json definition files? What about the fact of having 2 json files? Is there a way to combine them?

Thanks in advance

Outcomes