Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added control/layers #34

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/control.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mod layers;
mod zoom;

use crate::{create_object_with_properties, Map};
use js_sys::Object;
use wasm_bindgen::prelude::*;
use web_sys::HtmlElement;

pub use layers::LayersControl;
pub use zoom::{Zoom, ZoomOptions};

#[wasm_bindgen]
Expand Down
20 changes: 20 additions & 0 deletions src/control/layers.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use super::Control;
use js_sys::Object;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
#[derive(Debug, Clone)]
#[wasm_bindgen(extends = Control, js_namespace = ["L", "Control"])]
pub type LayersControl;

#[wasm_bindgen(js_namespace = ["L", "control"], js_name = "layers")]
fn constructor_layers(options: &Object) -> LayersControl;
}

impl LayersControl {
#[must_use]
pub fn new(options: &Object) -> Self {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about this?

Suggested change
pub fn new(options: &Object) -> Self {
pub fn new(options: &std::collections::HashMap<String, Layer>) -> Self {

constructor_layers(options)
}
Copy link
Author

@legokichi legokichi Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo

Suggested change
}
}
pub fn new_with_options(&Object, options: &LayersControlOptions) -> Self {
...
}

}
12 changes: 0 additions & 12 deletions src/layer_control.rs
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this file is not necessary

This file was deleted.

3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ mod icon;
mod lat_lng;
mod lat_lng_bounds;
mod layer;
mod layer_control;
mod layer_group;
mod map;
mod marker;
Expand All @@ -26,7 +25,7 @@ mod util;
use js_sys::Array;
use paste::paste;

pub use control::{Control, ControlOptions, Zoom, ZoomOptions};
pub use control::{Control, ControlOptions, LayersControl, Zoom, ZoomOptions};
pub use crs::Crs;
pub use div_icon::{DivIcon, DivIconOptions};
pub use div_overlay::DivOverlay;
Expand Down