opengeos / leafmap

A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
https://leafmap.org
MIT License
3.21k stars 384 forks source link

ability to select location of cholorpeth legen (lefttop,leftbottom,rightbottom,bottomcenter, etc) #305

Closed Niko-La closed 1 year ago

Niko-La commented 1 year ago

The current default location of the legend is interfering with whitetoolgui access feature request 1) ability to select location during the m.add(gdf,....., legend_location ='bottomleft') 2)ability to move the legend after ployment to organize before export to html

image

when having two cholorpeth layers this is an even bigger issue.

edit: https://leafmap.org/notebooks/53_choropleth/ has a moveable one by default? how is this is the leafmap package not the same one? do i need to update it manually? i tried to leafmap.update_package() and try by restarting runtime but not getting the same effects

same with the layer info it is not attached to one part of the screen but rather follows the maps

edit2: ran your 53 cholorpeth map on colab and it became fixed just like mine, so maybe it's colab? binder jupyter didn't work Error displaying widget: model not found

image image
giswqs commented 1 year ago

The legend for folium is movable, while the legend for ipyleaflet is not movable. Binder might have some issues with installing ipyleaflet. For ipyleaflet, the legend height and position can be customized. You can also make the map fullscreen so the components do not overlap.

https://leafmap.org/leafmap/#leafmap.leafmap.Map.add_legend

Niko-La commented 1 year ago

Tried to run folium image

Worked fine with the started code

but my working ipyleaflet code is giving the following error on folium backend

image

It was working as expected on ipyleaflet with the same code

giswqs commented 1 year ago

This is likely an issue caused by your data. I just tried out the notebook example. Both the ipyleaflet and folium backends work fine.

Niko-La commented 1 year ago

Ok i will investigate my data and reproduce it using the notebook example as the reference file.

I tried kepler backend

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[<ipython-input-23-4833d09b646d>](https://localhost:8080/#) in <module>
      5 #m.add_data(gdf, column='Median Total Household Income 2020', scheme='Quantiles', cmap='Blues', legend_title='Median totalHousehold Income 2020', layer_name = "Income")
      6 #m.split_map(left_layer="SATELLITE", right_layer="nlmaps.water")
----> 7 m.add_data(gdf, column='Average Household Size 2021', scheme='Quantiles', cmap='Reds', legend_title='Ave House ppl 2021', layer_name = "House Size", )
      8 m
      9 

TypeError: add_data() got an unexpected keyword argument 'column'

same code that was working for default backend. Technically the code should be identical when changing backend correct?

giswqs commented 1 year ago

Not necessarily. Not all backends support the same arguments.