admin管理员组文章数量:1389757
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.
本文标签: reactjsMapbox Custom Marker as a quotPillarquot on the MapStack Overflow
版权声明:本文标题:reactjs - Mapbox Custom Marker as a "Pillar" on the Map - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744644488a2617316.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论