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.
Solved! Go to Solution.
It's exactly what i need, thank you very much for your help.
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
You will want to add and remove the graphicsLayer. Take a look at the updated JS Fiddle.
Thank you, for your help