Javascript 映射框标记不考虑zindex
在我正在构建的mapbox应用程序中,我根据用户的地理位置将多个标记加载到页面上,问题是虽然我需要某些标记高于其他标记,但这些标记不符合我设置的Javascript 映射框标记不考虑zindex,javascript,geolocation,mapbox,markers,Javascript,Geolocation,Mapbox,Markers,在我正在构建的mapbox应用程序中,我根据用户的地理位置将多个标记加载到页面上,问题是虽然我需要某些标记高于其他标记,但这些标记不符合我设置的zIndex。这是我的密码 function addMarker(type, radius, height, lat, long, id, special, name) { var circle_options; switch (type) { case marker.RESTRICTED: cir
zIndex
。这是我的密码
function addMarker(type, radius, height, lat, long, id, special, name) {
var circle_options;
switch (type) {
case marker.RESTRICTED:
circle_options = {
color: '#D90000',
fillColor: '#D90000', // Fill color
fillOpacity: 0.4, // Fill opacity
stroke: false,
zIndexOffSet: -1
};
break;
case marker.NOT_RECOMMENDED:
circle_options = {
color: '#FF8000',
fillColor: '#FF8000', // Fill color
fillOpacity: 0.75, // Fill opacity
stroke: false,
zIndexOffSet: 1000
};
break;
case marker.USER_RECOMMENDED:
circle_options = {
color: '#9FCC1C',
fillColor: '#9FCC1C', // Fill color
fillOpacity: 0.75, // Fill opacity
stroke: false,
zIndexOffSet: 1000
};
break;
case marker.APPROVED:
circle_options = {
color: '#006ADC',
fillColor: '#006ADC', // Fill color
fillOpacity: 0.75,
stroke: false,
zIndexOffSet: 1000
};
break;
}
var mark = L.circle([
lat, long
], radius * 1609.34, circle_options);
if (nav.currentPage() == 'location-details') {
if (mapElement) {
mapElement.setView([lat, long], zoomMap[radius])
mapElement.removeLayer(use);
mapElement.removeLayer(ic);
}
}
else if (nav.currentPage() == 'home') {
mark.objectId = id;
circles.push(mark);
}
mark.on('click', function (e) {
var self = id;
circles.some(function (item) {
if (self == item.objectId) {
nav.navigate('location-details', false, item.objectId);
return true;
}
});
})
mark.addTo(mapElement)
}
看起来没有
zIndexOffSet
选项,您可以作为最后一个参数传递给L.Circle()
尽管有一个
className
选项,您可以使用该选项为标记指定具有不同预设z索引的自定义类。为什么不按您希望的顺序添加标记呢?Mapbox extends中没有z-index的功能,因此您可以使用bringToFront()
和bringToBack()
方法。但是它不允许您精确地控制z索引,请参见。文森特对顺序的看法是正确的:看,你能为它做一个简单的定义吗?你使用的是定位元素吗?