I've been trying to create an app that uses driving navigation, but when trying to find how to get from one point to another (defined with latitude and longitude) using osmnx pathfinding, it looks like I can't display the actual route. Here's the code I am using:
import osmnx
G = ox.graph_from_place("New York, New York", network_type='drive')
# Latitude and longitude for origin and destination
origin_lat, origin_lon = 40.73765090370579, -73.97428265598312
destination_lat, destination_lon = 40.72568284052202, -74.01119033844985
#Then I find the nearest nodes
origin_node = ox.nearest_nodes(G, X=origin_lat, Y=origin_lon)
destination_node = ox.nearest_nodes(G, X=destination_lat, Y=destination_lon)
R = ox.shortest_path(G, origin_node, destination_node, weight='length')
fig, ax = ox.plot_graph_route(G, R, route_color="r", route_linewidth=6, node_size=0)
To my knowledge, I think this is supposed to use matplotlib to show the route (based on many tutorials and help from AI), and when I run it, the map does pop up, but there is no route shown in red. The individual points of latitude and longitude aren't shown either. I want to integrate this into kivy mapview as a part of the UI. Eventually, I'd want to be able to search through the entire route to check for major cities/towns along the way (A functionality of the app I want to make). Additionally, I'd like to make the origin latitude and longitude based on GPS, but that only works well with plyer on android/ios, and although I wouldn't mind converting it to android (using buildozer because it's kivy and I'm using WSL because I'm on Windows), I've had a bunch of trouble trying to convert it, everything from NDK and SDK problems to problems with missing modules to just a bunch of random other problems (I'm a beginner at this so I've been using AI to help me but haven't gotten very far). I'd also rather not use a VM to simulate a Linux OS. I've been debating using geocoding to get a rough idea of the location but then it would be much harder to find a route to the destination and a core functionality of the app is using that route to determine the cities you will pass through. Any ideas/suggestions/solutions would be greatly appreciated!
It is because you swapped your x and y coordinates in the nearest nodes search. X should be longitude and Y should be latitude. You did the opposite.
This is noted in the function's documentation.