from ipyleaflet import Map, Polygon
center = [22.398332241511387, 114.02332305908205]
zoom = 11
m = Map(center=center, zoom=zoom)
m
m
polygon_coords = [
[22.403410892712124, 113.97697448730469],
[22.38373008592495, 113.98658752441405],
[22.369126397545887, 114.01268005371094],
[22.38563480185718, 114.02778625488281],
[22.395157990290755, 114.04701232910156],
[22.413567638369805, 114.06005859375],
[22.432609534876796, 114.06280517578125],
[22.444668051657157, 114.04838562011717],
[22.44847578656544, 114.04289245605469],
[22.444668051657157, 114.03259277343749],
[22.447206553211814, 114.01954650878906],
[22.436417600763114, 113.99620056152344],
[22.420549970290875, 113.98178100585938],
]
Let's create a polygon that can be transformed (i.e. rotated and scaled) and dragged. You can drag the polygon around, or use the handler to rotate it and to scale it. Note that the transformations are synced across all the map views.
pg = Polygon(locations=polygon_coords, transform=True, draggable=True)
m += pg
The scaling can be set to be uniform, meaning that it will preserve the height / width ratio.
pg.uniform_scaling = True
The ability to scale, rotate and drag can be turned off.
pg.scaling = False
pg.rotation = False
pg.draggable = False