change map creation

This commit is contained in:
Swrup 2022-06-18 07:53:26 +02:00
parent 06c614d2c5
commit 83527f5cae
3 changed files with 16 additions and 14 deletions

View file

@ -6,10 +6,13 @@ let of_jv = Fun.id
let to_jv = Fun.id
let create ?(options = Jv.null) container =
match Brr.El.at (Jstr.of_string "id") container with
| None -> failwith "container doesn't have id"
| Some id -> Jv.call Global.leaflet "map" [| Jv.of_jstr id; options |]
let create_on ?(options = Jv.null) id =
Jv.call Global.leaflet "map" [| Jv.of_string id; options |]
let create_from_div ?(options = Jv.null) container =
if Brr.El.has_tag_name Brr.El.Name.div container then
Jv.call Global.leaflet "map" [| Brr.El.to_jv container; options |]
else failwith "container is not a <div>"
let invalidate_size map =
let (_ : Jv.t) = Jv.call map "invalidateSize" [| Jv.true' |] in