2

I am getting features (graphics) back from an IdentifyTask, setting a symbol and adding to a graphics layer. Polygons and points show up just fine, but not lines.

Has anyone else encountered this? Is there something special I'm supposed to do with polylines?

Here is some of the code:

I am constructing the symbol from the following JSON:

"Line": { "type": "esriSLS", "style": "esriSLSSolid", "color": [17, 255, 251, 255], "width": 2 }

The symbol is constructed as follows:

switch(geometryType) {
                ...
                case _geometryType.POLYLINE:
                    var json = symbolConfig.Line;


                    if (json != null)
                        symbol = new _dojo.SimpleLineSymbol(json);
                    else
                        symbol = new _dojo.SimpleLineSymbol();


                    break;
                ...
            }

I add the symbol to my IdentifyTask results and add to the map graphics layer as follows:

if (features.constructor === Array)
                _.each(features, function(feature) {
                    feature.setSymbol(Symbols.getSymbol(symbolType, feature.geometry.type));


                    graphicsLayer.add(feature);
                });

The Symbols.getSymbol() method calls the snippet above where the symbol is constructed. I know this doesn't include everything that happens, so I can add more, but there is quite a lot, so I'm trying to keep it as lean as possible.

Here is the JSON for a sample polyline graphic. The reason the _graphicsLayer property is null is because it creates a circular reference (since it contains a reference to the graphic as well) that causes JSON.stringify() to fail. So I created the JSON before adding the graphic to the graphics layer.

{
   "geometry":{
      "type":"polyline",
      "paths":[
         [
            [
               -11571538.3026,
               6145187.9335
            ],
            [
               -11582226.4153,
               6121719.7624
            ]
         ]
      ],
      "_path":0,
      "spatialReference":{
         "wkid":102100,
         "declaredClass":"esri.SpatialReference",
         "wkt":null,
         "_info":{
            "3785":{
               "wkTemplate":"PROJCS[\"WGS_1984_Web_Mercator\",GEOGCS[\"GCS_WGS_1984_Major_Auxiliary_Sphere\",DATUM[\"D_WGS_1984_Major_Auxiliary_Sphere\",SPHEROID[\"WGS_1984_Major_Auxiliary_Sphere\",6378137.0,0.0]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],PARAMETER[\"Standard_Parallel_1\",0.0],UNIT[\"Meter\",1.0]]",
               "valid":[
                  -20037508.342788905,
                  20037508.342788905
               ],
               "origin":[
                  -20037508.342787,
                  20037508.342787
               ],
               "dx":0.00001
            },
            "3857":{
               "wkTemplate":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]",
               "valid":[
                  -20037508.342788905,
                  20037508.342788905
               ],
               "origin":[
                  -20037508.342787,
                  20037508.342787
               ],
               "dx":0.00001
            },
            "4326":{
               "wkTemplate":"GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",${Central_Meridian}],UNIT[\"Degree\",0.0174532925199433]]",
               "altTemplate":"PROJCS[\"WGS_1984_Plate_Carree\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Plate_Carree\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],UNIT[\"Degrees\",111319.491]]",
               "valid":[
                  -180,
                  180
               ],
               "origin":[
                  -180,
                  180
               ],
               "dx":0.00001
            },
            "102100":{
               "wkTemplate":"PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0]]",
               "valid":[
                  -20037508.342788905,
                  20037508.342788905
               ],
               "origin":[
                  -20037508.342787,
                  20037508.342787
               ],
               "dx":0.00001
            },
            "102113":{
               "wkTemplate":"PROJCS[\"WGS_1984_Web_Mercator\",GEOGCS[\"GCS_WGS_1984_Major_Auxiliary_Sphere\",DATUM[\"D_WGS_1984_Major_Auxiliary_Sphere\",SPHEROID[\"WGS_1984_Major_Auxiliary_Sphere\",6378137.0,0.0]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",${Central_Meridian}],PARAMETER[\"Standard_Parallel_1\",0.0],UNIT[\"Meter\",1.0]]",
               "valid":[
                  -20037508.342788905,
                  20037508.342788905
               ],
               "origin":[
                  -20037508.342787,
                  20037508.342787
               ],
               "dx":0.00001
            }
         }
      },
      "declaredClass":"esri.geometry.Polyline",
      "_extent":null
   },
   "symbol":{
      "type":"simplelinesymbol",
      "style":"solid",
      "color":{
         "r":17,
         "g":255,
         "b":251,
         "a":1
      },
      "width":2.6666666666666665
   },
   "attributes":{...},
   "declaredClass":"esri.Graphic",
   "_shape":null,
   "_graphicsLayer":null,
   "_visible":true,
   "visible":true
}
  • if you step through the code in a debugger, does graphicsLayer definitely contain your polyline features? Can you post the JSON of those features? – Stephen Lead Jan 8 '15 at 23:33
  • I did check that the graphics layer contains the polyline features. The properties set on the graphics didn't have any obvious issues. I will post the JSON in my main question in a a sec. – lintmouse Jan 9 '15 at 16:25
  • why _dojo.SimpleLineSymbol and not esri/symbols/SimpleLineSymbol? can you write up a fiddle or jsbin? – John Gravois Jan 9 '15 at 17:33
  • We're wrapping the Dojo api in an angular service. It is actually creating an esri/symbols/SimpleLineSymbol. I'll work on something I can show in fiddle/jsbin. – lintmouse Jan 9 '15 at 18:38
1

Okay I found the problem. We are using Kendo as well. I was attaching features to a Kendo tree control which was mutating the ESRI objects. For some reason it didn't affect polygons and points. I just recreate the polyline features from the Kendo objects before adding to the map and that is working.

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.