make Map.create take Brr.El
This commit is contained in:
parent
0370fb97a2
commit
68ee03bead
4 changed files with 12 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
(executable
|
(executable
|
||||||
(name main)
|
(name main)
|
||||||
(modules main)
|
(modules main)
|
||||||
(libraries leaflet)
|
(libraries brr leaflet)
|
||||||
(modes js)
|
(modes js)
|
||||||
(preprocess
|
(preprocess
|
||||||
(pps js_of_ocaml-ppx)))
|
(pps js_of_ocaml-ppx)))
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
(* create map *)
|
(* create map *)
|
||||||
let map =
|
let map =
|
||||||
let container_id = "map" in
|
let container =
|
||||||
Leaflet.Map.create container_id
|
match Brr.Document.find_el_by_id Brr.G.document (Jstr.of_string "map") with
|
||||||
|
| None -> failwith "map container not found"
|
||||||
|
| Some el -> el
|
||||||
|
in
|
||||||
|
Leaflet.Map.create container
|
||||||
|
|
||||||
(* setup map *)
|
(* setup map *)
|
||||||
let () =
|
let () =
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ let of_jv = Fun.id
|
||||||
|
|
||||||
let to_jv = Fun.id
|
let to_jv = Fun.id
|
||||||
|
|
||||||
let create ?(options = Jv.null) container_id =
|
let create ?(options = Jv.null) container =
|
||||||
Jv.call Global.leaflet "map" [| Jv.of_string container_id; options |]
|
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 invalidate_size map =
|
let invalidate_size map =
|
||||||
let (_ : Jv.t) = Jv.call map "invalidateSize" [| Jv.true' |] in
|
let (_ : Jv.t) = Jv.call map "invalidateSize" [| Jv.true' |] in
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
type t
|
type t
|
||||||
|
|
||||||
val create : ?options:Jv.t -> string -> t
|
val create : ?options:Jv.t -> Brr.El.t -> t
|
||||||
|
|
||||||
val invalidate_size : t -> unit
|
val invalidate_size : t -> unit
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue