Skip to content

Create Scale control class #1873

Closed
@berrfred

Description

@berrfred

Is your feature request related to a problem? Please describe.
It looks like L.control.scale() now has several useful options (e.g. position. metric, imperial), wouldn't it make sense to have it as a separate plugin as initially suggested by @BibMartin ? #270

Describe the solution you'd like
I am interested in showing only the metric scale at bottomrigth ... and maybe trick the css to integrate it in the attributions but this is another story. Today without a plugin it would require some dirty css and js to achieve it.

Describe alternatives you've considered
This is where I got with my usual script approach, moving control-scale to bottomright before attribution and assuming imperial is the second child, then delete it:

map_script_scale_control = '<script>document.addEventListener("DOMContentLoaded", function() {\
	var leafletControlScale = document.querySelector("div.leaflet-control-scale");\
	document.querySelector("div.leaflet-bottom.leaflet-right").insertBefore(\
		leafletControlScale, document.querySelector("div.leaflet-control-attribution")\
	);\
	leafletControlScale.removeChild(leafletControlScale.children[1]);\
});</script>'

map.get_root().html.add_child(folium.Element(map_script_scale_control))

image

Additional context
Also adding the following css I've been able to display attribution and scale on the same row ... not sure if this could also become a parameter to handle in the plugin.

map_style_scale_inline = '<style>\
	.leaflet-control-scale { margin-bottom: 0 !important; }\
	.leaflet-control-attribution { clear: none !important; }\
</style>'

map.get_root().header.add_child(folium.Element(map_style_scale_inline))

image

Implementation
Definitely missing experience on making a PR but taking inspiration from existing plugins I am willing to learn and might be able to achieve it ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature request or idea about how to make folium betterhelp wantedHelp is welcome for this issue or PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions