I'm trying to enable tilt and heading rotation on a Google Map using the @react-google-maps/api library in a React app.
I have:
Created a Map ID via Google Cloud Console with:
Map type: JavaScript
Vector selected (not raster)
Tilt and Rotation enabled (see screenshot below)
Confirmed the Map ID and API Key are from the same Google Cloud project.
Zoom level set to 18.
tiltandheadingprops set on<GoogleMap>.- API version is default (should be the latest).
Problem:
Despite setting mapId, heading={90}, and tilt={45}, the map does not rotate or tilt.
Also, in the onLoad callback, calling map.getRenderingType() returns "UNINITIALIZED". This suggests it's not rendering in vector mode, which is required for tilt/heading.
Here’s my simplified code:
const containerStyle = {
width: '100%',
height: '400px',
};
const center = {
lat: 50.9932083,
lng: 10.0492926,
};
const onLoad = (map) => {
console.log('Tilt:', map.getTilt());
console.log('Heading:', map.getHeading());
console.log('Rendering Type:', map.getRenderingType()); // UNINITIALIZED
};
<GoogleMap
mapContainerStyle={containerStyle}
center={center}
zoom={18}
tilt={45}
heading={90}
mapId="..."
onLoad={onLoad}
/>
What I’ve tried:
Verifying mapId configuration (screenshot below)
Zoomed to level 18
Hardcoded tilt/heading
Calling
setTilt()andetHeading()manually inonLoadLogging rendering type → always
"UNINITIALIZED"
Questions:
Is this a bug or am I missing something?
How can I force vector rendering in React, or do I need to fall back to native JS init with
google.maps.importLibrary("maps")?
Any help is appreciated! MapId configuration
projection_changedevent to determine when the map is ready: ``` [map.addListener('projection_changed', () => { const renderingType = map.getRenderingType(); console.log('Rendering Type:', renderingType); }); ] ``` See this link below for more details: developers.google.com/maps/documentation/javascript/reference/…projection_changed? Why?