Select to view content in your preferred language

iOS app - Editing JSON

6104
12
10-24-2011 12:39 PM
AliciaSoto
Frequent Contributor
Hello everyone,

I have been playing with the iOS app and the JSON settings. I'm not knowledgeable enough yet to create my own iOS application. (plus I don't have an Intel-based Macintosh)

I'm currently working with my own data off ArcGIS Server 10. I've managed to get my data to display as an operational layer on top of a basemap by editing the JSON.

{
  "version" : "1.3",
  "operationalLayers" : [
    {
       "url" : "http://myservername/ArcGIS/rest/services/maps/MyData/MapServer",
       "visibility" : true,
       "opacity" : 1,
       "title" : "Layers"
     }],
   "baseMap" : {
   "baseMapLayers" : [
     {
       "id" : "World_Topo_Map8225",
       "opacity" : 1,
       "visibility" : true,
       "url" : "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
      }],
    }
}


Everything works great, but is it possible to add an 'identify' tool to my app by only editing the JSON script? without publishing the data on arcgis online?

Thank you for your time.
0 Kudos
12 Replies
RussRoberts
Esri Notable Contributor
To be able to identify your features you will need to define a popupinfo for your features. One of the easiest ways to do this is to create a webmap define popups for your features and then extract the webmap JSON.

The process to extract the JSON is outlined in the help doc:
http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/AppGuide/Maps.pdf

Also popups and identifying features is also discussed in this thread
http://forums.arcgis.com/threads/36981-Identify-Feature-ESRI-ArcGIS-APP-Update

Hope this helps you out
Cheers
Russ
0 Kudos
AliciaSoto
Frequent Contributor
To be able to identify your features you will need to define a popupinfo for your features. One of the easiest ways to do this is to create a webmap define popups for your features and then extract the webmap JSON.

The process to extract the JSON is outlined in the help doc:
http://help.arcgis.com/en/arcgismobile/10.0/apis/iphone/AppGuide/Maps.pdf

Also popups and identifying features is also discussed in this thread
http://forums.arcgis.com/threads/36981-Identify-Feature-ESRI-ArcGIS-APP-Update

Hope this helps you out
Cheers
Russ


Thank you Russ! The PDF link really helped. I had seen it before, but it is now starting to make sense to me.

I extracted the JSON from a test layer I added to arcgis online. I see now why you said that will be the easiest way. Trying to replicate the code for my other maps will be difficult to do from scratch. However, since some of my data is copyrighted, I'm still reluctant to place it on arcgis online even if it's suppose to be set to private and I delete it right afterwards.

I'm gonna study my extracted test JSON and see how hard it will be to add my other data by hand in JSON.

Thanks for the help.
0 Kudos
RussRoberts
Esri Notable Contributor
Not a problem.
A work around to hosting up copyrighted data could be to create an empty feature class that mirrors the feature classes you are hosting up but have the copyright issues. This way you mirror the schemas and use the empty feature class in the webmap. Once you have extracted the JSON you can do a "find/replace" in a text file on the "empty feature class" rest end points with your data filled rest points. This way no actual company/copyrighted data is hosted up onto online..but you will have to have the schema for these features exactly matched.

This still isn't the best solution but could be a possible solution for you and would reduce possible JSON errors and maybe time creating these maps.
Cheers
Russ
0 Kudos
AliciaSoto
Frequent Contributor
After spending a few days reading these forums and the esri documentation, I have been able to display and identify a few of my own gis services on the iOS app(through a vpn connection).

I am now working on adapting an existing map service to display correctly on the ipad app.

Here is partof the JSON of the map service I am using

{
  "currentVersion" : 10.03, 
  "serviceDescription" : "", 
  "mapName" : "Layers", 
  "description" : "", 
  "copyrightText" : "", 
  "layers" : [
    {
      "id" : 0, 
      "name" : "Gas Grid", 
      "parentLayerId" : -1, 
      "defaultVisibility" : true, 
      "subLayerIds" : null, 
      "minScale" : 0, 
      "maxScale" : 0
    }, 
    {
      "id" : 1, 
      "name" : "Water Utilities Grid", 
      "parentLayerId" : -1, 
      "defaultVisibility" : false, 
      "subLayerIds" : null, 
      "minScale" : 0, 
      "maxScale" : 400
    }, 
    {
      "id" : 2, 
      "name" : "Gas Dept Layers", 
      "parentLayerId" : -1, 
      "defaultVisibility" : true, 
      "subLayerIds" : [3, 4, 5], 
      "minScale" : 0, 
      "maxScale" : 0
    }, 
    {
      "id" : 3, 
      "name" : "Commercial Meters", 
      "parentLayerId" : 2, 
      "defaultVisibility" : true, 
      "subLayerIds" : null, 
      "minScale" : 4800, 
      "maxScale" : 0
    }, 
    {
      "id" : 4, 
      "name" : "Valves", 
      "parentLayerId" : 2, 
      "defaultVisibility" : true, 
      "subLayerIds" : null, 
      "minScale" : 4800, 
      "maxScale" : 0
    }, 
    {
      "id" : 5, 
      "name" : "Mains", 
      "parentLayerId" : 2, 
      "defaultVisibility" : true, 
      "subLayerIds" : null, 
      "minScale" : 4800, 
      "maxScale" : 0
    }, 
    .
    .
    .
    .
    .
    .
  ], 
  "tables" : [
    
  ], 
  "spatialReference" : {
    "wkid" : 2279
  }, 
  "singleFusedMapCache" : false, 
  "initialExtent" : {
    "xmin" : 1228236.70754998, 
    "ymin" : 17087997.5799992, 
    "xmax" : 1422523.18567219, 
    "ymax" : 17233052.008659, 
    "spatialReference" : {
      "wkid" : 2279
    }
  }, 
  "fullExtent" : {
    "xmin" : 1228236.70754998, 
    "ymin" : 17087997.5799992, 
    "xmax" : 1422523.18567219, 
    "ymax" : 17233052.008659, 
    "spatialReference" : {
      "wkid" : 2279
    }
  }, 
  "units" : "esriFeet", 
  "supportedImageFormatTypes" : "PNG24,PNG,JPG,DIB,TIFF,EMF,PS,PDF,GIF,SVG,SVGZ,AI,BMP", 
  "documentInfo" : {
    "Title" : "Gas Dept", 
    "Author" : "alicia", 
    "Comments" : "", 
    "Subject" : "", 
    "Category" : "", 
    "Keywords" : "", 
    "Credits" : ""
  }, 
  "capabilities" : "Map,Query,Data"
}


Here are the 3 capabilities I am trying to include in my map
1) display data using symbology and reference scales set up in my service mxd
2) List data in the TOC and allow user to add and remove layers
3) Allow user to identify certain features.

Here is the JSON pseudoCode I have come up with so far. Am I going about this the right way? I know I can just upload empty datasets to ArcGIS online and extract the JSONs like Russ suggested, but I feel like I'm learning more doing it this way first.

There are no comment tags in JSON, so I'm using this *this is a comment*

{
  "operationalLayers": [
  {
    "url": "http:/myserver/ArcGIS/rest/services/maps/Mobile_Gas/MapServer/0",
    "id": "0",
    "visibility": true,
    "opacity": 1,
    "mode": 1,
    "title": "Gas Grid",
    *declare popupInfo here*
    "description": null
  },
  {
    *repeat the process for every feature in the map*
    *create popupInfo only for layers that I want users to be able to identify*
  }  
  ],
  "version": "1.3"
}


I've experimented with the above pseudoCode already, but only doing the first 3 features. The problem I run into is that my 2nd feature (http:/myserver/ArcGIS/rest/services/maps/Mobile_Gas/MapServer/1) is not displaying the same way as it does in my mxd. I've tried setting the defaultvisibility, minscale, and maxscale. So far those haven't worked either.

