react-google-maps-api | React Google Maps API | Map library
kandi X-RAY | react-google-maps-api Summary
kandi X-RAY | react-google-maps-api Summary
React Google Maps API
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-google-maps-api
react-google-maps-api Key Features
react-google-maps-api Examples and Code Snippets
Community Discussions
Trending Discussions on react-google-maps-api
QUESTION
I am trying to access the getPlaces()
function which should be in the StandaloneSearchBox
component from react-google-maps/api
. In the documentation and other examples the are using it this way:
ANSWER
Answered 2021-Jun-10 at 23:58Here are the suggestions on how to make your code work:
I can see that you are using functional component in your code. You can't use
this
in functional component. You can use the useState instead. Instead of this.searchBox, you can useconst [searchBox, setSearchBox] = useState(null);
Once you have the useState, use the
onLoad
props of your SearchBox to call a function where you put the ref of your Searchbox object to the searchbox state.In your
onPlacesChanged
, you can just log thesearchBox.getPlaces()
to get the result of your getPlaces.
Here's the working code and the code snippet:
QUESTION
The Google Maps API library I am using for this is https://github.com/JustFly1984/react-google-maps-api
What I have been asked to create is a map with multiple markers, each of which can be clicked on to open an InfoWindow centred on that marker. Much like the AirBnB search page, with the map on one side results on the other.
However, I seem to only be able to have an InfoWindow that is open at the loading of the page and then can't be opened again.
My research so far has generally shown that I would need to completely redo this component as a class instead. Although I don't really understand the class based model of components, so ideally I wouldn't have to mess around with that.
Is there a way to make the desired effect without reworking my program entirely?
This is the code for the component, in case it is relevant
...ANSWER
Answered 2021-Apr-20 at 07:48To achieve your goal you would want to use states in your application. But since you want to deal with it using Function components, you would need to make use of react hooks to use states.
Here is a working sample for your reference: https://stackblitz.com/edit/marker-with-infowindow-react-api-o6357y
QUESTION
I'm trying to change the position of the drawing manager control panel (the one that lets the user select what shape to draw).
However, I'm having difficulties doing so.
I figured that the position values google.maps.ControlPosition.TOP_CENTER
are just numbers. So according to the docs I'm trying to pass in the position object similar to the example here
ANSWER
Answered 2021-Jan-10 at 17:21I am really no React expert and as it seems they can't provide one working example in the official docs, I am not too sure how it should be done.
The official solution I believe is here: https://react-google-maps-api-docs.netlify.app/#usejsapiloader but I could not get this to work.
So far, the only way I was able to get your above code working was by doing 2 things: 1) move the drawing manager to a separate component, and 2) use /* global google */
in the component.
QUESTION
I'm want to stopPropagation of https://react-google-maps-api-docs.netlify.app/#autocomplete. The autocomplete works well but I need to use it in a popover and when I select a place the popover automatically closes.
If there is another library that works well with popovers and modals
...ANSWER
Answered 2020-Nov-12 at 20:26I'm using chakraUI, I get help from discord(dodas user) here is the solution he make. Basically he catch the mousedown event(google block click event) and when the popover is open, select item or click trigger button just do nothing for others events just close popovers.
https://codesandbox.io/s/popovergoogle-autocomplete-6nvtb?file=/src/App.js:0-3329
QUESTION
Currently using TypeScript on my project with React version 16.13.1.
Trying to get the the Autocomplete function working from this @react-google-maps/api but the examples are in class component and i'm using functional hooks.
Any idea whats wrong with my code? Here's an example i got from the library.
Code example from this library
...ANSWER
Answered 2020-Aug-20 at 14:26You have the array items in the useState
call backwards:
const [setAutocomplete, autocomplete] = useState() as any
You want this:
const [autocomplete, setAutocomplete] = useState() as any
The first item in the array is the variable that holds the state value, the second is the function that React uses to maintain it. In your current code, the setAutoComplete
is not a function, but autoComplete
is.
QUESTION
I'm using the @react-google-maps/api
to build my first react map.. But my latLng literal for position inside the Marker
is breaking my code. Is this not the same latLng format that I'm using for center
which works fine? How is my Marker latLng wrong? That seems to be the only required attribute in the docs so I'm at a dead end.
ANSWER
Answered 2020-Jul-13 at 08:15The position property is an object. Hand your lat and lng values like this:
QUESTION
I would like to know how could I use a custom marker with google maps drawing controls. I want to do that because I need to place a marker when a user clicks in the map and have it open a info window (when clicked) and have a few custom actions in there (buttons and such).
I'm using react and @react-google-maps/api for this, but that might be besides the point since it is just a wrapper around the Maps Javascript API provided by Google.
From the docs it is possible to provide google.maps.MarkerOptions
to the google.maps.drawing.DrawingManagerOptions
. Unfortunately there is no option there to provide a custom Marker
to be rendered.
I tried using the markercomplete()
call back exposed by the google.maps.drawing.DrawingManager
since it has the newly created Marker
as parameter, and then doing something like this:
ANSWER
Answered 2020-Jun-04 at 14:47All you need to do is to set the icon
property in the MarkerOptions
, if I correctly understand your meaning of "custom marker". Below is an example using a SVG path for the icon.
This snippet is in full JS but the same should work with the React library.
QUESTION
Hi i want to make a button that can move the map to the user current location, i read the docs but i still don't understand which code to move the map like when we type and enter a location in autocomplete, or should i re-render the map with new lat long?
...ANSWER
Answered 2020-Apr-23 at 08:17Actually, you have to change the center of the map to the user location and re-render the map component. Like this:
QUESTION
Is it possible to create your own marker with your own styles? That is, change the background, change the radius, add a shadow, etc. All I got was to change the opacity and replace it with an icon.
...ANSWER
Answered 2020-Feb-08 at 09:19The icon IS the custom marker, everything you want to change about the marker you have to do to the icon. Since you have an svg it shouldn't be too hard to style.
QUESTION
I am new to React Google Maps. I'm unable to get radius value from Circle.
https://github.com/JustFly1984/react-google-maps-api
I want to get circle redius onRadiusChanged
event.
index.js
...ANSWER
Answered 2019-Nov-01 at 15:48onRadiusChanged
(as the underlying center_changed
event for a Circle
class ) event does not accept any arguments. Since onRadiusChanged
event handler method is not bound with its component instance in your example, the updated radius could be determined like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install react-google-maps-api
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