I am trying to create a geospatial Python GUI app using PyQT5, Geopandas, OSMnX, and Folium. I am converting the app into an .EXE file using pyinstaller. The app looks something like this:

enter image description here

I am using GTFS data as well as User-Generated Suggestions data containing user start and end coordinates to display all the bus stops closest for the users within a specified buffer distance. I am also displaying the top 10 most recommended routes between the starting the destination bus stops. I am able to display all of these elements (Markers, Circle Ranges, Circle markers, routes) on the folium element in my PyQT5 GUI app. But when I try to add the tooltip attribute which specifies the number of users who use the route into the code, The map is not displaying anything anymore in the GUI app, it remains the same. But at the same time, If I save the HTML of the folium map, it displays all the elements, as shown below:

enter image description here

The code for initializing and displaying the map on the QTWebEngineWidget is

        recoMap = folium.Map(location=[25.2048, 55.2708], zoom_start=10)
        data = io.BytesIO()
        recoMap.save(data, close_file=False)

And the code for adding tooltip and plotting route is given as:

            for ind, freq_route in freq_route_list[:10].iterrows():
                # try:
                origin = [freq_route['stop_lat_A'],freq_route['stop_lon_A']]# oakland, san pablo & market
                destination = [freq_route['stop_lat_B'], freq_route['stop_lon_B']]  # berkeley, sacramento & university

                from_node = ox.distance.nearest_nodes(self.model.Gdrive, origin[1], origin[0])
                to_node = ox.distance.nearest_nodes(self.model.Gdrive, destination[1], destination[0])

                route = ox.distance.shortest_path(self.model.Gdrive, from_node, to_node, weight='length')
                route_list += route
                tooltp = 'Start Point: ' + str(freq_route['stop_name_A']) + ' <br>Destination Point: ' + str(freq_route['stop_name_B']) + '<br>Recommended Count: ' + str(freq_route['Count'])
                # print(ind)
                if ind == 0:
                    reco_map = ox.plot_route_folium(self.model.Gdrive, route, weight=5,tooltip=tooltp)
                    reco_map = ox.plot_route_folium(self.model.Gdrive, route, route_map=reco_map, weight=5, tooltip=tooltp)

Can anyone tell me what I am doing wrong and help me find a way to update my folium map in my PyQT app?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.