This commit is contained in:
runette committed 2024-04-22 15:52:51 +01:00
commit e0afef912e
1285 files changed
+83219

No files matched your search

@@ -0,0 +1,54 @@
using Mapbox.Json;
using Mapbox.Utils;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mapbox.Platform.TilesetTileJSON
{
public class TileJSON
{
private IFileSource _fileSource;
private int _timeout;
public IFileSource FileSource { get { return _fileSource; } }
public TileJSON(IFileSource fileSource, int timeout)
{
_fileSource = fileSource;
_timeout = timeout;
}
public IAsyncRequest Get(string tilesetName, Action<TileJSONResponse> callback)
{
string url = string.Format(
"{0}v4/{1}.json?secure"
, Constants.BaseAPI
, tilesetName
);
return _fileSource.Request(
url
, (Response response) =>
{
string json = Encoding.UTF8.GetString(response.Data);
TileJSONResponse tileJSONResponse = JsonConvert.DeserializeObject<TileJSONResponse>(json);
if (tileJSONResponse != null)
{
tileJSONResponse.Source = tilesetName;
}
callback(tileJSONResponse);
}
, _timeout
);
}
}
}