Very short question - as i can't find an answer in the google maps api V3 documentation
I'm looking for a control which allows me to control/modify an api map's orientation so that north isn't at the top.
Is this possible? If so, how?
Thanks
On your computer, open Google Maps from the website. Turn on Globe view and Satellite. Hold down Ctrl, then click and drag anywhere on the map to rotate it. Moving your mouse up and down will alter the vertical angle, while moving it left and right will rotate your view clockwise or counterclockwise.
Change the view Face North: At the bottom, tap the compass. Tilt the map: With 2 fingers, touch and hold the map, then move your fingers up and down the screen. Rotate the map: With 2 fingers, touch and hold the map, then move your fingers around each other on the screen.
You can do that with 45 degree imaginery but it only works for specific locations.
As a workaround, you can rotate its wrapper div instead, using CSS transform: rotate()
*you need to disableDefaultUI, because every element inside will be rotated as well
OpenLayers is a free, lightweight and very complete javascript mapping API. Just take a look at their example page, it looks awesome (rotation example: https://openlayers.org/en/latest/examples/rotation.html).
OpenLayers can be made to show Google Maps tiles too, which can then be rotated https://gis.stackexchange.com/a/277606/114599
Currently, Google-Maps-API doesn't have an option to rotate the map (I'm hoping this feature will be soon).
satellite
or hybrid
tilt: 45
. This parameter will change the map display from a 2D map view into a 3D-like view by tilting the map in 45 degrees. heading
parameter is set to the rotation you would like to have (0, 90, 180 and 270 degrees). This will only work if tilt
is enabled.
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: { lat: 45.518, lng: -122.672 }, // try to put different location and rotation may not work
zoom: 18, // use a smaller zoom level and rotation may not work
mapTypeId: 'satellite', // use TERRAIN or ROADMAP and rotation will not work
heading: 90,
tilt: 45
});
}
for more info see: https://developers.google.com/maps/documentation/javascript/examples/aerial-rotation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With