In [8]:
#from __future__ import print_function
import ipyleaflet
from ipyleaflet import (
Map,
Marker,
TileLayer, ImageOverlay,
Polyline, Polygon, Rectangle, Circle, CircleMarker,
GeoJSON,
DrawControl
)
In [2]:
%load_ext watermark
In [7]:
%watermark -v -m -p watermark,ipyleaflet
In [5]:
lg = 0.0
lt= 40.0
lg2 = lg + 1
lt2 = lt + 1
my_geojson_shape = {"type": "Feature", \
"properties": {"operator": 'XXX'}, \
"geometry": { "type" : "Polygon", \
"coordinates": [[[lg, lt],[lg2, lt],[lg2, lt2],[lg, lt2],[lg, lt]]]
}
}
my_map_data = {"type": "FeatureCollection",
"features": [my_geojson_shape ],
"marker-color": "#fff"}
for feature in my_map_data['features']:
feature['properties']['style'] = {
"color": 'black', # color of the polygone outline
"weight": 2, # weight of the polygone outline
"opacity": 0.3, # opacity of the polygone outline
"fillColor": "orange", # color inside the polygon
"fillOpacity": 0.3, # opacity inside the polygon
}
m = Map(center=(40.5,0.5), zoom=8)
g = GeoJSON(data=my_map_data, hover_style={'fillColor': 'red'}, name='My Rectangle')
m.add_layer(g)
m
In [ ]: