Google Maps - Auto rotate maps

Hello, I’ve been trying to make my Google map rotate so it looks in the same direction as the user as a GPS App would do. Does anyone know how to do this?

Thanks.

Creating realtime navigate application using Google Maps API is prohibited by the Terms of Usage.

3.2.4 Restrictions Against Misusing the Services.
#c No Re-Creating Google Products or Features.
Customer will not use the Services to create a product or service with features that are substantially similar to or that re-create the features of another Google product or service. Customer’s product or service must contain substantial, independent value and features beyond the Google products or services. For example, Customer will not: (i) re-distribute the Google Maps Core Services or pass them off as if they were Customer’s services; (ii) create a substitute of the Google Maps Core Services, Google Maps, or Google Maps mobile apps, or their features; (iii) use the Google Maps Core Services in a listings or directory service or to create or augment an advertising product; (iv) combine data from the Directions API, Geolocation API, and Maps SDK for Android to create real-time navigation functionality substantially similar to the functionality provided by the Google Maps for Android mobile app.

I’m creating an app using Situm which is for indoor navigating and has to be combined with a maps SDK like Google’s. Although it’s real time navigation Google Maps App for Android doesn’t have this feature. Do you think that’d be OK? If not, are there good alternatives to Google Maps that you know for Cordova?

(iv) combine data from the Directions API, Geolocation API, and Maps SDK for Android to create real-time navigation functionality substantially similar to the functionality provided by the Google Maps for Android mobile app.

Regarding of this clause, if your app are not substantially similar like using own data (in this case Situm), this clause does not match it.

As far as your information, you use own data, not using Google Directions API, so, in this case, you can use Google Maps API.

Okay thanks. So still trying to find out how to rotate de map D:

Tried rotating the div but doesn’t work :confused:

Okay, then answering to the original question “how to rotate the map” is that use map.animateCamera() or map.setCameraBearing().

animateCamera()

let cameraPosition: CameraPosition = this.map.getCameraPosition();

cameraPosition.bearing = 90; // heading of the map

this.map.animateCamera(cameraPosition);

or

this.map.setCameraBearing(90);  // changing the map heading without animation

There is no function to change map heading automatically.
Thus you need to control the map camera from your code.

In order to get the device heading, you might be able to use this.
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-device-orientation/

1 Like

The Google map is not a HTML element, it’s a native view which is located under the browser.
So rotating the map div is non-sense.


That worked perfectly, thank you very much!