Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetPositionByKeywords doesn't work anymore #209

Open
Triskh opened this issue Jun 20, 2024 · 4 comments
Open

SetPositionByKeywords doesn't work anymore #209

Triskh opened this issue Jun 20, 2024 · 4 comments

Comments

@Triskh
Copy link

Triskh commented Jun 20, 2024

I have an programm that set's the map position with keywords, but since a few days this doesn't work anymore. The map itself works normaly and the position can be set with coordinates. As mapprovider i use openstreetmap.

Has anyone the same problem or has anyone an idea to fix this problem?

@salbertsCAD
Copy link

I don't think we use this particular method, but we do use the GetPositionByKeywords method. And I think we're having the same problem. Debugging session shows that a web request to get the location information from the keywords, returns a 403 Forbidden. Hopefully this will be fixed soon!

@jonas-medCrew
Copy link

Same here on GetPositionByKeywords using OpenStreetMap. Does anyone know a workaround?

@jonas-medCrew
Copy link

jonas-medCrew commented Jun 27, 2024

Error seems to appear on request to hhtps://nominatim.openstreetmap.org/search...
I Fixed it by doing the request myself in helperclass to get the coordinates of an address or searchstring.

Solution looks like this:
`private static HttpClient _client;

static MapHelper()
{
_client = new HttpClient()
{
BaseAddress = new Uri("https://nominatim.openstreetmap.org/"),
};
_client.DefaultRequestHeaders.Add("User-Agent", "");
}

public static async Task GetPointFromUrl(string keys)
{
try
{
string text = await _client.GetStringAsync($"search?q={keys.Replace(" ", "+")}&format=json");
var list = JsonConvert.DeserializeObject<List>(text);
if (list?.Count > 0)
{
return new PointLatLng(list.First().lat, list.First().lon);
}
}
catch (Exception ex)
{
Debug.WriteLine($"Error: {ex.Message}");
}
return default;
}
`

Without setting UserAgent header the request will result in 403 forbidden.

Hope it helps.

A Fix of this issue would be really nice anyways

@salbertsCAD
Copy link

Can confirm jonas' solution worked for us too. Thank you for sharing your solution! Shame it has to come to manual workarounds, hopefully they will fix it on their side soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants