/// <summary> Builds a forward geocode URL string. </summary> /// <returns> A complete, valid forward geocode URL. </returns> public override string GetUrl() { Dictionary <string, string> opts = new Dictionary <string, string>(); if (this.Autocomplete != null) { opts.Add("autocomplete", this.Autocomplete.ToString().ToLower()); } if (this.Bbox != null) { var nonNullableBbox = (Vector2dBounds)this.Bbox; opts.Add("bbox", nonNullableBbox.ToString()); } if (this.Country != null) { opts.Add("country", ForwardGeocodeResource.GetUrlQueryFromArray <string>(this.Country)); } if (this.Proximity != null) { var nonNullableProx = (Vector2d)this.Proximity; opts.Add("proximity", nonNullableProx.ToString()); } if (this.Types != null) { opts.Add("types", GetUrlQueryFromArray(this.Types)); } return(Constants.BaseAPI + this.ApiEndpoint + this.Mode + Uri.EscapeDataString(this.Query) + ".json" + EncodeQueryString(opts)); }
/// <summary> Builds a forward geocode URL string. </summary> /// <returns> A complete, valid forward geocode URL. </returns> public override string GetUrl() { Dictionary <string, string> opts = new Dictionary <string, string>(); if (this.Autocomplete != null) { opts.Add("autocomplete", this.Autocomplete.ToString().ToLower()); } if (this.Bbox != null) { var nonNullableBbox = (Vector2dBounds)this.Bbox; opts.Add("bbox", nonNullableBbox.ToString()); } if (this.Country != null) { opts.Add("country", ForwardGeocodeResource.GetUrlQueryFromArray <string>(this.Country)); } if (this.Proximity != null) { var nonNullableProx = (Vector2d)this.Proximity; opts.Add("proximity", nonNullableProx.ToString()); } if (this.Types != null) { opts.Add("types", GetUrlQueryFromArray(this.Types)); } // !!!!!!!!!! HACK !!!!!!! // we are seeing super weird behaviour on some iOS devices: // crashes with properly escaped whitespaces %20 and commas %2C - and other special characters // 'NSAllowsArbitraryLoads' and 'NSURLConnection finished with error - code - 1002' // Use 'CFNETWORK_DIAGNOSTICS=1' in XCode to get more details https://stackoverflow.com/a/46748461 // trying to get rid of at least the most common characters - other will still crash #if UNITY_IOS Query = Query .Replace(",", " ") .Replace(".", " ") .Replace("-", " "); #endif return (Constants.BaseAPI + ApiEndpoint + Mode + #if UNITY_IOS WWW.EscapeURL(Query) + #else Uri.EscapeDataString(Query) + #endif ".json" + EncodeQueryString(opts)); }