I'd like to have exact-sized icons on my map, where each icon takes up a predefined size in meters on the map. Additionally, these need to be changed at runtime, so generating an image ahead of time that covers the whole map is a no-go. My use case is displaying to-be-painted pavement markings, so a 3 meter square is probably the largest thing displayed. Matching the rotation and pitch is easily done with setting icon-rotation-alignment
to map
, leaving the issue of size. I could scale the icon-size
by interpolate
-ing the zoom factor ( ['interpolate', ['exponential', 2], ['zoom'], 15, 1 / 72, 22, 1 / 0.56]
), but I would then run into problems with the difference in latitudes with the Mercator projection . It would probably be possible, though, to interpolate based on both the zoom and current latitude.
Alternatively, some demos that look to be doing similar tasks of aligning real-world sizes are Add a 3D model , Add a canvas source , Add a custom style layer (although I don't think I need that), and Add an image . My understanding of how I would use each:
Which of these would be the best option?
You can do that easily with a raster layer in mapbox but you'll need to do on your side the calculations of the length in meters for the 4 corners of the image using a conversion that considers latitude.
Other option if you want to add an image in exact meters size (considering the latitude), just check this out made with the latest version of threebox
You'll be able to load any image (and any 3D model) and define its size in meters (millimeters indeed) with only a few lines of code, but using a threejs plug-in for a pure 2D task is probably like shooting fish in a barrel.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.