You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A quick question on how to set more advanced options e.g. mapTypeControlOptions
I've tried window.google.maps.mapTypeControlOptions, but it occured the error "caught TypeError: Cannot read properties of undefined (reading 'maps')
Here's my code
import{GoogleMap,useJsApiLoader}from'@react-google-maps/api';import{mapConstants}from'./constant';const{VITE_GOOGLE_MAPS_KEY,VITE_GOOGLE_MAPS_DYNAMIC_ID}=import.meta.env;constlibraries=['places'];functionCustomGoogleMap({ children }){const{ isLoaded, loadError }=useJsApiLoader({googleMapsApiKey: VITE_GOOGLE_MAPS_KEY,
libraries,mapIds: [VITE_GOOGLE_MAPS_DYNAMIC_ID],});if(loadError)return'Error loading maps';if(!isLoaded)return<h1>loading</h1>;return(<GoogleMapmapContainerStyle={{height: '90vh',width: '90vw'}}options={{mapTypeControl: true,mapTypeControlOptions: {mapTypeIds: [mapConstants.ROADMAP,mapConstants.HYBRID],// It is working because this option type is Stringposition: window.google.maps.ControlPosition.RIGHT_TOP,// Not working// style:},}}>{children}</GoogleMap>);}exportdefaultCustomGoogleMap;
I want to set mapTypeControl.position and mapTypeControl.style
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
Now I'm setting the mapOptions.
A quick question on how to set more advanced options e.g.
mapTypeControlOptions
I've tried window.google.maps.mapTypeControlOptions, but it occured the error
"caught TypeError: Cannot read properties of undefined (reading 'maps')
Here's my code
I want to set
mapTypeControl.position
andmapTypeControl.style
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions