Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set zoom level #920

Closed
nhatchimai111 opened this issue Dec 27, 2016 · 6 comments
Closed

Set zoom level #920

nhatchimai111 opened this issue Dec 27, 2016 · 6 comments

Comments

@nhatchimai111
Copy link

How to set zoom level for google map?
Help me!

@symmetriccurve
Copy link

symmetriccurve commented Dec 28, 2016

use longitudeDelta and latitudeDelta values to the region object to set the Zoom level.

zoomIn = (delta)=> {
         var zoomLevel = delta/100.0000000001
         var Lat = this.newRegion.latitudeDelta-(this.newRegion.latitudeDelta * zoomLevel)
         var Lng = this.newRegion.longitudeDelta-(this.newRegion.longitudeDelta * zoomLevel)
         if(Lat  >= 0 &&  Lat <= 180) {
               this.mapReference.animateToRegion({
                latitude: this.newRegion.latitude,
                longitude: this.newRegion.longitude,
                latitudeDelta:Lat,
                longitudeDelta:Lng
             },500)
         } else {
            console.error('latitudeDelta Should be In tha range of 1 to 180 or longitudeDelta Should be In tha range of 1 to 360 ');
         }
   }

   zoomOut = (delta)=> {
         var zoomLevel = delta/100.0000000001
         var Lat = this.newRegion.latitudeDelta+(this.newRegion.latitudeDelta * zoomLevel)
         var Lng = this.newRegion.longitudeDelta+(this.newRegion.longitudeDelta * zoomLevel)
         if(Lat  >= 0 &&  Lat <= 180) {
               this.mapReference.animateToRegion({
                latitude: this.newRegion.latitude,
                longitude: this.newRegion.longitude,
                latitudeDelta:Lat,
                longitudeDelta:Lng
             },500)
         } else {
         console.error('latitudeDelta Should be In tha range of 1 to 180 or longitudeDelta Should be In tha range of 1 to 360 ');
         }
   }

@mubeenadev
Copy link

+1

@maggialejandro
Copy link

I use this code

const { region } = this.state;
const newRegion = {
  latitude: coordinates.latitude,
  longitude: coordinates.longitude,
  latitudeDelta: region.latitudeDelta - (region.latitudeDelta / 1.2),
  longitudeDelta: region.longitudeDelta - (region.longitudeDelta / 1.2),
};

this.mapRef.animateToRegion(newRegion, 500);

@alvelig
Copy link
Contributor

alvelig commented Dec 12, 2017

The deltas are zoomControls

@alvelig alvelig closed this as completed Dec 12, 2017
@shrikantkunte
Copy link

@alvelig I am using default zoom controller by zoomControlEnabled={true}. Can we change the position of this zoom controller?

@miracle2k
Copy link
Contributor

@shrikantkunte Hopefully in the future, #2563 will provide this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants