What is the best way to dynamic change the lod of a map?

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;
""")

I have done a few maps in bokeh, but it’s easiest to use a WMTSTileSource (tiles — Bokeh 3.2.0 Documentation)

Then in your figure make sure you have some kind of zoom ('wheel_zoom' is the most common) so you can zoom in and out.

@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).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.