Resize Map to Zoom to a particular area

Hi,

I have some code that creates a map and initialises the figure/map to as shown below with the X and Y ranges set to cover the min/max values associated with my data set of polygons overlaid on the map.

tileSrc = get_provider(Vendors.CARTODBPOSITRON_RETINA)

 dist = figure(x_range=Range1d(min(min(div.sa1_source.data['E'])), max(max(div.sa1_source.data['E']))), 
                     y_range=Range1d(min(min(div.sa1_source.data['N'])), max(max(div.sa1_source.data['N']))),
                     height=1500, width=1800, height_policy="max", width_policy="max", 
                     sizing_mode="scale_height")
dist.add_tile(tileSrc)

If a user selects a particular region I would like the map to zoom to that area automagically. (It is a simple scroll/zoom to do it manually). In the code below I tried overriding the x_range and y_range values with the range that covers the selected area which does something (it reduces the coverage of the tiles to the new x/y ranges but it doesn’t zoom or centre to that range.

I could recreate the figure and poke it back into the doc but then I’d have to recreate a bunch of other glyphs (I suspect) and attach them to the new figure.

Any ideas how one might resize and recentre the map given a new range?

def newZone(attr, old, new):
      #
      # reset zone layer
      #
       global currentZone, mapper
        
       currentZone = int(new)

       zonebase = div.sa1df.loc[div.sa1df.distzone == currentZone,['distarea','geometry','private','fill_colour']]
        
       if (currentZone == 0) or (len(zonebase) == 0):
                zone_source.data = dict(zone_Null.data)
                print("Current Zone is: {0}".format(div.divZones.loc[div.divZones.Id == currentZone]))
                dist.title.text = "Distribution Areas for {0}".format(div.divZones.loc[div.divZones.Id == 
                    currentZone,'Name'].tolist()[0])
                saveArea.disabled = True
                zones = []
        else:
                zones = zonebase.dissolve(by='distarea', aggfunc='sum')
                zones.reset_index(inplace=True)
                zones['fill_alpha'] = 0
                zones['fill_colour'] = zones.distarea % 20
                #
                #  Adjust 'private' count based on distAreas adjustments
                #
                # TODO Redo adjustments
                zones['Adjusted'] = zones.private #+ zones.Adjustment
            
                #
                zone_source.data = dict(convert_GeoPandas_to_Bokeh_format(zones).data)
                
                dist.x_range = Range1d(min(min(zone_source.data['E'])), max(max(zone_source.data['E'])))
                dist.y_range = Range1d(min(min(zone_source.data['N'])), max(max(zone_source.data['N'])))

                dist.title.text = 'Distribution Areas for {0}'.format(div.divZones.loc[div.divZones.Id == currentZone,'Name'].tolist()[0])