-
-
Notifications
You must be signed in to change notification settings - Fork 66
Open
Description
I want to use getGeocode to get latlng to input as requestOptions within usePlaceAutocomplete
something like that:
const CityPage = () => {
const router = useRouter();
const { cityName } = router.query;
const [location, setLocation] = useState<LatLng>();
getGeocode({ address: cityName }).then((results) => {
const result = getLatLng(results[0]);
setLocation(result)
});
const {
ready,
value,
suggestions: { status, data },
setValue,
clearSuggestions,
} = usePlacesAutocomplete({
requestOptions: {
location
/* Define search scope here */
},
callbackName: 'initMap',
debounce: 300,
});
However, next.js complains about ReferenceError: window is not defined. I understand that google has not been initialised.. and the issue would be fixed if useGeocode is used after usePlacesAutocomplete.. but i need it this way and don't know how to go about it. Any advice?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels