I have used the @react-google-maps/api library to add a google map and show some custom marker icons on the google map. I have followed the documentation found in here. And added a marker. I have successfully able to show my list of custom markers on the Google Map. But the issue is, I can not scale down those images and those marker icons are shown in its original size (those png images are very large)
"objectList" list contains data. The "iconUrl" returns an url of custom marker png image.
I am not sure how I can scale down the icon, since the "scale" attribute I used in the Marker is not working.
import { GoogleMap, LoadScript, Marker } from "@react-google-maps/api";
<LoadScript googleMapsApiKey="<MAP_API_KEY_GOES_HERE>">
<GoogleMap center={defaultProps.center} zoom={defaultProps.zoom} mapContainerStyle={mapStyle}>
{objectList.map( (obj) => (
<Marker key={obj.idNum} position={obj.position} icon={{url: obj.iconUrl, scaledSize: new window.google.maps.Size(90, 42) }} />
))}
</GoogleMap>
</LoadScript>
UPDATE:I have tried the "scaledSize" attribute as suggested by the this question. But it throws me the below error
Cannot read properties of undefined (reading 'maps') TypeError: Cannot read properties of undefined (reading 'maps')
How can I resolve this error ? Do I have to import another library ?