react-mapbox-gl | A React binding of mapbox-gl-js | Map library
kandi X-RAY | react-mapbox-gl Summary
kandi X-RAY | react-mapbox-gl Summary
A React binding of mapbox-gl-js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of react-mapbox-gl
react-mapbox-gl Key Features
react-mapbox-gl Examples and Code Snippets
Community Discussions
Trending Discussions on react-mapbox-gl
QUESTION
I'm trying to display the users position and the heading indicator in React-mapbox-gl.
...ANSWER
Answered 2022-Jan-01 at 21:31EDIT: v6.1.18 is released, and the GeolocateControl now has the showUserHeading prop. Therefore the solution below is no longer needed.
I figured out that as of 21.09.2021, react-map-gl hasn't included showUserHeading
within their props. I solved this by patching using this tool https://www.npmjs.com/package/patch-package
Here's the patch
QUESTION
Hej. I want to create a react admin input component MapInput where I'm given a map with drawing controls github. There I'm able to draw my polygon and get GeoJSON as a result, which I can then send to my backend REST API server (json-server).
My system consists of my react client program, and a json-server with REST API. Example for an area in my REST API:
...ANSWER
Answered 2021-Sep-20 at 15:53Your custom input component must display and allow the change of the polygon. This data is in the form state, handled by react-final-form. So you'll need to use react-final-form's useField()
hook to grab the input value and change callback:
QUESTION
I m using https://github.com/alex3165/react-mapbox-gl
My question is how to make a marker component draggable?
...ANSWER
Answered 2021-Aug-16 at 07:47React Map GL have a similar example in their docs:
https://visgl.github.io/react-map-gl/examples/draggable-markers
On that page you'll find a link to "View Code", and in App.js you'll see the logic.
React-Mapbox-GL works in a similar way, and have the same properties you can pass functions to: onDragStart
, onDrag
, onDragEnd
.
You'll need to set up your marker in a similar way to them:
QUESTION
I'm working website which uses a lot of markers. And for performance reasons I'm going to render only visible markers after each move. I'm using mapbox js library via react-mapbox-gl react library. Any advice how to get visible coordinates from map? Top left and bottom right visible coordinates is enough.
...ANSWER
Answered 2021-Jul-05 at 08:28You can use map.getBounds()
or map.getBounds().toArray()
.
QUESTION
I want to have a map and an input form on a single page. The user should be able to type into the input field, hit submit, and have the Mapbox component move to that location.
I have two issues, and I suspect they are related. When I type in the input box, the map component flickers after each onChange event. Second, when I submit the form, the geolocation is successfully fetched, the props are updated on the Map component and the map marker appears, but the map doesn't perform the neat animation I see when I just go into React Dev tools and manually update the props.
I know I'm a rank beginner, and there are a thousand things wrong with this I'm sure. I'd love if someone knows the answer to this, but I'd also be happy if someone could just point me in the right direction. I spend the morning looking over the React's "getting started" and "hooks" section, and took some React classes where you built simple apps, but clearly there was something fundamental that didn't sink in. Thanks!
Here is the NextJS page:
...ANSWER
Answered 2021-Apr-22 at 21:06Your sense that the problems are related is right on. One issue is that you're re-initializing the Map
component on every render:
QUESTION
I'm trying to use React Mapbox but I'm facing some problems with using the Layer component.
I'm trying to follow this demo: https://github.com/alex3165/react-mapbox-gl/blob/master/example/src/demos/heatmap.tsx
Or even the "quick start" demo from the main page: https://github.com/alex3165/react-mapbox-gl
And my map is showing but the layer is doesn't! Here's my code:
...ANSWER
Answered 2020-Nov-19 at 07:29Ok, so after some more research I found that the problem is in the last version of react-mapbox-gl (5.0.0
). Installing react-mapbox-gl@4.8.6
finally displayed my Layers and everything works fine.
I don't know what is the problem in version 5.0.0
. Hope they will fix this soon.
QUESTION
I'm a new of MapBox and trying to make the same feature of googleMap 'Search This Area'.
In my imagine, I need the coordinate of user's view(left-top and right-bottom), then I can calculate if my points is in user's view it will display markers.
...ANSWER
Answered 2020-Jul-21 at 14:11https://docs.mapbox.com/mapbox-gl-js/api/geography/#lnglatbounds to get the bounding box of your current map view, use
QUESTION
The text in my popups is unselectable. I am able to close popups via click, etc., but when hovering the pointer over the text, the pointer remains as the hand icon, and never changes into the I-beam text selection icon. I've tried adding the popups a few different ways, to no avail:
...ANSWER
Answered 2020-May-21 at 08:27I believe it will be difficult to get to the exact cause without a running example. Here are some ideas:
- Use the same class they use in the examples for the content:
mapboxgl-popup-content
- Inspect the HTML and see if there isn't some sort of invisible layered element on top of your text. From the Browser DevTools, in the "Inspector" (Firefox) or "Elements" (Chrome) tab, by hovering the tags, you'll be able to see the bounding box of each rendered element like so:
- Similar to the point before, check for the
z-index
CSS property in the rendered element to see if something isn't layering on top of your content
Lastly, there's also the cursor CSS property which you can use to force the cursor's appearance.
QUESTION
I am using React Mapbox GL in my project and as i use Marker for about 10000 data points and performance is not that good. I have read the documentation and it says
Note: When rendering many objects, avoid using Markers as it will negatively affect performance. Use Layers and Features instead.
How to use Layers and Feature to display markers?
...ANSWER
Answered 2020-Jan-09 at 12:44To render something with layers and features, put one or more Feature components inside of a Layer component. You can give each Feature a position using the coordinates
prop.
Now, what's left over is to style these features. How you do this depends on what your markers previously contained, but for example, if you'd like to draw circles for each of the positions, you can set the Layer's type
to circle
and under the paint
prop, provide values for circle-color
and circle-radius
(these are described in the mapbox-gl API docs.
For drawing images for each coordinate, you can use the icon-image
layout
property on the Layer (you would have to either use a preexisting icon or upload one to Mapbox Studio).
You can see some sample code in the demos, for example the all-shapes demo styles data with circles.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-mapbox-gl
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page