private static bool ValidateMapSession(MapLocationOptions mapLocationOptions) { if (mapLocationOptions.MapSession == null) { Debug.LogError("MapLocationFinder request failed: MapSession is not present."); return(false); } if (string.IsNullOrWhiteSpace(mapLocationOptions.MapSession.DeveloperKey)) { Debug.LogError("MapLocationFinder request failed: MapSession has missing developer key."); return(false); } return(true); }
/// <summary> /// Forms and sends a geocoding request to retrieve location infromation for the provided address query. /// The specified reference location helps improve the result's relevance. /// </summary> public async static Task <MapLocationFinderResult> FindLocations( string query, LatLon referenceLocation, MapLocationOptions mapLocationOptions = null) { var mapLocationOptionsForRequest = mapLocationOptions ?? new MapLocationOptions(); if (!ValidateMapSession(mapLocationOptionsForRequest)) { return(new MapLocationFinderResult(MapLocationFinderStatus.InvalidCredentials)); } var url = await BuildUrl($"q={query}", mapLocationOptions ?? new MapLocationOptions()).ConfigureAwait(true); url += FormattableString.Invariant($"&ul={referenceLocation.LatitudeInDegrees},{referenceLocation.LongitudeInDegrees}"); return(await Request(url).ConfigureAwait(true)); }
/// <summary> /// Forms and sends a geocoding request to retrieve location infromation for the provided address query. /// The specified GeoBoundingBox helps improve the result's relevance. /// </summary> public async static Task <MapLocationFinderResult> FindLocations( string query, GeoBoundingBox referenceBoundingBox, MapLocationOptions mapLocationOptions = null) { var mapLocationOptionsForRequest = mapLocationOptions ?? new MapLocationOptions(); if (!ValidateMapSession(mapLocationOptionsForRequest)) { return(new MapLocationFinderResult(MapLocationFinderStatus.InvalidCredentials)); } var url = await BuildUrl($"q={query}", mapLocationOptionsForRequest).ConfigureAwait(true); url += $"&umv={referenceBoundingBox.BottomLeft.LatitudeInDegrees},{referenceBoundingBox.BottomLeft.LongitudeInDegrees},{referenceBoundingBox.TopRight.LatitudeInDegrees},{referenceBoundingBox.TopRight.LongitudeInDegrees}"; return(await Request(url).ConfigureAwait(true)); }
/// <summary> /// Forms and sends a reverse geocoding request by location. /// </summary> public static async Task <MapLocationFinderResult> FindLocationsAt(LatLon location, MapLocationOptions mapLocationOptions = null) { var mapLocationOptionsForRequest = mapLocationOptions ?? new MapLocationOptions(); if (!ValidateMapSession(mapLocationOptionsForRequest)) { return(new MapLocationFinderResult(MapLocationFinderStatus.InvalidCredentials)); } var url = await BuildUrl( string.Empty, mapLocationOptions ?? new MapLocationOptions(), FormattableString.Invariant($"Locations/{location.LatitudeInDegrees},{location.LongitudeInDegrees}"), false) .ConfigureAwait(true); return(await Request(url).ConfigureAwait(true)); }
/// <summary> /// Forms and sends a geocoding request to retrieve location infromation for the provided address query. /// </summary> public async static Task <MapLocationFinderResult> FindLocations(string query, MapLocationOptions mapLocationOptions = null) { var mapLocationOptionsForRequest = mapLocationOptions ?? new MapLocationOptions(); if (!ValidateMapSession(mapLocationOptionsForRequest)) { return(new MapLocationFinderResult(MapLocationFinderStatus.InvalidCredentials)); } var url = await BuildUrl($"q={query}", mapLocationOptions ?? new MapLocationOptions()).ConfigureAwait(true); return(await Request(url).ConfigureAwait(true)); }
/// <summary> /// Forms and sends a reverse geocoding request by location. /// </summary> public static async Task <MapLocationFinderResult> FindLocationsAt(LatLon location, MapLocationOptions mapLocationOptions = null) { var url = BuildUrl("", mapLocationOptions, $"Locations/{location.LatitudeInDegrees},{location.LongitudeInDegrees}", false); return(await Request(url)); }
/// <summary> /// Forms and sends a geocoding request to retrieve location infromation for the provided address query. /// </summary> public async static Task <MapLocationFinderResult> FindLocations(string query, MapLocationOptions mapLocationOptions = null) { var url = BuildUrl($"q={query}", mapLocationOptions); return(await Request(url)); }