On my Mapbox have 3 layers.
id: 'Map'
, id:'Cluster'
, id: 'Point'
map.on('click', 'Point', function (e) {
$(".page-wrapper").addClass("toggled");/*show sidebar*/
});
This code mean when I click point on layer id: 'Point'
, sidebar will show.
$(".page-wrapper").removeClass("toggled");/*hide sidebar*/
And this code will hide sidebar when add to event.
Now, I want click any where without point on layer id: 'Point'
sidebar will hidden.
How can I do that?
On my Mapbox have 3 layers.
id: 'Map'
, id:'Cluster'
, id: 'Point'
map.on('click', 'Point', function (e) {
$(".page-wrapper").addClass("toggled");/*show sidebar*/
});
This code mean when I click point on layer id: 'Point'
, sidebar will show.
$(".page-wrapper").removeClass("toggled");/*hide sidebar*/
And this code will hide sidebar when add to event.
Now, I want click any where without point on layer id: 'Point'
sidebar will hidden.
How can I do that?
Share Improve this question asked Jan 26, 2019 at 8:26 AlexAlex 8271 gold badge15 silver badges39 bronze badges1 Answer
Reset to default 10Use the click event handler for the entire map and the preventDefault
function:
map.on('click', 'point', function(e) {
e.preventDefault();
console.log('show sidebar');
});
map.on('click', function(e) {
if (e.defaultPrevented === false) {
console.log('hide taskbar');
}
});
[ https://jsfiddle/7mfb59qo/2/ ]
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744316348a4568203.html
评论列表(0条)