@@ -191,10 +191,10 @@ def close_map(
191191 hoverinfo = "skip" , showlegend = False ,
192192 ))
193193
194- # City-boundary outline (no fill), above the background fills.
194+ # City-boundary outline (no fill), above the background fills. It is context, so
195+ # it does not drive the zoom — the view frames the data, not the whole city.
195196 if boundary is not None :
196197 bg = _as_layer (boundary ).to_crs (4326 )
197- bounds .append (_bounds (bg ))
198198 lons , lats = _polygon_lines (bg )
199199 traces .append (go .Scattermapbox (
200200 lon = lons , lat = lats , mode = "lines" ,
@@ -258,6 +258,22 @@ def close_map(
258258 text = [hover [i ]], hoverinfo = "text" , showlegend = False ))
259259 coloraxis = {"colorscale" : _scale (palette ), "reversescale" : reverse ,
260260 "cmin" : min (fv ), "cmax" : max (fv ), "colorbar" : {"title" : fill }}
261+ elif (fv is None and hl is None and isinstance (color , (list , tuple ))
262+ and len (color ) == len (g ) and len (g ) > 1 ):
263+ # Per-polygon categorical colours (e.g. blocks by their closest POI):
264+ # one flat trace per distinct colour.
265+ colseries = list (color )
266+ for col in dict .fromkeys (colseries ):
267+ idx = [i for i , c in enumerate (colseries ) if c == col ]
268+ sub = g .iloc [idx ][["_id" , "geometry" ]]
269+ traces .append (go .Choroplethmapbox (
270+ geojson = json .loads (sub .to_json ()),
271+ locations = [g .at [i , "_id" ] for i in idx ],
272+ featureidkey = "properties._id" , z = [1 ] * len (idx ),
273+ colorscale = [[0 , col ], [1 , col ]], showscale = False ,
274+ marker = {"opacity" : opacity , "line" : poly_line },
275+ text = [hover [i ] for i in idx ], hoverinfo = "text" ,
276+ showlegend = False ))
261277 else :
262278 geojson = json .loads (g [["_id" , "geometry" ]].to_json ())
263279 common = {
0 commit comments