Hi, I'm trying to change the colour of the marker shown on my mapbox map based on a property value
eg
type = 1, color = blue
type =2, color = red
Tried to use the GeoJson Layer styling but not sure where to start
I believe the default map location marker/icon may not be able to change colours but I'm happy to use an 'X' from the Marker field if cna just change its font color.
Without the styling you won't see any points on the map.
The color_val property of the marker will define the colour.
However with this method the interactions with the markers won't trigger events.
It is a bit of a hack and Retool is working on adding a better integration.
Many thanks for the details here - it does work!. Not being able to interact with the markers though to trigger events is a deal breaker for this app though, so will have to find a workaround for that too. Cheers
That will be a bridge too far for a hack like me, and anyway really wanting ReTool to be a low-code solution for our needs here, which apart from this little hiccup I've been very impressed with.
Hoping the Retool team do add the ability for marker customisation based on a property, keeping the interactivity of course.
Thanks for engaging. cheers
Hi @MarkMcP, this feature is often requested but currently in our backlog! I bumped it for you but can't give any timeline. I agree with Filippo that a custom component would be the way to go otherwise.
Thanks. Will keep a look out. I'm actually trying to put together something just like this for intneral use. The way their Mapbox works is just what I'm chasing
I saw your post and wanted to share something that might help!
I recently built a custom Retool component for a client that sounds pretty similar to what youβre looking for, so I decided to open source it in case itβs useful to others too.
Quick demo:
GitHub repo:
Installation instructions:
Youβll find everything in the README:
Feel free to fork it, suggest improvements, or reach out if you have questions! Hope it helps.
You're working on a car tracker map in Pakistan using Mapbox and want to change the marker color based on the vehicle type (e.g., type 1 = blue, type 2 = red), you can achieve this easily with a custom GeoJSON layer. Instead of using the default Mapbox marker, which has limited styling options, use a custom HTML marker (like an 'X' or icon) and style it using CSS. When you create each marker, check the type property in your GeoJSON data and assign a corresponding color using inline styles or class names. This way, you can clearly differentiate vehicle types visually on the map without relying on the default icons.
Yes using GeoJSON layer will display different colours, but the markers are then no longer interactive, so cannt click on them to display popups or filtered tables etc.