nativescript-mapbox icon indicating copy to clipboard operation
nativescript-mapbox copied to clipboard

Possible to implement min/max zoom?

Open keerl opened this issue 7 years ago • 10 comments

Would it be possible to implement a feature to constrain how far the user can zoom in or out?

keerl avatar Oct 15 '18 16:10 keerl

Can you share a link to the native SDK docs that describe this feature (if it exists, of course)?

EddyVerbruggen avatar Oct 15 '18 17:10 EddyVerbruggen

Looks good, thanks!

EddyVerbruggen avatar Oct 15 '18 17:10 EddyVerbruggen

Any updates on this?

Thanks!

joeynylund avatar Feb 27 '19 20:02 joeynylund

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);
        }

nericode avatar Aug 21 '19 16:08 nericode

@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 avatar May 12 '20 08:05 felixkrautschuk

@felixkrautschuk Do you have a repository I can look at? Have you looked at the updated demos in here in github?

Yermo avatar May 12 '20 23:05 Yermo

@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).

felixkrautschuk avatar May 13 '20 08:05 felixkrautschuk

Ok. Thank you. I will check it out.

Yermo avatar May 13 '20 20:05 Yermo

@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.

felixkrautschuk avatar May 27 '20 10:05 felixkrautschuk