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

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

Closed

Description

@frederik-jacques

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.

Activity

  1. added
    iOS
    macOS
    on May 15, 2016
  2. 1ec5 commented on May 15, 2016

    @1ec5
    Contributor

    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.

  3. andrewstay commented on Jun 22, 2016

    @andrewstay

    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.

  4. 1ec5 commented on Jul 5, 2016

    @1ec5
    Contributor

    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.

  5. andrewstay commented on Nov 18, 2016

    @andrewstay

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

  6. 1ec5 commented on Nov 18, 2017

    @1ec5
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureiOSmacOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions