react-map-gl

URL for Mapbox style sheet JSON

倾然丶 夕夏残阳落幕 提交于 2021-02-11 14:28:17
问题 Is there a URL that serves up the style sheet JSON for a given style? All the URL's are in Mapbox scheme: mapbox://styles/wfisher/41dj33random72ravc31c5dyn But I'd like to download the JSON directly on load so I can modify it before passing in a Javascript object to <ReactMapGL> . 回答1: You have to use the Mapbox Static API: https://www.mapbox.com/api-documentation/#retrieve-a-style so the URL would be: https://api.mapbox.com/styles/v1/wfisher/41dj33random72ravc31c5dyn?access_token=<token> and

How can i get the location of the user - Using at React Map GL

荒凉一梦 提交于 2021-02-07 18:28:18
问题 I'm using React Map GL, and I want to put the latitude and longitude of the user Returning the component like this: export default geolocated({ positionOptions: { enableHighAccuracy: false }, userDecisionTimeout: 5000 })(Layout); I'm tried to use react-geolocated but it's returning null coords. I want to get these informations when the component mounts, that's the code: componentDidMount() { console.log(this.props); if (navigator.geolocation) { const viewport = { ...this.state.viewport,

React useState option value 1 step behind onChange selection

送分小仙女□ 提交于 2021-01-28 14:40:08
问题 The size.value state is one option behind when the _updateData function triggers onChange of the <select> . For example, Let's say the starting defaultValue option of <select> is "All", locations is empty...the option is changed to "Medium", locations is "All"...the option is changed to "Large", locations is "Medium"...and so on. Initially I want the _updateData function to run onload with "All" selected which is not working either, it throws the error Cannot read property 'target' of

Stylable marker/feature in react-mapbox-gl?

青春壹個敷衍的年華 提交于 2020-06-13 11:31:21
问题 Im using https://github.com/alex3165/react-mapbox-gl My question is how to style the marker or feature component? Feature does not accept children nor style prop. Marker accepts style and children, however it doesnt render anything passed as props and even if I style it with, e.g. {{ background: 'blue' }} it has no any effects on the style. Have I missed something? Thanks 回答1: Marker and Feature are two different components which work in different ways but can both achieve what you are trying

react-map-gl without API key using osm tiles

久未见 提交于 2019-12-06 11:15:38
问题 Is it possible? This tells me it is, but dont know why it defines and API key. but I cannot get it to work with react-map-gl StaticMap class. The property I can see from that class is just mapStyle which would take a standard Mapbox vector tiles path/name. Does it take an object? My code does not give me an error or show the tiles I request. <DeckGL> <StaticMap mapStyle= {{ "version": 7, "sources": { "simple-tiles": { "type": "raster", "tiles":["http://a.tile.openstreetmap.org/{z}/{x}/{y}.png

react-map-gl without API key using osm tiles

北战南征 提交于 2019-12-04 15:29:17
Is it possible? This tells me it is, but dont know why it defines and API key. but I cannot get it to work with react-map-gl StaticMap class. The property I can see from that class is just mapStyle which would take a standard Mapbox vector tiles path/name. Does it take an object? My code does not give me an error or show the tiles I request. <DeckGL> <StaticMap mapStyle= {{ "version": 7, "sources": { "simple-tiles": { "type": "raster", "tiles":["http://a.tile.openstreetmap.org/{z}/{x}/{y}.png", "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png"], "tileSize": 256 }, "power": { "type": "vector",