Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Restrict panning of map with offline downloaded map #5042

Closed
frederik-jacques opened this issue May 15, 2016 · 5 comments
Closed

[ios] Restrict panning of map with offline downloaded map #5042

frederik-jacques opened this issue May 15, 2016 · 5 comments
Labels
feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS

Comments

@frederik-jacques
Copy link

frederik-jacques commented May 15, 2016

When you download an offline map you provide the MGLTilePyramidOfflineRegion initialiser a bounds struct which downloads a specific part of a map.

When you use the offline map, the user is able to scroll around and sees blank tiles for parts outside the map that have been downloaded.

It should be possible to restrict the map to only pan within certain bounds.

You could implement - (void)mapView:(MGLMapView *)mapView regionDidChangeAnimated:(BOOL)animated, but then you have to manually check if the current visible screen bounds is outside the downloaded bounds.

In the previous version of the Mapbox SDK this was possible with a certain method where you would pass in the NE en SW coordinate and you couldn't scroll past those.

Platform: iOS
Mapbox SDK version: 3.2.2

Steps to trigger behavior

  1. Download an offline map
  2. Show it on a map
  3. Scroll around

Expected behavior

You can only scroll within the bounds that have been downloaded.

Actual behavior

You can scroll everywhere, so you get to see blank tiles when the app runs in offline mode.

@1ec5 1ec5 added feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS labels May 15, 2016
@1ec5
Copy link
Contributor

1ec5 commented May 15, 2016

Previous discussion in #2457. This is complicated by the fact that this SDK allows rotation and tilting, whereas that wasn’t possible with the old SDK. In some cases, it would be OK for the user to see beyond the bounds by rotating and tilting, whereas for the case you describe, that would be suboptimal. Another consideration is that we intend to eventually allow offline regions to be non-rectangular, at which point the -mapView:regionDidChangeAnimated: approach would be easier to work with, and #2457 would be even easier.

@andrewstay
Copy link

This is one of the critical features for stay.com.
Our logic is based around a particular city. We load annotations and map for one city. So we need to restrict user from panning outside the city area.

@1ec5
Copy link
Contributor

1ec5 commented Jul 5, 2016

For starters, I’ve implemented the simplest possible API for restricting movement in #5584. With this API, it should be possible to implement logic to restrict gestures based on regions already downloaded for offline use, but we should keep this ticket open to investigate more concise or automatic approaches.

@andrewstay
Copy link

@1ec5 I cannot implement it using -mapView:regionDidChangeAnimated: approach as it is blocked by #7119

@1ec5
Copy link
Contributor

1ec5 commented Nov 18, 2017

As of #5584, you can implement the -[MGLMapViewDelegate mapView:shouldChangeFromCamera:toCamera:] to constrain gestures to the offline region.

@1ec5 1ec5 closed this as completed Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

No branches or pull requests

3 participants