Hi,
I'm finding this weird.
I have a couple of feature services which I initialise as hidden, then I add them to the map.
var layer = new FeatureLayer(url, { mode: FeatureLayer.MODE_SELECTION, outFields: ["*"], visible: false });
After adding them to the map, I do a query.
When a click event is handled, I'd like to set these layers visible, so I do layer.show();
Before the layer.show(), there are 2 graphics in this layer. But after the layer.show() the graphics are gone.
This is my console log for testing purposes:
Before layer.show(), layer: Object {url: "REMOVED ON PURPOSE", _url: Object, spatialReference: Object, initialExtent: Object, _div: Object…} Before layer.show(), Graphics: [Object, Object] Before layer.show(), is layer visible: false layer.show() Before layer.show(), layer: Object {url: "REMOVED ON PURPOSE", _url: Object, spatialReference: Object, initialExtent: Object, _div: Object…} After layer.show(), Graphics: [] After layer.show(), is layer visible: true -------------------------------------------------------------
What is happening here??
If you can share the code , we can try to figure out whats going wrong...
var redliningLayer = new FeatureLayer(url, { id: getLayerName(index), mode: FeatureLayer.MODE_SELECTION, outFields: ["*"], visible: false });
redliningLayer.selectFeatures(queryByMeldingId, FeatureLayer.SELECTION_NEW, function (selection) { // create text symbol for these graphics Utilities.createTextGraphic(selection); }, function (error) { console.error("redlining.Points.selectFeatures failed with error: " + error); });
redliningLayer.show();
It's pretty straightforward.
This is a big solution, so I can't share all code.
But how come the graphics are available before the .show() and are removed after the .show()?
I'm using arcgis javascript api 3.13 b.t.w.
You might try moving the 'show()' function inside of the query callback. If the query finishes after show() is called it could be doing something strange.
In addition sometimes I try using setVisibility() if show() isn't working.