You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1015 B
54 lines
1015 B
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
|
|
);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|