leaflet-rs
leaflet-rs copied to clipboard
map constructor with object as property
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...
https://github.com/slowtec/leaflet-rs/compare/master...ttdonovan:image-overlay