Open Prajeeshmobomo opened 5 years ago
same here...
https://github.com/tomchentw/react-google-maps/issues/812#issuecomment-433315859
I followed this comment to have these two libraries work with each other.
import React, {FC, useEffect, useRef} from 'react'; import {Input} from "@/components/ui";
type Props = {}
export const Autocomplete: FC
useEffect(() => {
(async () => {
await window.google.maps.importLibrary('places')
if (autocomplete.current) {
const a =
new window.google.maps.places.Autocomplete(
autocomplete.current, {
types: ['(regions)'],
componentRestrictions: {country: 'ua'}
})
}
})()
}, [autocomplete.current]);
return (
<div>
<Input
//@ts-ignore
inputRef={autocomplete}
placeholder={"search place"}
/>
</div>
);
};
it works for me
I am using google-maps-react in my project. The code to display map is as follows.
The credentials are defined as follows.
Now i need to show the places autocomplete box inside the map.
I have used the following package https://github.com/hibiken/react-places-autocomplete#load-google-library
The current issue is that the google maps and the places search box does not work together.
When i add the places component, i am getting the following error.
To fix the issue, if i define the MAPS ON THE INDEX PAGE, then i get the following error and the map does not load.
So basically there are two things that needs to work
1) Map Component
2) Places box which is inside maps.
Any idea on how to fix this?