Skip to content

Custom Marker Overlaid by Default Pin in MaplibreGL JS Versions After 3.1.0 #3925

Answered by r-follador
r-follador asked this question in Q&A
Discussion options

You must be logged in to vote

My bad, the example in "Add custom icons with Markers" actually works.
I need to pass the created <div> as an element in the constructor:

let el = document.createElement('div');
el.className = 'marker2d';
let marker = new maplibregl.Marker({element: el})
  		.setLngLat([12.4822, 41.8967])
  		.addTo(map);

See https://jsbin.com/danusugeqo/edit?html,output

Thanks for your help!! The other observation still stands, using addClassName keeps the default pin visible. I don't know if this is intended behaviour or not.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@r-follador
Comment options

@r-follador
Comment options

Answer selected by r-follador
@HarelM
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3924 on April 01, 2024 05:40.