mapbox / mapbox-maps-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and Metal
https://www.mapbox.com/mapbox-mobile-sdk
Other
469 stars 153 forks source link

Offline maps tile region boundaries #950

Open Tapestes opened 2 years ago

Tapestes commented 2 years ago

New Feature

I'd like to be able to highlight the geographic region accounted for by any offline TileRegion in the TileStore. Using the method below, I can retrieve the center coordinate of the offline tile region, but I don't see any way to grab the northwest and southeast corners of the region boundary.

TileStore.default.allTileRegions { result in
            switch result {
            case let .success(tileRegions):
                print(tileRegions)
                for region in tileRegions {
                    TileStore.default.tileRegionGeometry(forId: region.id, completion: { result in
                        switch result {
                        case let .success(tileRegionGeometry):
                            print(tileRegionGeometry) //center point of region
                        default:
                            break
                        }
                    })
                }
            default:
                break
            }
        }

Why

As far as i can tell, I can retrieve the center point of a region in the TileStore, but not its boundary. The boundary would be useful as I could then let the user know whether they've already download the tiles for a given area.

ZiZasaurus commented 2 years ago

@Tapestes, are you declaring the geometry in your TileRegionLoadOptions as a point or as another geometry type? If I create my region using a polygon (like in the sample code below) I am able to return a polygon for my tileRegionGeometry.

let tileRegionLoadOptions = TileRegionLoadOptions(
            geometry: .polygon(Polygon([coordinates])),
            descriptors: [outdoorsDescriptor],
            metadata: ["tag": "my-outdoors-tile-region"],
            acceptExpired: true)!
Tapestes commented 2 years ago

Thanks @ZiZasaurus. I'm declaring as a point. It seems like its grabbing the largest possible area around the point. If that's the case, I'd still want to know how large an area it ended up grabbing. If the size of the area around the point is constant and you could supply that size, then I'm good as I could just infer the area or, as you suggest, grab a specified area. Thanks for the help.