I don't quite understand how the mxd symbology should be translated over to the JSON.
0 Kudos
RussRoberts
Esri Notable Contributor
Can you take a snap shot of what you are seeing in the mxd and on the iOS app? Also could you point out some key things that I should be seeing.
Cheers
Russ
0 Kudos
AliciaSoto
Frequent Contributor
Can you take a snap shot of what you are seeing in the mxd and on the iOS app? Also could you point out some key things that I should be seeing.
Cheers
Russ


Sure. It might be easier for me to just post a video of what I'm doing.....since I'm probably not using the correct terminology all the time. I'll start working on that.

Thanks for your help.
0 Kudos
AliciaSoto
Frequent Contributor
Here's a video of an example application I created. I'm still trying to figure out how to edit the JSON file so that my feature layers will display properly.


" rel="nofollow" target="_blank">http://www.youtube.com/watch?v=vYo4zRtBZGw[/video]


Here is the JSON text I used in the video.

{
  "version":"1.3",
  "operationalLayers":[
    {
      "url":"http:/myserver/ArcGIS/rest/services/maps/iOS_Forum_Test/MapServer/0",
      "visibility": true,
      "title": "Elementary School Districts",
      "popupInfo": {
        "title": "Elementary School District",
        "fieldInfos": [
          {
            "fieldName": "NAME10",
            "label": "",
            "isEditable": false,
            "tooltip": "",
            "visible": true,
            "stringFieldOption": "textbox"
          },
          {
            "fieldName": "LOGRADE10",
            "label": "Low Grade",
            "isEditable": false,
            "tooltip": "",
            "visible": true,
            "stringFieldOption": "textbox"
          },
          {
            "fieldName": "HIGRADE10",
            "label": "High Grade",
            "isEditable": false,
            "tooltip": "",
            "visible": true,
            "stringFieldOption": "textbox"
          }
        ]
      }
    },
    {
      "url":"http:/myserver/ArcGIS/rest/services/maps/iOS_Forum_Test/MapServer/1",
      "visibility": true,
      "title" : "Congressional Districts"      
    },
    {
      "url":"http:/myserver/ArcGIS/rest/services/maps/iOS_Forum_Test/MapServer/2",
      "visibility": true,
      "title" : "Census Block Groups",
      "popupInfo": {
        "title": "Census Block Group",
        "fieldInfos": [
          {
            "fieldName": "TRACTCE10",
            "label": "TRACTCE10",
            "isEditable": false,
            "tooltip": "",
            "visible": true,
            "stringFieldOption": "textbox"
          },
          {
            "fieldName": "BLKGRPCE10",
            "label": "BLKGRPCE10",
            "isEditable": false,
            "tooltip": "",
            "visible": true,
            "stringFieldOption": "textbox"
          },
          {
            "fieldName": "ALAND10",
            "label": "ALAND10",
            "isEditable": false,
            "tooltip": "",
            "visible": true,
            "stringFieldOption": "textbox"
          }
        ]
      }
    },
    {
      "url":"http:/myserver/ArcGIS/rest/services/maps/iOS_Forum_Test/MapServer/3",
      "visibility": true,
      "title" : "Texas Boundaries"
    }
  ]
}
0 Kudos
RussRoberts
Esri Notable Contributor
Your formatting is slightly off. For a map service you do not have to set the service URL for each individual layer within a map service.


Here is a sample. I have popups for the first 2 layers (0,1) and then last layer(2) has no popups defined.


