Visible & hidden option!

1342
5
Jump to solution
11-20-2014 03:10 AM
ArcGISG_I_S
New Contributor

Dear all,

I am adding point using their coordinate (x,y) and i want to hide the different point and make them visible after button click. I think that something is wrong with my code.

Below is the JavaScript Code:

map.addLayer(facilitiesGraphicsLayer);

       

  var x1 = 'facilitiesGraphicsLayer.add(new Graphic(new Point(6052367,2817478,map.spatialReference)))';

  var x2 = 'facilitiesGraphicsLayer.add(new Graphic(new Point(6053464,2817499,map.spatialReference)))';

  var x3 = 'facilitiesGraphicsLayer.add(new Graphic(new Point(6054562,2817520,map.spatialReference)))';

var xx1 = document.getElementById(x1);  

xx1.style.display = 'hidden';

var xx2 = document.getElementById(x2);  

xx2.style.display = 'hidden';

var xx3 = document.getElementById(x3);  

xx3.style.display = 'hidden';

Any help will be appreciated.
Thanks to all of you.

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

I believe you will want to use the remove and add methods for the GraphicsLayer.  Here is an example of this.

View solution in original post

0 Kudos
5 Replies
JakeSkinner
Esri Esteemed Contributor

I believe you will want to use the remove and add methods for the GraphicsLayer.  Here is an example of this.

0 Kudos
ArcGISG_I_S
New Contributor

It's exactly what i need, thank you very much for your help.

0 Kudos
ArcGISG_I_S
New Contributor

Hi,

your code is working good, but i have more than 100 points that i should add and hide in the same time i tried to use for but its not working. Below the code i am using;

x1 = graphicsLayer.add(new Graphic(new Point([-122.65, 45.52], new SpatialReference({wkid: 4326})), pointSymbol));

x2 = graphicsLayer.add(new Graphic(new Point([-122.39, 45.51], new SpatialReference({wkid: 4326})), pointSymbol));

x3 = graphicsLayer.add(new Graphic(new Point([-122.35, 45.51], new SpatialReference({wkid: 4326})), pointSymbol));

x... = ....

 

     map.addLayer(graphicsLayer);

  

     on(dojo.byId("show"), "click", function () {

  for (i=1;i < 100;i++)

  {

  graphicsLayer.add(xi);

  }

     })

  on(dojo.byId("hide"), "click", function () {

  for (i=1;i < 100;i++)

  {

         graphicsLayer.remove(xi);

  }

     })

Could you please show me where is the error.

Thank you very much

0 Kudos
JakeSkinner
Esri Esteemed Contributor

You will want to add and remove the graphicsLayer.  Take a look at the updated JS Fiddle.

0 Kudos
ArcGISG_I_S
New Contributor

Thank you, for your help

0 Kudos