Using Odyssey.js with Cartodb.js

المشرف العام

Administrator
طاقم الإدارة
I'm looking to use Odyssey to create an interactive introduction to various data layers on an interactive web map I've created using CartoDB.js. I'd like to have different data layers turned on / off each time the user clicks through an Odyssey slide.

From what I understand that this can be done in the odyssey.js code by calling the cartodb.js methods for hiding and showing sublayers. I've tried searching for examples of this but haven't come across any. Can anyone provide a link to an example such as a Github GIST / bl.ock?

UPDATE 12.6.14

I was able to use a hack where I create a custom javascript event to be fired when the odyssey slides change. I then created a function that listened for the custom event and tracks the index of the current slide in the div.slides-container array. This way it is possible to tell what current slide the user is viewing and then call cartodb.js methods outside of Odyssey.js as needed.

A Gist of the code may be found here and a live version may be viewed here.

Ideally I'd like to cut down on the redundancy of this code and call cartodb.js methods for showing or hiding layers, setting SQL or CartoCSS of various sublayers of a layer when calling cartodb.createLayer().

Any suggestions would be appreciated and I'll leave the question as not answered until I find the correct way to do this. @javisantana?



أكثر...
 
أعلى