Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map-feature StopPropagation experiment #118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions api/map-feature/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
document.querySelector('#blur').disabled = true;
document.querySelector('#zoom').disabled = true;
document.querySelector('#replace').disabled = true;
document.querySelector('#prevent').disabled = true;
document.querySelector('#remove').disabled = true;
} else {
document.querySelector('#add').disabled = true;
Expand All @@ -63,6 +64,7 @@
document.querySelector('#blur').disabled = false;
document.querySelector('#zoom').disabled = false;
document.querySelector('#replace').disabled = false;
document.querySelector('#prevent').disabled = false;
document.querySelector('#remove').disabled = false;
}
}
Expand Down Expand Up @@ -102,6 +104,15 @@
document.querySelector('map-feature').remove();
toggleDisabled();
}
function addStopPropagationMan() {
let man = document.querySelector('map-feature');
man.addEventListener("click", (e) => {
// Stops Default click action
e.originalEvent.stopPropagation();
// handle the click button yourself here
// ...
});
}
</script>
<template id="projection">
<map-meta name="projection" content="OSMTILE"></map-meta>
Expand Down Expand Up @@ -153,6 +164,7 @@
<button id="click" disabled onclick="_doMan('click')">Click feature</button>
<button id="zoom" disabled onclick="_doMan('zoomTo')">Zoom to feature</button>
<button id="replace" disabled onclick="_doMan('addCustomClickHandlerTo')">Replace default click handler</button>
<button id="prevent" disabled onclick="_doMan('addStopPropagation')">Stop default click action</button>
<button id="remove" disabled onclick="_doMan('remove')">Remove feature</button>
<textarea id="txt"></textarea>
</body>
Expand Down