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
}
graphicsLayer
definitely contain your polyline features? Can you post the JSON of those features?