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

Add minZoom and maxZoom properties for android and ios #1360

Merged

Conversation

foyarash
Copy link
Contributor

Adding ability to set minZoomLevel and maxZoomLevel for both iOS and Android (GMaps included for iOS).

Need maybe some review for iOS, as i did a dumb implementation of https://github.com/johndpope/MKMapViewZoom .

@henrikra
Copy link

So basically if I have two markers on the map very close to each other but I set minZoomLevel to something reasonable and call fitToMarkers the map won't zoom it self to street level?

@foyarash
Copy link
Contributor Author

Well yeah which is quite logic. What will happen is that, if the required zoom to fit your markers is more than the maxZoomLevel, you will have your map at this maxZoomLevel (same case for minZoomLevel).

@henrikra
Copy link

Then this PR is very good. What if I want to use fitToMarkers with different min zoom level? I guess this setting is global 🤔

@foyarash
Copy link
Contributor Author

This is a global setting for the map yeah, but something which has to be tested is to set the max/min possible zoom values in case you do a fitMarkers by settings the props with a state value.

@foyarash
Copy link
Contributor Author

PR updated, i forgot to add some things to the AIRMap.h, and GMaps for iOS was not working correctly

@@ -257,7 +257,7 @@ class MapMarker extends React.Component {
let image;
if (this.props.image) {
image = resolveAssetSource(this.props.image) || {};
image = image.uri;
image = image.uri || this.props.image;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What warrants this change?

// GlobalVars.m
//
// Created by Eric Kim on 2017-04-04.
// Copyright © 2017 Apply Digital. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a legal expert but i'm guessing this would have to change

@foyarash foyarash force-pushed the zoom-level-preferences branch 2 times, most recently from 0361b3b to 6213a1d Compare July 5, 2017 19:24
@foyarash
Copy link
Contributor Author

foyarash commented Jul 5, 2017

Corrected that, i got confused when merging some branches, but it's ok now

@christopherdro christopherdro merged commit 045ec7e into react-native-maps:master Jul 5, 2017
sorodrigo pushed a commit to Vizzuality/react-native-maps that referenced this pull request Jul 6, 2017
…-upstream

* upstream/master:
  Add minZoom and maxZoom properties for android and ios (react-native-maps#1360)
  Reference install solution in issue react-native-maps#718 in install docs (react-native-maps#1448)
  updates npm cache clean command (react-native-maps#1450)
  v0.15.3
  Added BatchedBridge
  Upgraded ios deps
  Use prop-types and add supprort for RN 0.45
  Allow react 16.0.0-alpha
  [Android] Code cleanup step I - reformatting (react-native-maps#1415)
  Fixes google map null pointer exception (react-native-maps#1403)
  [iOS - Google Maps] Fix animateToCoordinate and animateToRegion (react-native-maps#1115)
  Update from View.propTypes to ViewPropTypes to match RN v0.44.0 (react-native-maps#1323)
  Fix import header for React Native 0.44.2 (react-native-maps#1362)
  Fix a couple typos (react-native-maps#1375)
j8seangel added a commit to Vizzuality/react-native-maps that referenced this pull request Jul 14, 2017
* 'master' of github.com:Vizzuality/react-native-maps:
  fix: error syntax on AirMaps max and min zoom level not nil check
  Add minZoom and maxZoom properties for android and ios (react-native-maps#1360)
  Reference install solution in issue react-native-maps#718 in install docs (react-native-maps#1448)
  updates npm cache clean command (react-native-maps#1450)
  v0.15.3
  Added BatchedBridge
  Upgraded ios deps
  Use prop-types and add supprort for RN 0.45
  Allow react 16.0.0-alpha
  [Android] Code cleanup step I - reformatting (react-native-maps#1415)
  Fixes google map null pointer exception (react-native-maps#1403)
  [iOS - Google Maps] Fix animateToCoordinate and animateToRegion (react-native-maps#1115)
  Update from View.propTypes to ViewPropTypes to match RN v0.44.0 (react-native-maps#1323)
  Fix import header for React Native 0.44.2 (react-native-maps#1362)
  Fix a couple typos (react-native-maps#1375)
yosimasu pushed a commit to yosimasu/react-native-maps that referenced this pull request Aug 7, 2017
…maps#1360)

* Add minZoom and maxZoom properties for android and ios

* Add min/max zoom level properties to AIRMap.h

* Fix assignation for zoom levels for gmaps ios

* Resolve conflicts, fix potential nil value on ios

* Resolve conflicts
pjaraherrera pushed a commit to pjaraherrera/react-native-maps that referenced this pull request Sep 27, 2017
…maps#1360)

* Add minZoom and maxZoom properties for android and ios

* Add min/max zoom level properties to AIRMap.h

* Fix assignation for zoom levels for gmaps ios

* Resolve conflicts, fix potential nil value on ios

* Resolve conflicts
@samthui
Copy link

samthui commented Nov 17, 2017

I'm using react-native-maps 0.17.1. I set maxZoomLevel=10 and minZoomLevel=8, but I still can zoom in/out like nothing is limited. Does anyone have same problem?

@marengga
Copy link

Strange behavior on Android.
You should place maxZoomLevel props in the end of MapView declaration to make it works.

<MapView
     style={{ flex: 1 }}
     showsUserLocation={true}
     showsMyLocationButton={true}
     mapType={this.state.mapType}
     ref={(ref) => { this.mapRef = ref; }}
     onLayout={() => this.mapRef.fitToCoordinates(markers)}
     maxZoomLevel={17}>

Maybe conflicts with onLayout props?

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

Successfully merging this pull request may close these issues.

5 participants