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

Markers cannot have HTML content as child #100

Closed
Haapavuo opened this issue Aug 31, 2023 · 2 comments
Closed

Markers cannot have HTML content as child #100

Haapavuo opened this issue Aug 31, 2023 · 2 comments

Comments

@Haapavuo
Copy link

Haapavuo commented Aug 31, 2023

If you insert HTML content, e.g. a <p> element within a Marker, you will only get [object HTMLParagraphElement] instead of the HTML content. I haven't found any workaround to this. A custom component doesn't work either inside a Marker. Only text content seems to work.

          <Show when={locs()}>
            <For each={locs()}>{(loc, i) => 
              <Marker lngLat={loc.geometry?.coordinates} options={{ color: 'red' }}>
                <p>{loc.properties.osm_tags?.name}</p>
              </Marker>
            }</For>
          </Show>

The above example renders [object HTMLParagraphElement] to the Markers.

Any ideas? Thanks.

@Haapavuo
Copy link
Author

Workaround that actually works until the Marker component gets fixed:

let m = new maplibregl.Marker({color: 'yellow'});
    m.setPopup(new maplibregl.Popup().setHTML("<h1>Hello World!</h1>"));
    m.setLngLat(markerLoc).addTo(mapContext.map);

@KaiHuebner
Copy link
Contributor

Thanks for reporting this issue. Fixed in the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants