B
B
blackCover2021-03-06 14:38:33
Java
blackCover, 2021-03-06 14:38:33

How to specify query parameter "Cyrillic" on OpenWeatherMap?

Hello!
I am writing a weather forecast application. I organized the input of the name of the city through the menu and like this:

private void showInputDialog() {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Change city");
        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_CLASS_TEXT);
        builder.setView(input);
        builder.setPositiveButton("Go", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                getWeather(v, input.getText().toString());
            }
        });
        builder.show();

This design accepts only the Latin alphabet. How to make it so that it can be entered in Cyrillic and whether the open weather map accepts it, otherwise I didn’t find anything about this in the documentation?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Ruslan., 2021-03-06
@LaRN

This API has the ability to set coordinates instead of the city name.
api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}
It is possible to have a localized database of cities with coordinates in the application and call the API always by coordinates, and then the name of the city can be any language to enter.
You can even try not to store the coordinates of cities in the application, but conditionally google by the name of the city or get geolocation from the device on which the application is running.

O
Orkhan, 2021-03-06
Hasanly @azerphoenix

Good afternoon!
Here is what is written in the documentation about the names of cities.

By city name. Input the city name or its part and get the list of the most proper cities in the world. Example - Lon or Lond or London. The more precise city name you put the more precise list you will get. To make it more precise put the city's name or its part, comma, the name of the county or 2-letter country code. You will get all proper cities in chosen county. The order is important - the first is city name than comma than county. Example - Lon, UK or Lon, GB or London, GB or Lon, England. By geographic coordinates.

Accordingly, it does not work with Cyrillic. But you can add such functionality. For example, in the application, enter enum with English. and with Russian names of cities. For example,LONDON ("London", "Лондон")
Organized the input of the name of the city through the menu and this way

For example, I would do not enter the name of the city, but select from a drop-down list. And you never know in what language the user decides to enter the name of the city.

B
Bohdan Yurchuck, 2019-10-08
@Tigermax139

Hello guys, you need to use ssh instead of login login password. And it’s even better not to use Windows, it’s a pity that they don’t say it right away

R
Roman Mirilaczvili, 2017-12-18
@2ord

Is the SSH public key added to the Heroku profile?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question