AnsweredAssumed Answered

Want to Keep Feature Layer Invisible, but Graphic Layer Visible,  It disappears when FL is set to Visible: False

Question asked by ipeebles on Dec 2, 2016
Latest reply on Dec 6, 2016 by ipeebles

Good morning.  I have a working app, but I have running into an issue with the graphics.  I have the app set up, where the user can make a number of picks (draw points) on the map until they are ready to submit (applyEdits) to the feature layer.  Right now, I use the standard map graphics layer and clear the graphic each time the user makes a click on the map.  I do not want to display the graphic each time the user makes a pick, only have it display as they make an individual pick.


Now for the tricky part.  After the user makes their final pick and decides to submit, I want the graphics to remain on the map until the application closes.  To do this, I have set up a Graphics layer,  The problem is, when I pass in the geometry (feature), the graphic displays as I want, but only if the Feature Layer is set to Visible: True.  I need the Feature Layer to remain Visible: False, since the data will be sensitive to the Public.   When the Feature Layer is set to  Visible: False, The graphics layers becomes hidden as well.


So in short, how can I have the feature layer where the visibility is set to false, yet have the Graphics layer display?


Below are samples of my work flow and some code:


1. Drawing the Point and submitting after 3 picks (the third pick is the point I want to submit)


Buttons used to perform draw and submit


Performing a Draw using the Draw Hot Spot 1.  On the third pick, I want to submit.  The graphic is cleared as I want.  Notice how the graphic disappears each time it is re-drawn.  I want this to occur by design.


Pick 1

Pick 2

Pick 3 


When hitting the Submit Hot Spot Button, it posts to the feature layer with an alert.


Now when going to Draw Hot Spot 2, notice how a new graphic is drawn, but the blue pushpin disappears.  This is what I do not want.


Now for the code:


Graphics Layer:


// Symbols - Picture Marker Symbols
symbol1 = new PictureMarkerSymbol('', 30, 30);
symbol2 = new PictureMarkerSymbol('', 30, 30);
symbol3 = new PictureMarkerSymbol('', 30, 30);

// Graphics Layers with Picture Symbols
var symbol1GraphicsLayer = new GraphicsLayer();
var symbol2GraphicsLayer = new GraphicsLayer();
var symbol3GraphicsLayer = new GraphicsLayer();


Feature Layer:

// Feature Layers
// 01. Traffic Intersections 1
//var trafficInt1 = new FeatureLayer("", {
var trafficInt1 = new FeatureLayer("", {
mode: FeatureLayer.MODE_SNAPSHOT,
visible: false,
outFields: ["*"]


Draw and Editing


// Create Draw and Edit Toolbars 1
   function createToolbar1() {
   drawToolbar1 = new Draw(map);
   editToolbar1 = new Edit(map);
   drawToolbar1.on("draw-complete", addGraphicToMap1);

function addGraphicToMap1(evt) {;
   newAttributes1 = {"direction": "1"};
   newFeature1 = new Graphic(evt.geometry, null, newAttributes1);
   value1 = Graphic(evt.geometry, symbol1, newAttributes1));
   console.log("Graphic geometry for Hot Spot 1 is: ", value1);

function addGraphicToTrafficInt1(evt) {
   value4 = trafficInt1.applyEdits([newFeature1], null, null);
   console.log("Graphic Applied to Feature Layer (0)", value4)


   // Graphics Layer and Adding Geometry


alert("You have successfully added Hot Spot 1")

registry.byId("Point1").on("click", function editDisconnect1(){
   alert("Hot Spot 1 has already been added.")



Anyone have any ideas?  As always, thanks for the feedback.