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

map constructor with object as property #15

Open
ttdonovan opened this issue Mar 11, 2022 · 0 comments
Open

map constructor with object as property #15

ttdonovan opened this issue Mar 11, 2022 · 0 comments
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@ttdonovan
Copy link

ttdonovan commented Mar 11, 2022

This may not specifically be an issue with leaflet-rs and more of a wasm_bindgen question but looking for suggestions how to approach this. Thanks in advanced.

Example of the JS constructor that I am wanting.

const map = L.map("map", {
  crs: L.CRS.Simple,
  minZoom: -3,
  maxBoundsViscosity: 1.0,
});

What to do in Rust or how to add L.CRS to the bindings?

#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct MapOptions {
    // crs: ???, // this is JS object... L.CRS.Simple
    min_zoom: i32,
    max_bounds_viscosity: f64,
}

...

let options = JsValue::from_serde(&MapOptions {
    // crs: "L.CRS.Simple".to_string(), // how to make this a serializable JS Object...
    min_zoom: -3,
    max_bounds_viscosity: 1.0,
}).expect("Unable to serialize map options");

let map = Map::new("map", &options);

My goal is to add a game map and here is my feeble attempt...

master...ttdonovan:image-overlay

@flosse flosse added help wanted Extra attention is needed question Further information is requested labels Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants