Questions tagged [mapbox-gl-js]

A WebGL JavaScript interactive maps library that can render Mapbox Vector Tiles.

Filter by
Sorted by
Tagged with
4 votes
2 answers
8k views

Mapbox Vector Tiles from Geoserver 2.11 in Mapbox GL JS

I am running Geoserver 2.11.0, have installed the vector tiles extension and enabled the application/x-protobuf,type=mapbox-vector tile format. Requesting vector tiles from my server using OL3 works ...
jotamon's user avatar
  • 1,737
6 votes
1 answer
2k views

Turf.js midpoint of line

I'd like to open a popup in on the midpoint of a polyline/linestring in Mapbox GL, like it's the default case in Leaflet. How can I do this via turf.js? If I use centroid/center/centerOfMass it will ...
hyperknot's user avatar
  • 393
3 votes
1 answer
550 views

Storing a Mapbox-hosted vector tileset in a variable (Mapbox-GL-JS)

I'm trying to make a map using Mapbox GL that is basically identical to this example: https://www.mapbox.com/mapbox-gl-js/example/filter-markers/. The main difference that source I'm using is a ...
ghosteditor's user avatar
2 votes
1 answer
2k views

Using ST_AsMVT with ST_TileEnvelope clipping in mapbox

I have been searching for a while for a way to correctly project the ST_AsMVT to ensure it fits to the map. The below query was the only suggestion I found that will correctly transform to the mapbox ...
Reece Casey's user avatar
12 votes
5 answers
18k views

Mapbox GL JS - "Source Loaded" event

I'm adding a vector tile source to my Mapbox GL js map like this: this.map.on('load', () => { this.map.addSource('userSource', { type: 'vector', url: 'mapbox://&...
DMack's user avatar
  • 655
7 votes
1 answer
6k views

How do I increase the font size of contents in Map in Leaflet.js?

I am using Leaflet JS for displaying my map. Following is my code. The map gets displayed. But the size of the city names are not large. Each time I zoom in, the font size is very less. It is not ...
Questions's user avatar
6 votes
1 answer
8k views

highlight feature with click in mapbox gl

I have a geojson layer of streets that are highlighted when moused-over. My objective is now to highlight individual streets red with a click event. Only one street should be able to be ...
iskandarblue's user avatar
  • 2,092
5 votes
3 answers
9k views

How to emulate a click on a MapBox GL JS map?

I need to emulate a user click on my MapBox GL JS map. I doesn't matter where in my map: could be useful to do in the point at the center of my maps if this could be easier. UPDATE I've found here ...
Cesare's user avatar
  • 2,001
5 votes
2 answers
5k views

Mapbox GLJS - group layers

I'm trying to build an interactive map, without any knowledge in javascript, and i found myself a bit lost in this large world. I've already designed my style in mapbox studio. And now, trying to ...
Cdrice's user avatar
  • 63
5 votes
1 answer
6k views

How to change the icon-image on click

I am using Mapbox and I am trying to change the icon-image by clicking on it, for example I want to change this: With this when I click: map.on('load', function() { map.loadImage('./images/...
Thulaksan Jayapal's user avatar
4 votes
1 answer
8k views

Matching multiple properties in mapbox gl js filter

I am trying to write a filter that will match on values from several properties of a layer. For example, in my hypothetical layer of breweries, I'd like to match those breweries that have a state ...
jotamon's user avatar
  • 1,737
3 votes
1 answer
3k views

Combining popup info from overlapping polygons in Mapbox GL JS

I've tried several solutions, but I'm having trouble populating a popup with information from overlapping polygons. When there are polygons that overlap, I want to drill down and pull the names from ...
Michael Frans's user avatar
3 votes
0 answers
2k views

Mapbox GL checkbox menu

I am trying to toggle layers and legends using a checkbox menu. I'm able to toggle the bathroom and sq ft legends, but I'm not sure how to identify the layer layout in order to toggle it. Here is my ...
tkayne23's user avatar
2 votes
1 answer
2k views

Mapbox GL JS: Displaying polygons from different coordinate systems / projections

I'm new to GIS and have access to OS MasterMap Topography Layer data (UK). I've got it loaded into PostGIS and am querying the polygons that I'm interested in (buildings). My understanding is the ...
gbuckingham89's user avatar
1 vote
1 answer
7k views

Toggling multiple layers with one click? Mapbox GL JS

How would I go about grouping the two layers in the sample code below so they could be toggled on and off together with one button? <html> <head> <meta charset='utf-8' /> &...
Nickelberry's user avatar
1 vote
1 answer
2k views

Mapbox use point result from Geocoding/Search to queryRenderedFeatures on polygon layer that intersects

I've been quite stumped on this and while I have seen it used in other online examples I can't find anything on stack or in the documentation. Right now, I am trying to use the search bar result (a ...
Jspa's user avatar
  • 29
0 votes
1 answer
503 views

How to load geojson features outside view with Mapbox GL?

I am trying to load all features from an imported geoJSON. I want to do so because I need some propeties in order to create a list of all elements. But when trying to access them it looks like I can ...
obrob's user avatar
  • 857
0 votes
1 answer
1k views

Mapbox GL JS default state of toggle layers

How do I change the default state (off or on) of a toggle menu in Mapbox GL JS? The code that I'm using came from another question on this site Mapbox GLJS - group layers <!DOCTYPE html> <...
Nickelberry's user avatar