Skip to content

Commit

Permalink
Fixed compilation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
clm-unifly committed May 17, 2024
1 parent 338f288 commit 06a25aa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,58 @@ public class OfflineManagerExample : ContentPage, IExamplePage, IQueryAttributab
float tokyoZoom = 12;
IOfflineManager offlineManager;

public OfflineManagerExample()
public OfflineManagerExample()
{
iOSPage.SetUseSafeArea(this, false);
iOSPage.SetUseSafeArea(this, false);
Content = map = new MapboxView();
tokyoCoord = new Point(35.682027, 139.769305);

map.MapReady += Map_MapReady;
map.MapReady += Map_MapReady;
}

private void Map_MapReady(object sender, EventArgs e)
{
var cameraOptions = new CameraOptions
var cameraOptions = new CameraOptions
{
Center = tokyoCoord,
Zoom = tokyoZoom,
Center = tokyoCoord,
Zoom = tokyoZoom,
};
map.CameraOptions = cameraOptions;
map.MapboxStyle = MapboxStyle.OUTDOORS;

offlineManager = new OfflineManager(
MauiProgram.ACCESS_TOKEN,
MauiProgram.AccessToken,
cameraOptions);

offlineManager.IsMapboxStackConnected = true;

offlineManager.DownloadStyle(
MapboxStyle.OUTDOORS.Value,
new StylePackLoadOptions
new StylePackLoadOptions
{
Mode = GlyphsRasterizationMode.IdeographsRasterizedLocally,
Metadata = new Dictionary<string, object>
{
{ @"tag", @"my-outdoors-style-pack" }
}
Mode = GlyphsRasterizationMode.IdeographsRasterizedLocally,
Metadata = new Dictionary<string, object>
{
{ @"tag", @"my-outdoors-style-pack" }
}
},
(progress) =>
(progress) =>
{
System.Diagnostics.Debug.WriteLine($"PROGRESS:DownloadStyle {
progress.CompletedResourceCount}/{
progress.RequiredResourceCount}");
System.Diagnostics.Debug.WriteLine($"PROGRESS:DownloadStyle {
progress.CompletedResourceCount}/{
progress.RequiredResourceCount}");
},
(stylePack, exception) =>
(stylePack, exception) =>
{
if (exception != null)
{
System.Diagnostics.Debug.WriteLine($"ERR:DownloadStyle {exception.Message}");
return;
if (exception != null)
{
System.Diagnostics.Debug.WriteLine($"ERR:DownloadStyle {exception.Message}");
return;
}
System.Diagnostics.Debug.WriteLine($"DONE:DownloadStyle {
stylePack.CompletedResourceCount}/{
stylePack.RequiredResourceCount}");
System.Diagnostics.Debug.WriteLine($"DONE:DownloadStyle {
stylePack.CompletedResourceCount}/{
stylePack.RequiredResourceCount}");
});

var tilesetDescriptorOptions = new TilesetDescriptorOptions(
Expand All @@ -76,31 +76,31 @@ private void Map_MapReady(object sender, EventArgs e)
TilesetDescriptors: new [] { tilesetDescriptorOptions },
AcceptsExpired: true,
NetworkRestriction: NetworkRestriction.None,
Metadata: new Dictionary<string, object>
{
{ @"tag", @"my-outdoors-tile-region" }
Metadata: new Dictionary<string, object>
{
{ @"tag", @"my-outdoors-tile-region" }
});

offlineManager.DownloadTile(
tileRegionId,
tileRegionLoadOptions,
progress =>
progress =>
{
System.Diagnostics.Debug.WriteLine($"PROGRESS:DownloadTile {
progress.CompletedResourceCount}/{
progress.RequiredResourceCount}");
System.Diagnostics.Debug.WriteLine($"PROGRESS:DownloadTile {
progress.CompletedResourceCount}/{
progress.RequiredResourceCount}");
},
(tileRegion, exception) =>
(tileRegion, exception) =>
{
if (exception != null)
{
System.Diagnostics.Debug.WriteLine($"ERR:DownloadTile {exception.Message}");
return;
if (exception != null)
{
System.Diagnostics.Debug.WriteLine($"ERR:DownloadTile {exception.Message}");
return;
}
System.Diagnostics.Debug.WriteLine($"DONE:DownloadTile {
tileRegion.CompletedResourceCount}/{
tileRegion.RequiredResourceCount}");
System.Diagnostics.Debug.WriteLine($"DONE:DownloadTile {
tileRegion.CompletedResourceCount}/{
tileRegion.RequiredResourceCount}");
});
}

Expand Down
4 changes: 3 additions & 1 deletion src/qs/MapboxMauiQs/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ namespace MapboxMauiQs;

public static partial class MauiProgram
{
public static string AccessToken => throw new Exception("[your token]");

public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMapbox(ACCESS_TOKEN)
.UseMapbox(AccessToken)
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand Down

0 comments on commit 06a25aa

Please sign in to comment.