My goal is to have my markers standing like pillars at 90 degrees to the Mapbox map.
Like this:
I got this from .gl
Currently I have this code to add a Marker but it doesn't work.
const customMarker = document.createElement("div");
const backGroundColor = theme == "dark" ? "bg-white/90" : "bg-black/90";
customMarker.className = "w-2 h-20 rounded-full" + " " + backGroundColor;
if (!device.location?.longitude || !device.location?.latitude) return;
new mapboxgl.Marker({
element: customMarker,
pitchAlignment: "map",
rotationAlignment: "map"
})
.setLngLat([device.location?.longitude, device.location?.latitude] as [
number,
number
])
.setRotation(45)
.addTo(mapRef.current!);
This renders the markers like this:
My goal is to have my markers standing like pillars at 90 degrees to the Mapbox map.
Like this:
I got this from https://github/vasturiano/globe.gl
Currently I have this code to add a Marker but it doesn't work.
const customMarker = document.createElement("div");
const backGroundColor = theme == "dark" ? "bg-white/90" : "bg-black/90";
customMarker.className = "w-2 h-20 rounded-full" + " " + backGroundColor;
if (!device.location?.longitude || !device.location?.latitude) return;
new mapboxgl.Marker({
element: customMarker,
pitchAlignment: "map",
rotationAlignment: "map"
})
.setLngLat([device.location?.longitude, device.location?.latitude] as [
number,
number
])
.setRotation(45)
.addTo(mapRef.current!);
This renders the markers like this:
Share Improve this question asked Mar 14 at 16:01 SchickliSchickli 331 silver badge6 bronze badges1 Answer
Reset to default 0Setting the rotationAlignment property to "horizon" should give you the expected result. Orient markers toward the horizon.