Exemple #1
0
        internal void Initialize(IFileSource fileSource, CanonicalTileId canonicalTileId, string mapId, Action p)
        {
            Cancel();

            _state    = State.Loading;
            _id       = canonicalTileId;
            _callback = p;
            _request  = fileSource.Request(MakeTileResource(mapId).GetUrl(), HandleTileResponse, tileId: _id, mapId: mapId);
        }
Exemple #2
0
        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);
                callback(tileJSONResponse);
            }
                       , _timeout
                       ));
        }
Exemple #3
0
        /// <summary> Performs asynchronously a geocoding lookup. </summary>
        /// <param name="geocode"> Geocode resource. </param>
        /// <param name="callback"> Callback to be called after the request is completed. </param>
        /// <typeparam name="T"> String or LngLat. Should be automatically inferred. </typeparam>
        /// <returns>
        ///     Returns a <see cref="IAsyncRequest" /> that can be used for canceling a pending
        ///     request. This handle can be completely ignored if there is no intention of ever
        ///     canceling the request.
        /// </returns>
        public IAsyncRequest Match(MapMatchingResource match, Action <MapMatchingResponse> callback)
        {
            string url = match.GetUrl();

            return(_fileSource.Request(
                       url,
                       (Response response) =>
            {
                var str = Encoding.UTF8.GetString(response.Data);
                var data = Deserialize <MapMatchingResponse>(str);

                if (response.HasError)
                {
                    data.SetRequestExceptions(response.Exceptions);
                }

                callback(data);
            },
                       _timeout
                       ));
        }