[英]Adding a fixed square in Mapbox gl?
I know it is possible to add lines, points or polygons by adding a geojson source in Mapbox gl, these would be located on the map through coordinates. 我知道可以通过在Mapbox gl中添加geojson源来添加线,点或多边形,它们可以通过坐标位于地图上。 However, what I am trying to do is adding a simple polygon that would be fixed on the canvas, and would remain at the same position of the canvas - not the globe - even if the user pans or zooms.
但是,我正在尝试添加一个简单的多边形,该多边形将固定在画布上,并且即使用户平移或缩放,也将保持在画布的相同位置(而不是地球)。
(Note that I am aware that this could be achieved by resetting the data of the initial geojson on zoom/pan, but the figure would then glitch). (请注意,我知道可以通过在zoom / pan上重置初始geojson的数据来实现,但是该数字会出现故障)。
I would appreciate any idea, thanks. 我将不胜感激,谢谢。
If you just want a box that doesn't move why draw in WebGL? 如果您只想要一个不会移动的盒子,为什么要使用WebGL? Just make a div and position with with CSS?
只是使用CSS进行div定位?
The example on this page has 2 div based rectangles. 本页上的示例有2个基于div的矩形。 One says " US population density " and the other is the legend.
一个说“ 美国人口密度 ”,另一个说是传说。
If the mouse is over them they block scrolling. 如果鼠标悬停在它们上方,它们将阻止滚动。
If I right click on one and pick "inspect" I see it has a "map-overlay" CSS class. 如果我右键单击一个并选择“检查”,我会看到它具有“地图覆盖” CSS类。 If I add
pointer-events: none
to it suddenly I can scroll 如果我添加
pointer-events: none
突然pointer-events: none
,我可以滚动
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.