Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps API, custom tilt, rotation and stuff

I'm trying to display a map just like Google does here https://www.google.fr/maps

With google maps API, I'm struggling at finding the following :

  • makeing ctrl + drag change the tilt
  • programmatically setting the tilt to 0, but keep 3D imagery (for high resolution purpose basically)
  • programmatically setting the tilt to a custom value (say 30 degrees)
  • makeing ctrl + drag rotate the map
  • programmatically rotate the map to a custom value

Is that even possible ?

like image 931
Cyril CHAPON Avatar asked Nov 17 '25 12:11

Cyril CHAPON


1 Answers

First off, the map in your link by default does not support 45 degree tilt nor rotate options, as that is a roadmap. In order to enable tilt and rotate options in your map, you will need to set your mapTypeId to "Satellite" or "Hybrid" first and set the rotateControl in your Map Object to true; this is an example adapted from Google Maps API:

function initialiseMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
  center: {lat: 41.390205, lng: ‎2.154007},
  zoom: 12,
  mapTypeId: 'satellite',
  rotateControl: true
  });
  map.setTilt(45);

}

As far as I can tell from their documentation:

Google Maps JavaScript API support special 45 degree imagery for certain location

You can set the heading option and tilt option dynamically by calling the respective method on the map object. But I do not think you can override the preset behavior programmatically unless this is something that I have missed from the documentation . This is another link to the 45 degree service for you.

like image 68
rags2riches-prog Avatar answered Nov 19 '25 02:11

rags2riches-prog