Select to view content in your preferred language

How do you fix checkboxes for layers in an ArcGISTiledMapServiceLayer?

1048
3
03-14-2017 07:46 AM
VictorKniif
Deactivated User

So we have an ArcGISTiledMapServiceLayer with different featureLayers that we want to showcase with checkboxes.

Currently the solution looks as follow:

Toggle.js 

$(document).ready(function(){
$("#c1").click(function(){
$("#graphicsLayer1_layer").fadeToggle();
});

Body.php

<div class="filter-checkbox custom-checkbox">
<input type="checkbox" value="1" id="c1" name="chk_1" checked />
<label for="c1"></label>
</div>

The problem is when we toggle a checkbox, and zoom out in the map for an example it resets.

How do you prevent this?

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Victor,

  What does this fadeToggle function look like? 

The problem is when we toggle a checkbox, and zoom out in the map for an example it resets.

What resets the layers visibility or the checkbox state?

0 Kudos
VictorKniif
Deactivated User

FadeToggle is built in jquery

The layer is reloading when the map is zoomed. The checkbox state is still the same. It is just an onclick function on the checkbox. 

This provides us with the bugg where you uncheck the checkbox and the layer is gone but when you zoom the map it shows again. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Victor,

   OK, I see your issue then. You are using jQuery to fade the graphics layer dom object directly and not using the JS API to change the visible state of the GL. You need to set the GraphicsLayer Objects visible property to false so that the object know not to draw on map changes.