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

Add a rectangular marker with text overlay #7165

Closed
megelismi opened this issue Aug 22, 2018 · 3 comments
Closed

Add a rectangular marker with text overlay #7165

megelismi opened this issue Aug 22, 2018 · 3 comments

Comments

@megelismi
Copy link

megelismi commented Aug 22, 2018

mapbox-gl-js version: 0.46

Question

I'm trying to figure out how to add a rectangular marker that contains some dynamic data, in this case a housing price. I'm trying to achieve this using layers instead of a custom Marker. The reason is that I need to display a popup on hover, and as far as I can tell, Markers only display a popup on click.

I need the price tag to look something like this: https://i.stack.imgur.com/7wl5O.png

I've combed through the documentation and Google, but I have not found an answer. Please help.

Links to related documentation

https://www.mapbox.com/mapbox-gl-js/example/data-driven-circle-colors/
https://www.mapbox.com/mapbox-gl-js/example/data-driven-lines/
https://www.mapbox.com/mapbox-gl-js/example/display-and-style-rich-text-labels/

@ashleyclough
Copy link

You can use a symbol layer:
https://www.mapbox.com/mapbox-gl-js/style-spec#layers-symbol

Create an svg graphic of your marker for the icon-image and add the data driven text for the text-field.

@ryanhamley
Copy link
Contributor

You can see an example of creating custom Markers here. The Marker class also exposes a togglePopup method which you can use in a hover listener to open and close the attached popup.

@andrewharvey
Copy link
Collaborator

also #6856

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

4 participants