change map creation
This commit is contained in:
parent
06c614d2c5
commit
83527f5cae
3 changed files with 16 additions and 14 deletions
11
src/map.ml
11
src/map.ml
|
|
@ -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
|
||||
|
|
|
|||
11
src/map.mli
11
src/map.mli
|
|
@ -2,9 +2,14 @@
|
|||
|
||||
type t
|
||||
|
||||
(** [create container] creates a map on [container]. * To have a functional map
|
||||
you will need to add a tile layer to it. *)
|
||||
val create : ?options:Jv.t -> Brr.El.t -> t
|
||||
(** [create id] creates a map on the <div> with DOM id [id]. To have a
|
||||
functional map you will need to add a tile layer to it. *)
|
||||
val create_on : ?options:Jv.t -> string -> t
|
||||
|
||||
(** [create_from_div container] creates a map given [container], an instance of
|
||||
a <div> HTML element. To have a functional map you will need to add a tile
|
||||
layer to it. *)
|
||||
val create_from_div : ?options:Jv.t -> Brr.El.t -> t
|
||||
|
||||
(** [invalidate_size map] checks if the map container size changed and updates
|
||||
the map if so *)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue