📜 ⬆️ ⬇️

Examples of Google Maps API # 2: Hide Map Controls

Cross-post of the second small article on the Google Maps API from my blog . This time it will be about how to hide the map controls.

HAND CARD MANAGEMENT ELEMENTS


If you do not want the controls to clutter up your card, you can hide them very easily. When you hover the mouse, they will reappear, and as soon as the mouse pointer is removed from the area bounded by the div with the map, they will disappear.
To do this, add the following code, after init() , you initialize the card and connect the controls to it:
map.hideControls ();
But that's not all: if you leave everything as it is, the controls will not appear. In order for them to appear when hovering over a div and disappear when the pointer is output from the zone of this div, you need to insert the following code immediately after the previous one:
GEvent.addListener (map, "mouseover" , function () {
map.showControls ();
});
GEvent.addListener (map, "mouseout" , function () {
map.hideControls ();
});
Everything turned out to be very, very simple! A working example is here .

')

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


All Articles