Comments (6)
Hi @titouanmathis, I've just opened a PR with this change. #88
Thank you for the patch-package tip, I didn't knew it 😃
from vue-mapbox-gl.
Hi @asanmiguel-nodrizatech, I am not sure that this issue is related to our package as this seems to be a behavior that would happen when using mapbox-gl
directly.
If you can confirm that this is related to our package, could you provide us a link to a reproduction of the issue?
from vue-mapbox-gl.
In the mapbox cluster example (https://docs.mapbox.com/mapbox-gl-js/example/cluster/), there is this code to handle the click:
// inspect a cluster on click
map.on('click', 'clusters', (e) => {
const features = map.queryRenderedFeatures(e.point, {
layers: ['clusters']
});
const clusterId = features[0].properties.cluster_id;
map.getSource('earthquakes').getClusterExpansionZoom(
clusterId,
(err, zoom) => {
if (err) return;
map.easeTo({
center: features[0].geometry.coordinates,
zoom: zoom
});
}
);
});
This code is very similar to the one in your package, but in here I could add some condition before the easeTo
call.
The default behavior of the click on a cluster point should be exactly what is happening, but in your package I can't add the condition myself, so I was thinking in use the exposed event to prevent the default behavior, something like this:
function clustersClickHandler(event) {
const feature = unref(map).queryRenderedFeatures(event.point, {
layers: [unref(clustersLayer).id],
})[0];
const { cluster_id: clusterId } = feature.properties;
// Emit a cluster click event
emit('mb-cluster-click', clusterId, event);
// Check if event is prevented before to move the view
if (event.defaultPrevented) {
return;
}
unref(map)
.getSource(unref(sourceId))
.getClusterExpansionZoom(clusterId, (err, zoom) => {
if (err) {
return;
}
unref(map).easeTo({
center: feature.geometry.coordinates,
zoom,
});
});
}
from vue-mapbox-gl.
Thanks for the clarification, I understand your problem better. Your proposal of a condition on the event.defaultPrevented
property seems a nice addition. Could you open a PR to add it to the component?
from vue-mapbox-gl.
In the meantime, you can patch the module in your project with patch-package.
from vue-mapbox-gl.
Fixed in #88, thanks for the PR @asanmiguel-nodrizatech!
from vue-mapbox-gl.
Related Issues (20)
- An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling HOT 3
- MapboxCluster: `id`s of layer and source HOT 2
- TypeScript: `index.d.ts` file?
- Setting cooperativeGestures on MapboxMap HOT 1
- Working example for GeoJSON Line with MapboxSource & MapboxLayer HOT 1
- Add the missing clusterProperties to clusters HOT 1
- Incompatible with mapbox-gl (v3) HOT 2
- Link to your Guide is wrong in README.md HOT 1
- Draggend HOT 3
- DEP0151 DeprecationWarning
- Duplicate source ID for mulitple cluster HOT 1
- MapboxGeocoder does not emit `mb-created` HOT 1
- How to trigger geolocation on map load? HOT 16
- setting height to 100% instead of a value
- The map is not zooming on the new bounds when a default center is given HOT 4
- Cannot read properties of undefined (reading 'addTo') HOT 4
- Custom markers icon HOT 2
- Geocoder does not search for roads/streets HOT 1
- please Add support for right-to-left scripts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-mapbox-gl.