{
  "operationalLayers": [{
    "url": "http://sampleserver.arcgis.com/ArcGIS/rest/services/TestData/ElectricalView/MapServer",
    "id": "ElectricalView_1904",
    "visibility": true,
    "visibleLayers": [
      0,
      1,
      2
    ],
    "opacity": 1,
    "title": "ElectricalView",
    "layers": [
      {
        "id": 0,
        "popupInfo": {
          "title": "Primary Circuit: {LINK_TYPE}",
          "fieldInfos": [
            {
              "fieldName": "OBJECTID",
              "label": "OBJECTID",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "CONDUCTOR_",
              "label": "Conductor",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": {
                "places": 2,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "Enabled",
              "label": "Enabled",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "SHAPE",
              "label": "Condition",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "SHAPE.len",
              "label": "SHAPE.len",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": {
                "places": 2,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            }
          ],
          "description": null,
          "showAttachments": false,
          "mediaInfos": []
        }
      },
      {
        "id": 1,
        "popupInfo": {
          "title": "Secondary Circuit: {LINK_TYPE}",
          "fieldInfos": [
            {
              "fieldName": "OBJECTID",
              "label": "OBJECTID",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "CONDUCTOR_",
              "label": "Conductor",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": {
                "places": 2,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "LINK_TYPE",
              "label": "Link Type",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "INSULATION",
              "label": "Insulation",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": null,
              "stringFieldOption": "textbox"
            },
                        {
              "fieldName": "SYMBOL",
              "label": "Amps",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "PHASE_DESC",
              "label": "Voltage",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "Enabled",
              "label": "Enabled",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
             }
          ],
          "description": null,
          "showAttachments": false,
          "mediaInfos": []
        }
      }
    ]
  }],
  "baseMap": {
    "baseMapLayers": [{
      "id": "World_Topo_Map_9955",
      "opacity": 1,
      "visibility": true,
      "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
    }],
    "title": "Topographic"
  },
  "version": "1.4"
}

You may also want to set a basemap layer within your JSON. If you want to use one of those layers within your map service as a BM you can publish it out as a separate service and then place it within the BM JSON section.
Hope this helps.
Russ
0 Kudos
RussRoberts
Esri Notable Contributor
Your formatting is slightly off. For a map service you do not have to set the service URL for each individual layer within a map service.


Here is a sample. I have popups for the first 2 layers (0,1) and then last layer(2) has no popups defined.


{
  "operationalLayers": [{
    "url": "http://sampleserver.arcgis.com/ArcGIS/rest/services/TestData/ElectricalView/MapServer",
    "id": "ElectricalView_1904",
    "visibility": true,
    "visibleLayers": [
      0,
      1,
      2
    ],
    "opacity": 1,
    "title": "ElectricalView",
    "layers": [
      {
        "id": 0,
        "popupInfo": {
          "title": "Primary Circuit: {LINK_TYPE}",
          "fieldInfos": [
            {
              "fieldName": "OBJECTID",
              "label": "OBJECTID",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "CONDUCTOR_",
              "label": "Conductor",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": {
                "places": 2,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "Enabled",
              "label": "Enabled",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "SHAPE",
              "label": "Condition",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "SHAPE.len",
              "label": "SHAPE.len",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": {
                "places": 2,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            }
          ],
          "description": null,
          "showAttachments": false,
          "mediaInfos": []
        }
      },
      {
        "id": 1,
        "popupInfo": {
          "title": "Secondary Circuit: {LINK_TYPE}",
          "fieldInfos": [
            {
              "fieldName": "OBJECTID",
              "label": "OBJECTID",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "CONDUCTOR_",
              "label": "Conductor",
              "isEditable": false,
              "tooltip": "",
              "visible": false,
              "format": {
                "places": 2,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "LINK_TYPE",
              "label": "Link Type",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": null,
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "INSULATION",
              "label": "Insulation",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": null,
              "stringFieldOption": "textbox"
            },
                        {
              "fieldName": "SYMBOL",
              "label": "Amps",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "PHASE_DESC",
              "label": "Voltage",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
            },
            {
              "fieldName": "Enabled",
              "label": "Enabled",
              "isEditable": false,
              "tooltip": "",
              "visible": true,
              "format": {
                "places": 0,
                "digitSeparator": true
              },
              "stringFieldOption": "textbox"
             }
          ],
          "description": null,
          "showAttachments": false,
          "mediaInfos": []
        }
      }
    ]
  }],
  "baseMap": {
    "baseMapLayers": [{
      "id": "World_Topo_Map_9955",
      "opacity": 1,
      "visibility": true,
      "url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
    }],
    "title": "Topographic"
  },
  "version": "1.4"
}


You may also want to set a basemap layer within your JSON. If you want to use one of those layers within your map service as a BM you can publish it out as a separate service and then place it within the BM JSON section.
Hope this helps.
Russ
0 Kudos