Possible to implement min/max zoom?
Would it be possible to implement a feature to constrain how far the user can zoom in or out?
Can you share a link to the native SDK docs that describe this feature (if it exists, of course)?
I'm not sure if these are the kind of links you are looking for...
Android: https://www.mapbox.com/android-docs/maps/overview/#mapview-xml-attributes
Looks good, thanks!
Any updates on this?
Thanks!
Any updates on this?
Thanks!
Solution for me, max zoom:
var nativeMapView = map.ios ? map.ios : map.android;
if(isIOS) {
nativeMapView.maximumZoomLevel = 12;
} else {
nativeMapView.mapboxMap.setMaxZoomPreference(12);
}
@NeriCodec are you still able to use this code snippet with the latest version of this plugin? (5.0.1)
export function onMapReady(args) {
let nativeMapView = args.ios ? args.ios : args.android;
}
But even before I am able to access the maximumZoomLevel property on iOS and the setMaxZoomPreference method on Android, it says that map.android / map.ios is undefined.
@felixkrautschuk Do you have a repository I can look at? Have you looked at the updated demos in here in github?
@Yermo thanks for your fast reply.
I checked the updated demo app (NativeScript Core + TypeScript) and there you try to access the native element the same way and it also returns "undefined" for Android. But it works correctly on iOS.
https://github.com/Yermo/nativescript-mapbox/blob/0781ed5a206c64a4e266f34a780d0572aaf1842b/demo/app/main-page.ts#L74
I also tried
export function onMapReady(args) {
let nativeMapView = args.map.getNativeMapView();
}
But that also returns undefined on Android (while working as expected on iOS).
Ok. Thank you. I will check it out.
@Yermo I created a pull request for minZoom/maxZoom here https://github.com/Yermo/nativescript-mapbox/pull/365 and added that to the demo app as well. You can now call setMinZoom and setMaxZoom methods and set the minZoom and maxZoom properties from XML.
There is still the problem with getting the native instance with args.android (even though it is not related to the functionality within the pull-request).
On iOS, there is only one element, the MGLMapView instance which exposes all methods for interacting with the map.
On Android, you have the MapView and the MapBoxMap.
So I was not sure which one to set for this.nativeMapView.
Actually the MapBoxMap is the element for manipulation and interacting with the map.