Comments (6)
Hi @shimatar0!
Oh, It seems my prior implementation for MarkerOptions
is pretty much incomplete! This issue shouldn't have "good first issue" label π
Can you please try if this implementation works?
impl MarkerOptions {
pub fn build(mut self) -> JsValue {
let obj: js_sys::Object = serde_wasm_bindgen::to_value(&self).unwrap().into();
if let Some(element) = self.element.take() {
js_sys::Object::define_property(&obj, &JsValue::from_str("element"), &*element).into()
} else {
obj.into()
}
}
}
from mapbox-gl-rs.
Yes, element
needs to have #[serde(skip)]
, because it's not serializable. My implementation serializes MarkerOptions
without element
into JsValue
first. Then it appends element
property of HtmlElement
into the JsValue. Hope this will work.
from mapbox-gl-rs.
@yukinarit
Sorry. It took me a while to checkπ
I understand, but there still seemed to be a problem, so I put out a PR for WIP and commented!
from mapbox-gl-rs.
@yukinarit
Hi! In addressing this issue, found some concerns.
Perhaps this requires creating an HttpElement to customize the MakerOption structure,
but the HttpElement is likely to skip serialization.
https://github.com/yukinarit/mapbox-gl-rs/blob/main/src/marker.rs#L15-L16
I think that HttpElement may be a bit difficult to deal with as it does not seem to have a serialize/deserialize trait
π€
I can't really think of a better ideaπ
from mapbox-gl-rs.
@yukinarit
Thanks!
I feel that this would allow the structure members themselves to be serialized when passing through the build method.
However, I think the following structure definitions may be the bottleneck.(HtmlElement
)
e.g.
MarkerOptions
https://github.com/yukinarit/mapbox-gl-rs/blob/main/src/marker.rs#L15-L16
...
// todo keep serialization from skipping.
#[serde(skip_serializing_if = "Option::is_none")]
pub element: Option<web_sys::HtmlElement>,
...
Is this error likely?
the trait bound `HtmlElement: Serialize` is not satisfied
the following other types implement trait `Serialize`:
from mapbox-gl-rs.
Done in #42
from mapbox-gl-rs.
Related Issues (20)
- Update examples to use Yew v0.20
- Support VideoSource
- Heatmaps HOT 1
- Support Map's Image APIs
- Host examples in gh-pages
- Add an example of map's style HOT 1
- Support Map#addControl and NavigationControl
- Support FullscreenControl
- Support GeolocateControl
- Support ScaleControl
- Support AttributionControl
- Add example of draggable marker HOT 3
- Add example of sauron
- Add example of seed
- Add example of NavigationControl
- MapLibre support?
- Support Marker events HOT 3
- Support layerIds for Map events
- Support Map#queryRenderedFeatures
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapbox-gl-rs.