View's graphics layer not displaying Polylines

1986
3
Jump to solution
05-05-2017 12:43 PM
SamuelAbati
New Contributor III

I have two SubLayers (from a MapImageLayer), one is a Point and the other a Polyline.

I'm querying them for their geometry and adding as graphics to the View's graphics layers (view.graphics) as needed.

The problem is that, only the Point feature is being displayed, the Polylines aren't.

Things checked :

1) The query is indeed returning the features asked with geometry

2) The features(graphics) are indeed added to the View's graphics collection, just not displayed

var symbol_trecho = new SimpleLineSymbol({
    width: 10,
    color: [255, 0, 0, 1]
});

var query = new Query();
query.where = response.where;
query.outFields = ['OBJECTID', 'COD'];
query.returnGeometry = true;
lyr_polylines.queryFeatures(query).then(function(results){
    var features = results.features;
    features.forEach(function(feature,i){
        feature.symbol = symbol_polyline;
        view.graphics.add(feature);
    });;
})‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Thing is, I add both the Points and the Polylines to the View's graphics (Points always added first), can it only display one type of geometry? I tried adding to another GraphicsLayer too but it didn't work, so I'm not sure of anything

I can't track this issue, it's driving me insane...

(The mismatching names of the symbols was just a typo and couldn't fix it)

0 Kudos
1 Solution

Accepted Solutions
ThomasSolow
Occasional Contributor III

Try setting the outSpatialReference property on the query.  You might be able to set it to an object: { wkid: 102100 } or you might have to create a new SpatialReference with that wkid: SpatialReference | API Reference | ArcGIS API for JavaScript 4.3 ie new SpatialReference({wkid: 102100});

View solution in original post

3 Replies
ThomasSolow
Occasional Contributor III

view.graphics can contain graphics with multiple geometry types, just like a graphicslayer.  So the issue is elsewhere.

I would check to make sure the spatial references on the polyline geometries are correct.  That's a common issue and it's usually the first thing I check when something isn't showing up on the map.

Aside from that, I'm not sure.  The same you posted looks correct to me.

SamuelAbati
New Contributor III

That was it! The Point was in Mercator (102100) but the Polylines were returning as SIRGAS 2000 (The one in our service)

The only thing I can think of that would be different, is that in the Point's query I use the mapPoint as geometry, but the Polylines query I use the where clause.

Well, now do you know how to convert from Wkid 4674 to 102100? Or force the query to return as 102100

0 Kudos
ThomasSolow
Occasional Contributor III

Try setting the outSpatialReference property on the query.  You might be able to set it to an object: { wkid: 102100 } or you might have to create a new SpatialReference with that wkid: SpatialReference | API Reference | ArcGIS API for JavaScript 4.3 ie new SpatialReference({wkid: 102100});