Questions tagged [mapbox]

Mapbox is a location data platform for mobile and web applications. They provide building blocks to add location-based features such as maps, search, and navigation into any experience you create.

Mapbox is built on a platform of live-updating global data. Their secure data pipeline processes over 250 million miles of anonymized traffic data per day. Through apps powered by Mapbox, including Bosch, Snap, Lonely Planet, Tableau, Red Bull, DoorDash, The Weather Channel, and Hotels.com, they reach more than 520 million people each month.

Mapbox was born out of Development Seed and the necessity to build new tools and platforms for positive impact projects including those with The World Bank, United Nations, The Red Cross and other NGO and not-for-profit organizations. Since 2010, they have quickly expanded their offering of mapping and location-based APIs and SDKs to offer many tools for developers who want to build with maps.

Developer documentation and resources:

Troubleshooting:

Related tags:

6499 questions
216
votes
15 answers

Fix the upstream dependency conflict installing NPM packages

I am trying to npm install vue-mapbox mapbox-gl, and I'm getting a dependency tree error. I'm running Nuxt.js SSR with Vuetify and haven't installed anything related to Mapbox prior to running this install and am getting this error. 38 error code…
connorcode
  • 2,341
  • 2
  • 8
  • 13
169
votes
12 answers

Zoom to fit all markers in Mapbox or Leaflet

How do I set view to see all markers on map in Mapbox or Leaflet? Like Google Maps API does with bounds? E.g: var latlngbounds = new google.maps.LatLngBounds(); for (var i = 0; i < latlng.length; i++) { …
AHOYAHOY
  • 1,856
  • 4
  • 24
  • 34
103
votes
5 answers

What are Leaflet and Mapbox, and what are their differences?

What are Leaflet and Mapbox, and what are the differences or usages of both? What are the main differences in their APIs?
vetri02
  • 3,199
  • 8
  • 32
  • 43
84
votes
7 answers

LeafletJS: How to remove the zoom control

I'm trying to remove the zoom controls (+/-) on a LeafletJS map. I'm using the MapBox.js version of Leaflet but most of the operations are the same as Leaflet. I implement my map like this: var map = L.mapbox.map('map'); var layer =…
Brett DeWoody
  • 59,771
  • 29
  • 135
  • 184
70
votes
8 answers

Mapbox GL JS vs. Mapbox.js

From the Mapbox glossary, Mapbox.js Mapbox.js is a JavaScript library that allows you to add an your interactive map to your website. It is a plugin for Leaflet, and it is an open source library that’s free to use. and Mapbox GL JS Mapbox GL JS…
raphael
  • 2,762
  • 5
  • 26
  • 55
63
votes
5 answers

How to secure the JavaScript API Access Token?

There are numerous online resources which provide JavaScript APIs to access their services. To be more clear, I will base my question on the example of MapBox, but this applies well to many other services in various domains. When someone wants to…
Tim
  • 12,318
  • 7
  • 50
  • 72
61
votes
7 answers

Mapbox GL JS getBounds()/fitBounds()

I'm using Mapbox GL JS v0.14.2 and I've searched high and low through the documentation and very little is clear about this. If you use the standard JS API, it's very clear to 'fit map to markers' using an example they have provided…
John the Painter
  • 2,495
  • 8
  • 59
  • 101
57
votes
4 answers

Leaflet: How to add a text label to a custom marker icon?

Is it possible to add text to a custom icon marker? I want to avoid having to edit the icon in an image editor just to add the text. I've created my custom icon marker like so: var airfieldIcon = L.icon({ iconUrl: 'images/airfield.png', …
redshift
  • 4,815
  • 13
  • 75
  • 138
55
votes
2 answers

How to integrate OpenStreetMap into a react-native project?

I am trying to integrate OpenStreetMap into a React Native project. But I can't find any library or anything related to React Native in their GitHub account. The only thing I can find relating to these to topics is the link below, in which there is…
Amal p
  • 2,882
  • 4
  • 29
  • 49
39
votes
5 answers

Refused to load the image 'blob:...' because it violates the following Content Security Policy

I got this error: Refused to load the image 'blob:file:///cf368042-bf23-42b6-b07c-54189d3b0e01' because it violates the following Content Security Policy directive: "default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:". Note that…
Raz Buchnik
  • 7,753
  • 14
  • 53
  • 96
27
votes
3 answers

Mapbox GL JS: Export map to PNG or PDF?

I'm using Mapbox GL JS version 0.32. Is there a way to export the map to a high-res PNG or PDF? Obviously, I can just screenshot, but it would be nice if there was a more formal way. I found this repo, but it looks old and isn't clear how it…
Richard
  • 62,943
  • 126
  • 334
  • 542
26
votes
8 answers

How to save a completed polygon points leaflet.draw to mysql table

I would like to use leaflet.draw to create outlines of regions. I have managed to get this working ok: https://www.mapbox.com/mapbox.js/example/v1.0.0/leaflet-draw/ Now I'd like to save the data for each polygon to a mysql table. Am a little stuck…
user3703511
  • 261
  • 1
  • 3
  • 3
25
votes
6 answers

MapBox clear all current markers

I've created a MapBox instance with: var map = new mapboxgl.Map({ container : 'map', style : 'mapbox://styles/mapbox/streets-v9' }); I need to clear all markers, and have tried things like map.remove(marker) on each one, and a few other…
HomerPlata
  • 1,687
  • 5
  • 22
  • 39
23
votes
3 answers

mapbox-gl-js: Adjust visible area & bearing to a given line, for a given pitch

I'm trying to optimize a Mapbox view for long-distance hiking trails, like the Appalachian Trail or the Pacific Crest Trail. Here's an example, which I've oriented by hand, showing the Senda Pirenáica in Spain: The area of interest, the viewport,…
Herb Caudill
  • 50,043
  • 39
  • 124
  • 173
23
votes
3 answers

How can I read current zoom level of Mapbox?

I have a back to home function function panToHome(){ latLng = [current.lat, current.lng]; map.setView(latLng, 8); } I want to save the current view as history, so user can switch back as they might click mistakely. So the question is how…
Weijing Jay Lin
  • 2,991
  • 6
  • 33
  • 53
1
2 3
99 100