I am trying to get the latidute and the longitude from the URL. My current code:
public void getCoordinate(String city) {
try {
URL current = new URL("https://google.de/maps/place/" + city);
URLConnection currentConnection = current.openConnection();
System.out.println("Current: " + current.toString());
Thread.sleep(180 * 40L);
URL updated = currentConnection.getURL();
System.out.println("Now: " + updated.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
My idea: I call the side with the City i want and after a few seconds, i get the new URL which contains the longitude and the latitude. When i try it manually, i do this steps:
- Insert the URL with the given City
- Wait a few seconds and the URL changes
- Use the new URL to work with it
My problem is, I don't know, how to get the updated URL.