python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.86k stars 2.22k forks source link

adding Nautical milles unit to MeasureControl #1688

Closed jef-maubert closed 1 year ago

jef-maubert commented 1 year ago

Thanks a lot for the MeasureControl plugin that I found very usefull !

This MeasureControl plugin includes "acres", "feet", "kilometers","meters" and "miles" as linear units. (Note : the "miles" unit refers to "Statute mile", of the British Imperial unit system)

Could it be possible to introduce also nautical mile (or "nautical") ? This unit is very usefull (almost mandatory) for sea navigation because it is directly linked to the distance between paralleles.

The Implementation could be a new item in the objects list of the unit.js file :

nautical: {
    factor: 1,0/1852.0,
    display: 'nauticals',
    decimals: 2
},
sqnautical: {
    factor: 1,0/1852.0/1852.0,
    display: 'sqnauticals',
    decimals: 2
},

Best regards

Conengmo commented 1 year ago

Hi @jef-maubert, I haven't tried this but I'm pretty sure you can do this with the standard options of the JS package we use underneath. See https://github.com/ljagis/leaflet-measure#units. It exposes a unit argument that you can try. Our Python wrapper passes on any keyword arguments.

For example:

MeasureControl(
    units={
"nautical": {
    "factor": 1/1852.0,
    "display": 'nauticals',
    "decimals": 2
},
"sqnautical": {
    "factor": 1/1852.0/1852.0,
    "display": 'sqnauticals',
    "decimals": 2
},
    }
).add_to(m)

Can you try if that works as expected?

jef-maubert commented 1 year ago

T‌hanks a lot for your answer

Yes It works perfectly (I had just to quote the python dictionary field names )

Have a good new year 223 !

​‌

Best regards, Jef Maubert 06-78-34-62-36

 

De : "Frank Anema" A : "python-visualization/folium" ,"jef-maubert" ,"Mention" Envoyé: lundi 2 Janvier 2023 09:17 Objet : Re: [python-visualization/folium] adding Nautical milles unit to MeasureControl (Issue #1688)  

 

Hi @jef-maubert, I haven't tried this but I'm pretty sure you can do this with the standard options of the JS package we use underneath. See https://github.com/ljagis/leaflet-measure#units. It exposes a unit argument that you can try. Our Python wrapper passes on any keyword arguments.

For example:

MeasureControl( units={ nautical: { factor: 1/1852.0, display: 'nauticals', decimals: 2 }, sqnautical: { factor: 1/1852.0/1852.0, display: 'sqnauticals', decimals: 2 }, } ).add_to(m)

Can you try if that works as expected?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

Conengmo commented 1 year ago

Perfect, happy to hear. Best wishes to you as well!