ravi pandey
ravi pandey

Reputation: 19

Google map makes zoom in and zoom out twice in javascript

I am making an simple application using google map. In this application I have added a own custom zoom in and zoom out buttons. When I click on zoom in button then it set zoom value to 1 to map on one click but the map zoomed in twice. If I zoom in using mouse wheel then zoomed in twice.

Below is the code for zoom in that I am using...

var currentZoom = map.getZoom();
map.setZoom(currentZoom + 1);

I was trying to set zoom value in fractions such as .25 instead of 1. But map does not perform with fractions values with function setZoom(currentZoom + .25).

This is very important for my application to make zoom snipped. Please provide a solution for this or any alternate that I can do the same thing.

Upvotes: 1

Views: 1426

Answers (2)

HelloWorld
HelloWorld

Reputation: 2330

Though the docs don't say so anymore (they used to) setZoom method requires an integer not a floating point. You could use CSS Zoom in conjunction with Google map zoom (setZoom(1) + CSS zoom .25 to make zoom 1.25 for example). However that trick wont work in Firefox

Upvotes: 0

Vikasdeep Singh
Vikasdeep Singh

Reputation: 21766

You can not do that. It must be an integer like 1, 2, 3.... Not with 0.5, 0.75 etc

Checkout the official doc for more information: https://developers.google.com/maps/documentation/javascript/reference/3/map#Map.setZoom

Upvotes: 1

Related Questions