leptos_leaflet/lib.rs
1//! # leptos-leaflet
2//!
3//! This crate provides a set of components and utilities to work with the Leaflet library in Leptos.
4//!
5//! ## Components
6//!
7//! - [`MapContainer`](crate::MapContainer): A container for the Leaflet map. Where all the other components are added.
8//! - [`Circle`](crate::Circle): A circle overlay that represents a circle on the map.
9//! - [`Control`](crate::Control): A control that represents a control on the map.
10//! - [`ImageOverlay`](crate::ImageOverlay): An image overlay that represents an image on the map.
11//! - [`Marker`](crate::Marker): A marker overlay that represents a marker on the map.
12//! - [`Polygon`](crate::Polygon): A polygon overlay that represents a polygon on the map.
13//! - [`Polyline`](crate::Polyline): A polyline overlay that represents a polyline on the map.
14//! - [`Popup`](crate::Popup): A popup overlay that represents a popup on the map.
15//! - [`QuadTileLayer`](crate::QuadTileLayer): A tile layer that uses quadkey-based URLs instead of x/y/z coordinates.
16//! - [`TileLayer`](crate::TileLayer): A tile layer that represents a tile layer on the map.
17//! - [`TileLayerWms`](crate::TileLayerWms): A tile layer that represents a tile layer on the map.
18//! - [`Tooltip`](crate::Tooltip): A tooltip overlay that represents a tooltip on the map.
19//! - [`VideoOverlay`](crate::VideoOverlay): A video overlay that represents a video on the map.
20//! - [`Zoom`](crate::Zoom): A zoom control that represents a zoom control on the map.
21//!
22//! ## Utilities
23//!
24//! - [`IntoLatLng`](crate::IntoLatLng): A trait to convert types into `leaflet::LatLng` instances.
25//! - [`LeafletMapContext`](crate::LeafletMapContext): A context struct for the Leaflet map.
26//! - [`Position`](crate::Position): A struct to represent a position on the map.
27//!
28//! ## Example
29//!
30//! ```rust
31//! use std::time::Duration;
32//!
33//! use leptos::prelude::*;
34//! use leptos_leaflet::prelude::*;
35//!
36//! #[component]
37//! pub fn App() -> impl IntoView {
38//! let (marker_position, set_marker_position) = create_signal(Position::new(51.49, -0.08));
39//!
40//! create_effect(move |_| {
41//! set_interval_with_handle(
42//! move || {
43//! set_marker_position.update(|pos| {
44//! pos.lat += 0.001;
45//! pos.lng += 0.001;
46//! });
47//! },
48//! Duration::from_millis(200),
49//! )
50//! .ok()
51//! });
52//!
53//! view! {
54//! <MapContainer style="height: 400px" center=Position::new(51.505, -0.09) zoom=13.0 set_view=true>
55//! <TileLayer url="https://tile.openstreetmap.org/{z}/{x}/{y}.png" attribution="© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"/>
56//! <Marker position=marker_position >
57//! <Popup>
58//! <strong>{"A pretty CSS3 popup"}</strong>
59//! </Popup>
60//! </Marker>
61//! <Marker position=(51.5, -0.065) draggable=true >
62//! <Popup>
63//! <strong>{"A pretty CSS3 popup"}</strong>
64//! </Popup>
65//! </Marker>
66//! <Tooltip position=(51.5, -0.06) permanent=true direction="top">
67//! <strong>{"And a tooltip"}</strong>
68//! </Tooltip>
69//! <Polyline positions=positions(&[(51.505, -0.09), (51.51, -0.1), (51.51, -0.12)])/>
70//! <Polygon color="purple" positions=positions(&[ (51.515, -0.09), (51.52, -0.1), (51.52, -0.12)]) >
71//! <Tooltip sticky=true direction="top">
72//! <strong>{"I'm a polygon"}</strong>
73//! </Tooltip>
74//! </Polygon>
75//! <Circle center=(51.505, -0.09) color="blue" radius=200.0>
76//! <Tooltip sticky=true>{"I'm a circle"}</Tooltip>
77//! </Circle>
78//! </MapContainer>
79//! }
80//! }
81//! ```
82mod components;
83mod core;
84
85pub mod prelude {
86 pub use crate::position;
87 pub use crate::components::*;
88 pub use crate::core::*;
89}
90
91/// Leaflet re-exports
92pub use leaflet;
93
94use paste::paste;