Reputation: 63
Is it possible to click on labels in Mapbox and highlight the city like on Google maps?
Upvotes: 2
Views: 992
Reputation: 5768
All visible map elements, including labels, in a mapbox-gl map can be clicked.
see https://www.mapbox.com/mapbox-gl-js/example/queryrenderedfeatures/
In that example, instead of catching the mousemove event, catch the click event like this:
map.on('click', function (e) {
var features = map.queryRenderedFeatures(e.point);
document.getElementById('features').innerHTML = JSON.stringify(features, null, 2);
});
Upvotes: 0