mapbox-gl-js

How to specify Authorization Header for a source in mapbox-gl-js?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-22 15:06:29
问题 How do I set a request header for a wms source with mapbox-gl-js? I need all tile requests to add a header that looks like: Authorization: "Bearer base64-encoded-token" The WMS example, map#addSource and map#addLayer lead me to believe it is not possible to set tile request headers. 回答1: You can now use the transformRequest option to add a custom header: A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the

How to specify Authorization Header for a source in mapbox-gl-js?

一世执手 提交于 2020-01-22 15:05:14
问题 How do I set a request header for a wms source with mapbox-gl-js? I need all tile requests to add a header that looks like: Authorization: "Bearer base64-encoded-token" The WMS example, map#addSource and map#addLayer lead me to believe it is not possible to set tile request headers. 回答1: You can now use the transformRequest option to add a custom header: A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the

How to specify Authorization Header for a source in mapbox-gl-js?

落花浮王杯 提交于 2020-01-22 15:04:19
问题 How do I set a request header for a wms source with mapbox-gl-js? I need all tile requests to add a header that looks like: Authorization: "Bearer base64-encoded-token" The WMS example, map#addSource and map#addLayer lead me to believe it is not possible to set tile request headers. 回答1: You can now use the transformRequest option to add a custom header: A callback run before the Map makes a request for an external URL. The callback can be used to modify the url, set headers, or set the

How to fix 'window.URL.createObjectURL is not a function' when testing mapbox-gl in React?

依然范特西╮ 提交于 2020-01-16 09:02:29
问题 I'm testing React component with Mapbox, material-ui and custom styles. I use Jest + Enzyme for testing. I have problem: 'window.URL.createObjectURL is not a function'. I read similar questions: github.com/uber/react-map-gl/issues/210 github.com/mapbox/mapbox-gl-js/issues/3436 github.com/mapbox/mapbox-gl-js-mock and tried to add something but without success. Please, fix the issue. CodeSandbox 回答1: I had faced exactly same issue with my jest test suite. After some trial and searching, I was

Mapbox: Get loaded tile coordinates? [closed]

☆樱花仙子☆ 提交于 2020-01-14 04:15:09
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'd like to load 3D terrain onto my mapbox map, like Peter's example, however I'm hoping to find a much simpler implementation. My idea is to use mapbox's data event to get each loaded tile and simply load a three.js mesh above it.. but I need to figure out how to calculate each

How to setup a centralized state for a mapbox map in Vuex?

青春壹個敷衍的年華 提交于 2020-01-13 09:36:06
问题 I just started using vuex with vue. I do (roughly) understand the docs. I have a specific issue for which I am not sure whether I should use vuex and if so how to go about. I have an app in which mapbox map(s) are omnipresent in various layouts and components etc. As I will be making several vue single file components but are working with one same instance of a mapbox map I think it makes sense to have the mapbox map initiated and managed in the vuex store. So e.g. when I change the map

Mapbox Web GL JS - querySourceFeatures() function with vector tile source

强颜欢笑 提交于 2020-01-13 06:31:26
问题 I've got a vector tileset on Mapbox that I created by uploading a geojson file comprising polygons representing particular suburbs in Victoria, Australia. My vector tileset has three properties - suburb, state, postcode - corresponding to the feature properties in the geojson. I can also successfully query those properties via the Mapbox web gl js library to get an accurate map. For example I've got a map working that shows a popup when I click a highlighted polygon, and the popup correctly

Mapbox GL JS: Export map to PNG or PDF?

一曲冷凌霜 提交于 2019-12-31 19:21:36
问题 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 works. I tried using the preserveDrawingBuffer option: var map = new mapboxgl.Map({ container: 'map', style: 'mapbox://styles/mapbox/light-v9', minZoom: 4, maxZoom: 14, center: [-2.0, 53.3], preserveDrawingBuffer: true }); console.log(map.getCanvas()

Mapbox GL JS: Export map to PNG or PDF?

天涯浪子 提交于 2019-12-31 19:21:34
问题 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 works. I tried using the preserveDrawingBuffer option: var map = new mapboxgl.Map({ container: 'map', style: 'mapbox://styles/mapbox/light-v9', minZoom: 4, maxZoom: 14, center: [-2.0, 53.3], preserveDrawingBuffer: true }); console.log(map.getCanvas()

Mapbox gl js - draw a car marker

匆匆过客 提交于 2019-12-31 05:11:08
问题 I need to draw a car marker based on it's position. But, unlike all official examples, like this, I want size of my marker to be dependent on zoom level. And, I want it to have heading as well - I need to rotate it based on the car's heading. Is it possible with Mapbox GL JS, and how to do it? 回答1: The Symbol layer https://www.mapbox.com/mapbox-gl-js/style-spec#layers-symbol is best suited for this, see this example https://www.mapbox.com/mapbox-gl-js/example/rotating-controllable-marker/ 来源: