How to disable 45 degree option in Google Maps Javascript API 3.x

I want to remove the option for the user to place the card in 45 degree tilt mode from the satellite. I can set the default by calling setTilt (0) in the Map object, but when the map is displayed and the user clicks on the Satellite parameter in the upper right corner of the map, it still shows a 45-degree option.

How can I exclude the 45-degree version, and the user has the ability to switch between road and satellite views.

+6
source share
7 answers

I did this by overriding "mapTypeControl" manually. then you have control over what is included.

(I did this because it was not possible before to enable the Terrain parameter, but this is fixed now. Its the same basic problem)

You can use this example as a starting point: http://gmaps-samples-v3.googlecode.com/svn/trunk/controls/index.html

+2
source

The best kludge I have found for this includes both setting the slope parameter in the map parameters and hiding the popup using css attribute selectors. In other solutions, the user can manually switch to 45 °.

Map options

var mapOptions = { tilt:0, //all other map options } 

CSS to hide the pop-up window (when the mouse is over the Satellite control).

 [title=Show\ 45\ degree\ view] { display:none; } 
+13
source
 var mapOptions = { center: mycenter, zoom: 7, tilt: 0, 

this code disables 45 degree viewing forever, but I could not remove it.

EDITED

+6
source

I found that you need a slightly different CSS to hide the 45 degree selector:

 [title=Show\ 45\ degree\ view], [title=Zoom\ in\ to\ show\ 45\ degree\ view], [title=Zoom\ in\ to\ show\ 45-degree\ view] { display:none !important; } 

Refresh, found another name used when viewing maps on mobile devices.

0
source

Another alternative is to add an event listener so that the slope is 0 . This is in addition to setting tilt: 0 in the parameters of your card, as others recommend.

It does not remove the user interface, but prevents viewing, other than service ones. It is language independent and you do not need to update CSS.

eg:.

 google.maps.event.addListener(map, 'tilt_changed', function() { if (map.getTilt() != 0) { map.setTilt(0); } }); 
0
source

These answers are great, but I prefer to use this selector to hide the tilt button:

 [class="gm-tilt"] { display:none; } 
0
source

When you get the script, there is a variable called myOptions, and it contains scale. How:

 var myOptions = {zoom:19,center:new google.maps.LatLng(....... 

Here you can include the tilt: 0 variable, for example:

 var myOptions = {zoom:19,tilt:0,center:new google.maps.LatLng(....... 
-1
source

Source: https://habr.com/ru/post/910646/


All Articles