Skip to main content

leaflet/shapes/
path.rs

1use js_sys::Object;
2use wasm_bindgen::prelude::*;
3
4use crate::{Layer, LayerOptions, create_object_with_properties};
5
6#[wasm_bindgen]
7extern "C" {
8    /// [`Path`](https://leafletjs.com/reference.html#path)
9    #[wasm_bindgen(extends = Layer)]
10    #[derive(Debug, Clone)]
11    pub type Path;
12
13    /// [`redraw`](https://leafletjs.com/reference.html#path-redraw)
14    #[wasm_bindgen(method)]
15    pub fn redraw(this: &Path);
16
17    /// [`setStyle`](https://leafletjs.com/reference.html#path-setstyle)
18    #[wasm_bindgen(method, js_name = setStyle)]
19    pub fn set_style(this: &Path, path_options: &PathOptions);
20
21    /// [`bringToFront`](https://leafletjs.com/reference.html#path-bringtofront)
22    #[wasm_bindgen(method, js_name = bringToFront)]
23    pub fn bring_to_front(this: &Path);
24
25    /// [`bringToBack`](https://leafletjs.com/reference.html#path-bringtoback)
26    #[wasm_bindgen(method, js_name = bringToBack)]
27    pub fn bring_to_back(this: &Path);
28}
29
30create_object_with_properties!(
31    (PathOptions, PathOptions, LayerOptions),
32    (stroke, stroke, bool),
33    (color, color, String),
34    (weight, weight, f64),
35    (interactive, interactive, bool),
36    (opacity, opacity, f64),
37    (line_cap, lineCap, String),
38    (line_join, lineJoin, String),
39    (dash_array, dashArray, String),
40    (dash_offset, dashOffset, String),
41    (fill, fill, bool),
42    (fill_color, fillColor, String),
43    (fill_opacity, fillOpacity, f64),
44    (fill_rule, fillRule, String),
45    (bubbling_mouse_events, bubblingMouseEvents, bool),
46    (renderer, renderer, JsValue),
47    (class_name, className, String)
48);
49
50impl Default for PathOptions {
51    fn default() -> Self {
52        PathOptions::new()
53    }
54}