Measure Control#

Example#

from ipyleaflet import Map, MeasureControl, basemaps

m = Map(center=(43.0327, 6.0232), zoom=9, basemap=basemaps.Hydda.Full)

measure = MeasureControl(
    position='bottomleft',
    active_color = 'orange',
    primary_length_unit = 'kilometers'
)
m.add_control(measure)

measure.completed_color = 'red'

measure.add_length_unit('yards', 1.09361, 4)
measure.secondary_length_unit = 'yards'

measure.add_area_unit('sqyards', 1.19599, 4)
measure.secondary_area_unit = 'sqyards'

m

Attributes and methods#

class ipyleaflet.leaflet.MeasureControl(**kwargs)[source]#

MeasureControl class, with Control as parent class.

A control which allows making measurements on the Map.

primary_length_unit#

Possible values are ‘feet’, ‘meters’, ‘miles’, ‘kilometers’ or any user defined unit.

Type

str, default ‘feet’

secondary_length_unit#

Possible values are ‘feet’, ‘meters’, ‘miles’, ‘kilometers’ or any user defined unit.

Type

str, default None

primary_area_unit#

Possible values are ‘acres’, ‘hectares’, ‘sqfeet’, ‘sqmeters’, ‘sqmiles’ or any user defined unit.

Type

str, default ‘acres’

secondary_area_unit#

Possible values are ‘acres’, ‘hectares’, ‘sqfeet’, ‘sqmeters’, ‘sqmiles’ or any user defined unit.

Type

str, default None

active_color#

The color used for current measurements.

Type

CSS Color, default ‘#ABE67E’

completed_color#

The color used for the completed measurements.

Type

CSS Color, default ‘#C8F2BE’

add_area_unit(name, factor, decimals=0)[source]#

Add a custom area unit.

Parameters
  • name (str) – The name for your custom unit.

  • factor (float) – Factor to apply when converting to this unit. Area in sqmeters will be multiplied by this factor.

  • decimals (int, default 0) – Number of decimals to round results when using this unit.

add_length_unit(name, factor, decimals=0)[source]#

Add a custom length unit.

Parameters
  • name (str) – The name for your custom unit.

  • factor (float) – Factor to apply when converting to this unit. Length in meters will be multiplied by this factor.

  • decimals (int, default 0) – Number of decimals to round results when using this unit.