Google Maps Api default change default zoomControls Image?

Can you modify the default image of the google maps api zoom controls to create your own?

+4
source share
1 answer

No, you cannot change the zoom control image to all but the three options provided by Google:

The zoom control can appear in one of the following style options:

google.maps.ZoomControlStyle.SMALL displays a mini-zoom control consisting of only the + and - buttons. This style is suitable for small cards. On touch devices, this control appears as + and - buttons that respond to touch events.

google.maps.ZoomControlStyle.LARGE displays the standard zoom slider control. On touch devices, this control is displayed as + and - which respond to touch events.

google.maps.ZoomControlStyle.DEFAULT selects the appropriate zoom control based on the size of the map and the device on which the map is located. works.

However, you can create custom controls and place them on a map. You will need to install appropriate event handlers and control the state of the control, but you can do this.

The slider control can be a little complicated, but if you just want to zoom in and out, you can leave without state control.

events will look something like this:

//zoom in control click event google.maps.event.addDomListener(zoomIn, 'click', function() { var currentZoomLevel = map.getZoom(); if(currentZoomLevel != 21){ map.setZoom(currentZoomLevel + 1); } }); //zoom out control click event google.maps.event.addDomListener(zoomOut, 'click', function() { var currentZoomLevel = map.getZoom(); if(currentZoomLevel != 0){ map.setZoom(currentZoomLevel - 1); } }); 
+3
source

All Articles