I’m trying to do a map where depending of zoom level the plot changes. For example, if I can see the countries the data is source_1 if I zoom in to see what have inside determined country the data that will appear is another. What is the best way to do this?customJS where I identify the zoom lvl and change data dynamic?change when range changes?If there is another way…
I didn’t try anything yet but maybe something like:
filter = CustomJSFilter(args=dict(source=source), code="""
var indices = [];
var zoom_level = cb_obj.end_zoom_level;
var zoom_threshold = 10;
for (var i = 0; i < source.get_length(); i++) {
if (zoom_level <= zoom_threshold) {
indices.push(i);
}
}
return indices;
""")
@thiago you need to provide more information. Are you using a GMap plot, or a tile source on a regular plot? GMap plots do have a notion of “zoom level” (it is actually the GMaps API that defines this, and Bokeh uses it). Regular plots do not have any notion of “zoom level” they just have ranges with start and end properties. You can react to changes in these but its up to you to define what “zoom level” means (depending on your specific situation and requirements).