0

The code below is the switch statement that I am currently using. I can't seem to get the values (case) to match up with the horizontal slider I am using (4 unique values-each layer). I was thinking of trying an if else condition instead. Anyone have the best way to accomplish this?

function setPixelFilter() {
        var val = slider.get("value");
        switch (val) {
          case 0:
            var imageLayer = new ArcGISImageServiceLayer("https://...ImageServer")
            map.addLayer(imageLayer)
            break;
          case 100/3:
            var imageLayer = new ArcGISImageServiceLayer("https://...ImageServer")
            map.addLayer(imageLayer)                
            break;
          case 100/3*2:
            var imageLayer = new ArcGISImageServiceLayer("https://...ImageServer")
            map.addLayer(imageLayer)
            break;
          case 100:
            var imageLayer = new ArcGISImageServiceLayer("https://...ImageServer")
            map.addLayer(imageLayer)
            break;
  • you need to try setting a breakpoint in your browser developer tools to step through the code and inspect the value of 'val' – John Gravois Jul 14 '15 at 18:16
  • The slider.value is 5.5, 6, 7, 8 respectively. – Mat S Jul 14 '15 at 18:21
  • none of which equal 0, 33.3, 66.6 or 100. or am i missing something? – John Gravois Jul 14 '15 at 18:44
  • Yeah sorry, 0, 33.3, 66.6, 100 have to be in a percentage since that is the position of the horizontal slider. At that percentage (33.3) value 5.5 is pulled which equates to that imageLayer. I figured out the issue I was having but am running into another issue of the layers not redrawing after each slide which I think Ill ask in a separate question. – Mat S Jul 14 '15 at 19:01
  • What I was going to try to do as a work around so one layer draws and removes the previous layers at each horizontal value, was do an if else statement instead of using the switch. – Mat S Jul 14 '15 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.