hide/show layer when marker is selected
Aug 06, 2012
I'm creating a slide with markers, and I almost have it doing what I want, with the exception of the triggers.
I want to: Create a marker... on hover it just shows the title. I haven't added a description, so the callout never changes to show anything but just the title. On click, it changes color and shows a layer. On click again, the color returns to normal, and the layer hides.
I got it all set up, but the hiding the layer doesn't work. I created two triggers on the marker. The first trigger shows the layer when the marker is clicked (with the condition that the marker is in the Normal state). This works. The second trigger hides the layer when the marker is clicked (with the condition that the marker is in the Selected state). This does not work. The color of the marker (the state indicator) changes colors as I toggle it so I know the states are changing, but once the layer is shown, it never hides.
Thoughts? Thanks!
14 Replies
Hi Heather,
The old toggle a button state conundrum! You'll need a variable, here's why....(I also provide a sample file).
http://community.articulate.com/forums/p/16191/92680.aspx#92680
Glad to know this is something I can fix, but I'm still a bit confused how to implement this. In your story file, looks like you used 5 triggers to do what I was trying to do in 2 triggers. I'm going to have about 10 markers on the slide. Will I need a separate variable for each one to toggle markers 1-10 to show/hide layers 1-10? Meaning 50 triggers (five for each of the 10)?
Honestly, I'm still confused about why putting the conditional on the states instead of the variables doesn't work. I mean, if the marker is in Selected state, why can't "onClick" hide the layer?
OK, I think I get why the states don't toggle. I realize now that when the user clicks, both triggers activate, negating each other. Makes sense now. But I'm still a little overwhelmed that it will take 50 triggers to do what I want on one slide.
Take a look at the attached file. Does this do what you want to accomplish?
I added a state to the marker and used the evaluation of Selected to show and hide the layer. Show if it IS selected, Hide if it IS NOT selected.
STTEEEEEVVVVEEEEE FFFFLLLOOOOWWWEEEERRRRSSSS!!!!!!
By taking the click out of the equation, you just solved the Toggle a Button to show a layer dilemma!
No variable needed.
WOOT!
Steve, your sample looks ok, but I can't get it to work when I add multiple markers. The closest I've gotten is making you click twice on a marker to get it to work. I basically want a group of markers to allow you to:
1. Hover over each marker to see the title of the callout.
2. When you click a marker, a layer is shown.
3. When you click the same marker, the layer is hidden.
4. If a layer is shown when you click a different marker, then it should just hide the first layer and show the next one for the new marker.
This seemed like it would be so easy when I started. It's my first time looking at triggers, so I'm going by trial & error. So far it's been lots of trials and lots of errors.
I'm a bit closer... I mistakenly set the two triggers to Is Selected and Is Normal instead of Is Selected and Is Not Selected. Works better now, but still not perfect. I'm changing the color on the marker states between Normal (red) and Selected (green). If 1 is Selected (green) and then you click 2, the color of 1 stays green even though the layer 1 goes away and layer 2 appears. Is there a way to ensure only one marker is in Selected state at one time?
Thank you very much for your help.
You could select all of the markers and assign them to a button group. This would make them toggle like radio buttons but would remove the toggle on / toggle off when clicking a single one. Working on another "clear" feature but I'm not sure I can make it work
Good call Steve...I missed the removal of the toggle. Looking forward to what you come up with.
Regardless...sweet solution to solving the toggle question that's been vexing us for some time now!
Mike
Workable. See the attached file A transparent shape over the top of the active marker in the overlay layer swaps it back.
WooHoo! This worked!
The only thing that it doesn't do is allow you to click the same marker to close the layer. So, if marker 2 is selected and layer 2 is showing, you can't click marker 2 to hide layer 2. However for my purposes, this will work just fine.
Steve, in your markerState.story, the first marker allows you to toggle it on/off. However you can see what I'm getting when you try to toggle your 2nd and 3rd markers... the callouts don't close when you click them again. I'm not sure why your first one works differently than the other two... all of mine won't toggle themselves.
Like I said that's not a deal-breaker for me, but I didn't know if you amazing gurus could solve that problem, too.
Thank you so much!
Heather,
I think Steve only built out the first layer. If you build out the others, it should work.
Mike
Oops...
My bad. Heather, if you add a trigger to the hotspot "hide this layer", then it will work.
Mike
I now see Steve's method of adding a transparent shape on the layers to change the state back to Normal. He tried to point it out to me earlier, but I was too focused on getting the show/hide to work I couldn't see straight.
Very cool. Thank you for helping!
This discussion is closed. You can start a new discussion or contact Articulate Support.