- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 mapbox-gl-js 制作了一张 map ,并添加了 parking 场图层,单击该图层后,会打开一个带有方向的弹出窗口。然后我在 parking 场层的顶部放置了一些可点击的标记(用于公交车站、无障碍 parking 场等)。当我单击 parking 场上的标记时, parking 场弹出窗口和标记弹出窗口都会弹出。如果有标记弹出窗口,如何防止多边形层触发弹出窗口?我不想同时显示两个弹出窗口。
相关代码如下:
// Add a layer showing the parking lots
map.addLayer({
"id": "parking-layer",
"type": "fill",
"source": "parking-buttons",
"layout": {},
"paint": {
"fill-color": "hsla(0, 0%, 0%, 0)",
"fill-outline-color": "hsla(0, 0%, 0%, 0)"
}
});
// Add a layer showing the bus stop
map.addLayer({
"id": "bus",
"type": "symbol",
"source": "bus",
"layout": {
"icon-image": "{icon}-11",
"icon-allow-overlap": true
},
"paint": {
"icon-opacity": {"stops": [[15.49, 0], [15.5, 1]]}
}
});
// When a click event occurs for a polygon, open a popup with details
map.on('click', function (e) {
var features = map.queryRenderedFeatures(e.point, { layers: ['parking-layer', 'buildings-layer'] });
if (!features.length) {
return;
}
var feature = features[0];
// Populate the popup and set its coordinates
var popup = new mapboxgl.Popup()
.setLngLat(map.unproject(e.point))
.setHTML(feature.properties.description)
.addTo(map);
});
// When a click event occurs for a node, open a popup with details
map.on('click', function (e) {
var features = map.queryRenderedFeatures(e.point, { layers: ['bus', 'ephone'] });
if (!features.length) {
return;
}
var feature = features[0];
// Populate the popup and set its coordinates
var popup = new mapboxgl.Popup()
.setLngLat(feature.geometry.coordinates)
.setHTML(feature.properties.description)
.addTo(map);
});
最佳答案
您在 click
事件上注册了两个单独的处理程序,如果存在重叠的功能,这两个处理程序最终都会显示一个弹出窗口。
我会尝试在一个 click
处理程序中处理不同的结果,而不是 2 个:
// When a click event occurs for a polygon, open a popup with details
map.on('click', function (e) {
var pointFeatures = map.queryRenderedFeatures(e.point, { layers: ['bus', 'ephone'] });
if (pointFeatures.length > 0) {
var feature = pointFeatures[0];
// Populate the popup and set its coordinates
var popup = new mapboxgl.Popup()
.setLngLat(feature.geometry.coordinates)
.setHTML(feature.properties.description)
.addTo(map);
return; // don't display any more pop ups
}
var polygonFeatures = map.queryRenderedFeatures(e.point, { layers: ['parking-layer', 'buildings-layer'] });
if (!polygonFeatures.length) {
return;
}
var feature = polygonFeatures [0];
// Populate the popup and set its coordinates
var popup = new mapboxgl.Popup()
.setLngLat(map.unproject(e.point))
.setHTML(feature.properties.description)
.addTo(map);
});
关于javascript - 如何在 Mapbox GL JS 中的可点击多边形顶部放置可点击标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38903057/
我已经实现了 Bentley-Ottmann-algorithm检测多边形-多边形交叉点。这通常非常有效:由于多边形不自相交,因此两个多边形的线段并集中的任何线段相交表明两个多边形相交。 但是如果我看
我在 Silverlight 中有一个多边形(棋盘游戏的十六进制),例如; public class GridHex : IGridShape { ..... public IList
我创建了一个简单的 DirectX 应用程序来渲染一个顶点场。顶点呈现如下(如果从顶部查看): |\|\|\|\| |\|\|\|\| 每个三角形都是这样渲染的: 1 |\ 2 3 这应该意味着多边形
我的代码的某些部分here : var stage = new Kinetic.Stage({ container: "canvas", width: 300,
我正在尝试从 map 数据构造导航网格物体。步骤之一涉及将二进制图像(其中0表示占用空间,1表示自由空间)转换成平面直线图。 我正在尝试找到一种可靠的方法。我目前的想法是使用Canny边缘检测器,然后
我的任务是编写 MATLAB 代码来生成一个由 4 部分组成的 Logo ,如屏幕截图所示。左上角应为黑色,右下角应为白色。另一个程序应随机选择两种颜色。 我采取了以下方法: clear all cl
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
如何向 google.maps.Rectangle 和 google.maps.Polygon 添加标题? title 属性在 RectangleOptions 中不可用.我试过了,但没用(对于 go
我有一个表,用于将表上的段存储为多边形。然后我想获取所有被另一个多边形接触的线段,例如正方形或圆形。图片上:http://img.acianetmedia.com/GJ3 我将灰色小框表示为段和 bi
我正在我的网站上使用 CSS 来制作形状。它在 chrome 中运行良好,但在 mozilla、internet explorer 中打开时,它无法运行。 有人知道怎么解决吗? 这是 fiddle h
我使用 DrawingManager 在 Google map 上绘制圆形和多边形。我尝试使用下面的代码删除圆形/多边形。 selectedShape.setMap(null); 这里selected
我看到了很多如何检测碰撞的教程,但没有看到如何解决它。我正在制作一个自上而下的游戏,玩家具有圆形碰撞形状,而墙壁是各种多边形。 我正在使用 slick2d。我应该做的是,如果玩家与角落碰撞,我会按法线
我对 tkinter 比较陌生,我正在制作一个只使用正方形的游戏。我正在抄写的书只显示三角形。这是代码: # The tkinter launcher (Already complete) from
我在 OpenCV/Python 中工作,我遇到了这个问题。我已经使用 cv2.minAreaRect() 来获取围绕一组点的边界框。是否有任何其他函数/通用算法可以给我内接多边形(点集)的最大矩形?
如果给定一组线段 S ,我们能否设计一种算法来测试集合 S 中的线段是否可以形成多边形,我对它们是否相交多边形不感兴趣,我只想知道我可以测试什么标准, 任何建议 最佳答案 构建一个图形数据结构,其中节
如何从多个地理位置(经度、纬度值)创建多边形地理围栏。此外,如何在 Android 上跟踪用户进入此地理围栏区域或从该区域退出。 最佳答案 地理围栏只是一组形成多边形的纬度/经度点。获得纬度/经度点列
我想要一个 complex image like this在我的申请中。我想让用户点击复杂的多边形(在这种情况下是有边界的国家/地区)并突出显示他们点击的多边形。我有我需要用于该状态的图像。 我怎样才
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我想在 python tkinter 中移动对象,特别是多边形。问题出在 is_click 函数中。我似乎无法弄清楚如何确定我是否单击了该对象。代码还没有 100% 完成,移动仍然需要完成,但我现在需
我有一个大多边形,我想找到与该多边形相交的要素,但由于多边形太大,我遇到超时异常。 我试图研究 JTS 方法,但不知道如何使用它。 final List coordinates = List.of(n
我是一名优秀的程序员,十分优秀!