Skip to content

Commit

Permalink
Allow non-russian routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Feodor0090 committed Jun 26, 2023
1 parent 4c0e162 commit 0c8a9d6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/mahomaps/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ public static void SaveState(MapState ms) {
}
}

/**
* Gets language string for use in API requests.
*/
public static String GetLangString() {
switch (apiLang) {
case 0:
Expand Down
8 changes: 3 additions & 5 deletions src/mahomaps/api/YmapsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ private final String GetRouteUrl(Geopoint a, Geopoint b, int type) {
default:
throw new IllegalArgumentException();
}
String baseUrl = "https://api-maps.yandex.ru/services/route/2.0/?lang=";
String lang = new String(new char[] { baseUrl.charAt(29), baseUrl.charAt(38), '_',
Character.toUpperCase(baseUrl.charAt(29)), 'U' });
return baseUrl + lang + "&token=" + token + "&rll=" + a.lon + "%2C" + a.lat + "~" + b.lon + "%2C" + b.lat
+ "&rtm=dtr&results=1&apikey=" + key + typeS;
return "https://api-maps.yandex.ru/services/route/2.0/?lang=" + Settings.GetLangString() + "&token=" + token
+ "&rll=" + a.lon + "%2C" + a.lat + "~" + b.lon + "%2C" + b.lat + "&rtm=dtr&results=1&apikey=" + key
+ typeS;
}

public final JSONArray Search(String text, Geopoint around, double zone)
Expand Down

0 comments on commit 0c8a9d6

Please sign in to comment.