forked from swrup/leaflet
make geopub/leaflet a separate library
This commit is contained in:
commit
2fe7c1450d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_build
|
42
.ocamlformat
Normal file
42
.ocamlformat
Normal file
@ -0,0 +1,42 @@
|
||||
version=0.21.0
|
||||
assignment-operator=end-line
|
||||
break-cases=fit
|
||||
break-fun-decl=wrap
|
||||
break-fun-sig=wrap
|
||||
break-infix=wrap
|
||||
break-infix-before-func=false
|
||||
break-separators=before
|
||||
break-sequences=true
|
||||
cases-exp-indent=2
|
||||
cases-matching-exp-indent=normal
|
||||
doc-comments=before
|
||||
doc-comments-padding=2
|
||||
doc-comments-tag-only=default
|
||||
dock-collection-brackets=false
|
||||
exp-grouping=preserve
|
||||
field-space=loose
|
||||
if-then-else=compact
|
||||
indicate-multiline-delimiters=space
|
||||
indicate-nested-or-patterns=unsafe-no
|
||||
infix-precedence=indent
|
||||
leading-nested-match-parens=false
|
||||
let-and=sparse
|
||||
let-binding-spacing=compact
|
||||
let-module=compact
|
||||
margin=80
|
||||
max-indent=68
|
||||
module-item-spacing=sparse
|
||||
ocp-indent-compat=false
|
||||
parens-ite=false
|
||||
parens-tuple=always
|
||||
parse-docstrings=true
|
||||
sequence-blank-line=preserve-one
|
||||
sequence-style=terminator
|
||||
single-case=compact
|
||||
space-around-arrays=true
|
||||
space-around-lists=true
|
||||
space-around-records=true
|
||||
space-around-variants=true
|
||||
type-decl=sparse
|
||||
wrap-comments=false
|
||||
wrap-fun-args=true
|
1
CHANGES.md
Normal file
1
CHANGES.md
Normal file
@ -0,0 +1 @@
|
||||
## unreleased
|
8
LICENSE.md
Normal file
8
LICENSE.md
Normal file
@ -0,0 +1,8 @@
|
||||
The ISC License (ISC)
|
||||
=====================
|
||||
|
||||
Copyright © 2022, TODO
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
40
README.md
Normal file
40
README.md
Normal file
@ -0,0 +1,40 @@
|
||||
# leaflet
|
||||
|
||||
[leaflet] is an [OCaml] executable/library to TODO.
|
||||
|
||||
## Installation
|
||||
|
||||
`leaflet` can be installed with [opam]:
|
||||
|
||||
```sh
|
||||
opam install leaflet
|
||||
```
|
||||
|
||||
If you don't have `opam`, you can install it following the [how to install opam] guide.
|
||||
|
||||
If you can't or don't want to use `opam`, consult the [opam file] for build instructions.
|
||||
|
||||
## Quickstart
|
||||
|
||||
```ocaml
|
||||
let () = Format.printf "TODO@."
|
||||
```
|
||||
|
||||
For more, have a look at the [example] folder, at the [documentation] or at the [test suite].
|
||||
|
||||
## About
|
||||
|
||||
- [LICENSE]
|
||||
- [CHANGELOG]
|
||||
|
||||
[CHANGELOG]: ./CHANGES.md
|
||||
[example]: ./example
|
||||
[LICENSE]: ./LICENSE.md
|
||||
[opam file]: ./leaflet.opam
|
||||
[test suite]: ./test
|
||||
|
||||
[documentation]: TODO/leaflet
|
||||
[how to install opam]: https://opam.ocaml.org/doc/Install.html
|
||||
[OCaml]: https://ocaml.org
|
||||
[opam]: https://opam.ocaml.org/
|
||||
[leaflet]: TODO/leaflet
|
17
doc/index.mld
Normal file
17
doc/index.mld
Normal file
@ -0,0 +1,17 @@
|
||||
{0 leaflet}
|
||||
|
||||
{{:https://TODO/leaflet} leaflet} is an {{:https://ocaml.org} OCaml} library/executable to TODO.
|
||||
|
||||
{1:api API}
|
||||
|
||||
{!modules:
|
||||
Leaflet
|
||||
}
|
||||
|
||||
{1:private_api Private API}
|
||||
|
||||
You shouldn't have to use any of these modules, they're used internally only.
|
||||
|
||||
{!modules:
|
||||
TODO
|
||||
}
|
33
dune-project
Normal file
33
dune-project
Normal file
@ -0,0 +1,33 @@
|
||||
(lang dune 2.9)
|
||||
|
||||
(implicit_transitive_deps false)
|
||||
|
||||
(name leaflet)
|
||||
|
||||
(license ISC)
|
||||
|
||||
(authors "TODO")
|
||||
|
||||
(maintainers "TODO")
|
||||
|
||||
(source
|
||||
(uri TODO/leaflet))
|
||||
|
||||
(homepage TODO/leaflet)
|
||||
|
||||
(bug_reports TODO/leaflet)
|
||||
|
||||
(documentation TODO/leaflet)
|
||||
|
||||
(generate_opam_files true)
|
||||
|
||||
(package
|
||||
(name leaflet)
|
||||
(synopsis "OCaml library/executable to TODO")
|
||||
(description
|
||||
"leaflet is an OCaml library/executable to TODO.")
|
||||
(tags
|
||||
(leaflet TODO TODO TODO TODO))
|
||||
(depends
|
||||
(ocaml
|
||||
(>= 4.08))))
|
3
example/dune
Normal file
3
example/dune
Normal file
@ -0,0 +1,3 @@
|
||||
(executable
|
||||
(name main)
|
||||
(modules main))
|
1
example/main.ml
Normal file
1
example/main.ml
Normal file
@ -0,0 +1 @@
|
||||
let () = Format.printf "TODO@."
|
33
leaflet.opam
Normal file
33
leaflet.opam
Normal file
@ -0,0 +1,33 @@
|
||||
# This file is generated by dune, edit dune-project instead
|
||||
opam-version: "2.0"
|
||||
synopsis: "OCaml library/executable to TODO"
|
||||
description: "leaflet is an OCaml library/executable to TODO."
|
||||
maintainer: ["TODO"]
|
||||
authors: ["TODO"]
|
||||
license: "ISC"
|
||||
tags: ["leaflet" "TODO" "TODO" "TODO" "TODO"]
|
||||
homepage: "TODO/leaflet"
|
||||
doc: "TODO/leaflet"
|
||||
bug-reports: "TODO/leaflet"
|
||||
depends: [
|
||||
"dune" {>= "2.9"}
|
||||
"ocaml" {>= "4.08"}
|
||||
"odoc" {with-doc}
|
||||
]
|
||||
build: [
|
||||
["dune" "subst"] {dev}
|
||||
[
|
||||
"dune"
|
||||
"build"
|
||||
"-p"
|
||||
name
|
||||
"-j"
|
||||
jobs
|
||||
"--promote-install-files=false"
|
||||
"@install"
|
||||
"@runtest" {with-test}
|
||||
"@doc" {with-doc}
|
||||
]
|
||||
["dune" "install" "-p" name "--create-install-files" name]
|
||||
]
|
||||
dev-repo: "TODO/leaflet"
|
7
src/dune
Normal file
7
src/dune
Normal file
@ -0,0 +1,7 @@
|
||||
(library
|
||||
(name leaflet)
|
||||
(public_name leaflet)
|
||||
(modules leaflet)
|
||||
(libraries brr js_of_ocaml)
|
||||
(js_of_ocaml
|
||||
(javascript_files leaflet.js)))
|
6
src/leaflet.js
Normal file
6
src/leaflet.js
Normal file
File diff suppressed because one or more lines are too long
3
src/leaflet.js.license
Normal file
3
src/leaflet.js.license
Normal file
@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2010-2021 Vladimir Agafonkin
|
||||
|
||||
SPDX-License-Identifier: BSD-2-Clause
|
83
src/leaflet.ml
Normal file
83
src/leaflet.ml
Normal file
@ -0,0 +1,83 @@
|
||||
(*
|
||||
* SPDX-FileCopyrightText: 2021 pukkamustard <pukkamustard@posteo.net>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*)
|
||||
open Brr
|
||||
|
||||
let leaflet =
|
||||
match Jv.(find global "L") with
|
||||
| Some l -> l
|
||||
| None -> failwith "Could not load Leaflet"
|
||||
|
||||
module LatLng = struct
|
||||
type t = Jv.t
|
||||
|
||||
let create lat lng =
|
||||
Jv.call leaflet "latLng" [| Jv.of_float lat; Jv.of_float lng |]
|
||||
|
||||
let lat latlng = Jv.get latlng "lat" |> Jv.to_float
|
||||
let lng latlng = Jv.get latlng "lng" |> Jv.to_float
|
||||
end
|
||||
|
||||
module Ev = struct
|
||||
module MouseEvent = struct
|
||||
type t = Jv.t
|
||||
|
||||
let latlng e = Jv.get e "latlng"
|
||||
end
|
||||
end
|
||||
|
||||
module Map = struct
|
||||
type t = Jv.t
|
||||
|
||||
let create ?(options = Jv.null) el =
|
||||
Jv.call leaflet "map" [| El.to_jv el; options |]
|
||||
|
||||
let invalidate_size map =
|
||||
ignore @@ Jv.call map "invalidateSize" [| Jv.true' |]
|
||||
|
||||
let fit_world map = ignore @@ Jv.call map "fitWorld" [||]
|
||||
let get_container map = Jv.call map "getContainer" [||] |> El.of_jv
|
||||
|
||||
let set_view latlng ~zoom map =
|
||||
ignore @@ Jv.call map "setView" [| latlng; Jv.of_int zoom |];
|
||||
map
|
||||
|
||||
let as_target map = Brr.Ev.target_of_jv map
|
||||
let click = Brr.Ev.Type.create (Jstr.v "click")
|
||||
end
|
||||
|
||||
module TileLayer = struct
|
||||
type t = Jv.t
|
||||
|
||||
let create_osm () =
|
||||
Jv.call leaflet "tileLayer"
|
||||
[|
|
||||
Jv.of_string "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
|
||||
Jv.obj
|
||||
[|
|
||||
( "attribution",
|
||||
Jv.of_string
|
||||
"© <a \
|
||||
href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> \
|
||||
contributors" );
|
||||
|];
|
||||
|]
|
||||
|
||||
let add_to tile_layer map = ignore @@ Jv.call tile_layer "addTo" [| map |]
|
||||
end
|
||||
|
||||
module Marker = struct
|
||||
type t = Jv.t
|
||||
|
||||
let create latlng = Jv.call leaflet "marker" [| latlng |]
|
||||
let add_to marker map = ignore @@ Jv.call marker "addTo" [| map |]
|
||||
|
||||
let bind_popup el marker =
|
||||
ignore @@ Jv.call marker "bindPopup" [| El.to_jv el |];
|
||||
marker
|
||||
|
||||
let open_popup marker = ignore @@ Jv.call marker "openPopup" [||]
|
||||
end
|
||||
|
67
src/leaflet.mli
Normal file
67
src/leaflet.mli
Normal file
@ -0,0 +1,67 @@
|
||||
(*
|
||||
* SPDX-FileCopyrightText: 2021 pukkamustard <pukkamustard@posteo.net>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*)
|
||||
|
||||
open Brr
|
||||
(** {1 Leaflet}
|
||||
|
||||
This module provides bindings to the Leaflet JavaScript library for
|
||||
mobile-friendly interactive maps.
|
||||
|
||||
See also the [Leaflet API reference](https://leafletjs.com/reference.html).
|
||||
*)
|
||||
|
||||
module LatLng : sig
|
||||
type t
|
||||
|
||||
val create : float -> float -> t
|
||||
val lat : t -> float
|
||||
val lng : t -> float
|
||||
end
|
||||
|
||||
module Ev : sig
|
||||
module MouseEvent : sig
|
||||
type t
|
||||
|
||||
val latlng : t -> LatLng.t
|
||||
end
|
||||
end
|
||||
|
||||
module Map : sig
|
||||
type t
|
||||
|
||||
val create : ?options:Jv.t -> El.t -> t
|
||||
val invalidate_size : t -> unit
|
||||
val set_view : LatLng.t -> zoom:int -> t -> t
|
||||
val fit_world : t -> unit
|
||||
val get_container : t -> El.t
|
||||
|
||||
(** {1 Events} **)
|
||||
|
||||
val as_target : t -> Brr.Ev.target
|
||||
|
||||
(** {2 Interaction events} **)
|
||||
|
||||
val click : Ev.MouseEvent.t Brr.Ev.type'
|
||||
end
|
||||
|
||||
module TileLayer : sig
|
||||
type t
|
||||
|
||||
val create_osm : unit -> t
|
||||
val add_to : t -> Map.t -> unit
|
||||
end
|
||||
|
||||
module Marker : sig
|
||||
type t
|
||||
|
||||
val create : LatLng.t -> t
|
||||
val add_to : t -> Map.t -> unit
|
||||
|
||||
(** {2 Popup methods} *)
|
||||
|
||||
val bind_popup : El.t -> t -> t
|
||||
val open_popup : t -> unit
|
||||
end
|
1
test/test.ml
Normal file
1
test/test.ml
Normal file
@ -0,0 +1 @@
|
||||
let () = assert true (* TODO *)
|
Loading…
x
Reference in New Issue
Block a user