I have a Google map set up in a Slider Revolution slider and it pulls locations from a database. I have it set up so that it updates every 10 seconds, which works, but it seems that any time it runs and the map slide is not active, the pins disappear until the next time it updates. I would like it to update after each slide change.
This is the code that works for updating every 10 seconds:
function fetch(){
var mapsvg = this;
setInterval(()=>{
mapsvg.database.find()
}, 133000);
}
fetch();
This is the code that I tried to use for updating after slide change:
revapi2.bind("revolution.slide.onafterswap",function fetch(){
var mapsvg = this;
mapsvg.database.find();
})
fetch();
I get two errors with this code:
Uncaught (in promise) TypeError: Window.fetch: At least 1 argument required, but only 0 passed
and
Uncaught TypeError: mapsvg.database is undefined
Any help would be most appreciated.
In the event listener of Slider Revolution, you reference "this" which is the Slider Revolution object itself in that case. That object has no "database" attribute, so it fails.
You don't need to call fetch() in the second part, since the database.find() function will be called on slide swap event anyway.
As best you define global the mapsvg reference and in the Slider Revolution event listener just call mapsvg.database.find();
If you wish, drop a link to the current page, and I can give you an exact description of how to do it.