Coder Social home page Coder Social logo

Offline maps about mapbox-xamarin-forms HOT 3 CLOSED

naxam avatar naxam commented on August 11, 2024
Offline maps

from mapbox-xamarin-forms.

Comments (3)

fleuverouge avatar fleuverouge commented on August 11, 2024

Hi @pepobit For now the offline function is only supported in iOS.
To download a map style:

var offlineService = DependencyService.Get<Naxam.Controls.Mapbox.Forms.IOfflineStorageService>();
var region = new OfflinePackRegion()
                {
                    StyleURL = "<your map style url here>",
                    MaximumZoomLevel = 14,
                    MinimumZoomLevel = 1,
                    Bounds = new CoordinateBounds()
                    {
                        NorthEast = new Position()
                        {
                            Lat = 55.800,
                            Long = 9.000
                        },
                        SouthWest = new Position()
                        {
                            Lat = 55.650,
                            Long = 8.700
                        }
                    }
                };
             offlineService.DownloadMap(region, new System.Collections.Generic.Dictionary<string, string>() {
                    {"name", "test"}
                });

To observe download progress:

offlineService.OfflinePackProgressChanged += (sender, e) => {
                var progress = e.OfflinePack.Progress;
                float percentage = 0;
                if (progress.CountOfResourcesExpected > 0)
                {
                    percentage = (float)progress.CountOfResourcesCompleted / progress.CountOfResourcesExpected;
                }
                System.Diagnostics.Debug.WriteLine($"Downloaded resources: {progress.CountOfResourcesCompleted} ({percentage * 100} %)");
                System.Diagnostics.Debug.WriteLine($"Downloaded tiles: {progress.CountOfTilesCompleted}");
                if (progress.CountOfResourcesExpected == progress.CountOfResourcesCompleted) {
                    System.Diagnostics.Debug.WriteLine("Download completed");
                }
            };

To get offline packs:

OfflinePack[] packs = await offlineService.GetPacks();

The first time you get packs, the packs' states may not be correct, since "The state and progress of an inactive or completed pack are computed lazily". So you'll need to call void RequestPackProgress(OfflinePack pack) to observe the packs' states.
For more information please read MapBox's documents about Offline maps and MGLOfflinePack

from mapbox-xamarin-forms.

tuyen-vuduc avatar tuyen-vuduc commented on August 11, 2024

@pepobit I am going to close this issue due to no response from you. If you still get issue, plz reopen.

from mapbox-xamarin-forms.

swapnil591 avatar swapnil591 commented on August 11, 2024

offline map not working in android

from mapbox-xamarin-forms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.