0

I would like to project my shapefile information on the maps. I converted my shapefile into a JSON file. How can use the Json file to create a featurecollection object in the ARCGIS Javascript API. The Json file contains 50 thousand features. Have given a sample set of my feature collection below. I do not want to embed the entire JSON file within the javascript file.

{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "ROADNAME": "AAA", "LINK_INDEX": 1}, "geometry": { "type": "LineString", "coordinates": [ [ 163.554342, -77.702882 ], [
163.553160, -77.702327 ] ] } } , { "type": "Feature", "properties": { "ROADNAME": "KIAN TECK WAY","LINK_INDEX": 2}, "geometry": { "type": "LineString", "coordinates": [ [ 162.527145, -77.686591 ], [
162.522273, -77.686598 ] ] } } }
1

Here are some example to show the Json based FeatureCollection as Feature Layer in ARCGIS Javascript API Json Featurelayer 1 and Json To FeatureLayer 2. For showing the 50 Thousand write Handler which returns Json Something like this --->> Json Handler and give that output of the handler as a string to feature collection.Hope this helps you.

0

esri json to feature layer

example arcgis rest api request url:

http://xxxx.com/xxx/rest/services/Maps_and_Indices/MapServer/2/query?f=pjson&returnCountOnly=false&outFields=*&outSR=4326&where=DISTRICT%20=%20%27129B149%27%20or%20TILE_NAME%20=%20%27129B149%27%20or%20TOOLTIP%20=%20%27129B149%27%20or%20NLA_URL%20=%20%27129B149%27

decode URL:

 http://xxxx.com/xxx/rest/services/Maps_and_Indices/MapServer/2/query?f=pjson&returnCountOnly=false&outFields=*&outSR=4326&where=DISTRICT = '129B149' or TILE_NAME = '129B149' or TOOLTIP = '129B149' or NLA_URL = '129B149'

data: any arcgis rest api return (response)

example (data) :

            {
             "displayFieldName": "TILE_NAME",
             "fieldAliases": {
              "OBJECTID": "OBJECTID",
              "DISTRICT": "DISTRICT",
              "TILE_NAME": "TILE_NAME",
              "TOOLTIP": "TOOLTIP",
              "NLA_URL": "NLA_URL"
             },
             "geometryType": "esriGeometryPolygon",
             "spatialReference": {
              "wkid": 4326,
              "latestWkid": 4326
             },
             "fields": [
              {
               "name": "OBJECTID",
               "type": "esriFieldTypeOID",
               "alias": "OBJECTID"
              },
              {
               "name": "DISTRICT",
               "type": "esriFieldTypeString",
               "alias": "DISTRICT",
               "length": 16
              },
              {
               "name": "TILE_NAME",
               "type": "esriFieldTypeString",
               "alias": "TILE_NAME",
               "length": 32
              },
              {
               "name": "TOOLTIP",
               "type": "esriFieldTypeString",
               "alias": "TOOLTIP",
               "length": 66
              },
              {
               "name": "NLA_URL",
               "type": "esriFieldTypeString",
               "alias": "NLA_URL",
               "length": 78
              }
             ],
             "features": [
              {
               "attributes": {
                "OBJECTID": 1120,
                "DISTRICT": "WESTLA",
                "TILE_NAME": "129B149",
                "TOOLTIP": "District: WESTLA\\nTile: 129B149",
                "NLA_URL": "navigatela/reports/cadastral_map_index.cfm?pk=129B149"
               },
               "geometry": {
                "rings": [
                 [
                  [
                   -118.45870522159555,
                   34.053800267113971
                  ],
                  [
                   -118.44549967992378,
                   34.053813128253687
                  ],
                  [
                   -118.44548872993352,
                   34.045569527150292
                  ],
                  [
                   -118.45869298464309,
                   34.045556665428208
                  ],
                  [
                   -118.45870522159555,
                   34.053800267113971
                  ]
                 ]
                ]
               }
              }
             ]
            }

For example you want add arcgis rest api response( esri json) to feature layer

var search_layer_result = JSON.parse(data)

    console.log(search_layer_result)

   // ............ add esri json -> feature layer -> map  ..............


  var featureCollection = {  
                      layerDefinition : search_layer_result,  
                      featureSet : search_layer_result 
                      }; 

 search_result_featureLayer = new FeatureLayer(featureCollection);  
//var symbol = new SimpleMarkerSymbol().setColor(new esri.Color([255,0,0,0.5]));  
 var renderer = new SimpleRenderer(your_Symbol);  
 search_result_featureLayer.setRenderer(renderer);  

 map.addLayer(search_result_featureLayer, your_layer_index_optional);  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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