I am making desktop app in Python (3.8.10) using QML frontend (Qt 6.4.1)
The principle is that I take data from a CSV file and load it into a pandas dataframe. The data contains coordinates that I want to display on a map using the folium library. Since I also want to display all the data, which can have thousands of records, I need to use clusters (folium.plugins.FasterMarkerCluster) https://deparkes.co.uk/2016/06/24/folium-marker-clusters/
I create a map instance in a python class, insert points and create clusters
@staticmethod
def add_all_crime_types(map: MapObject, df: pd.DataFrame) -> None:
# Removing duplicates
df_filtered = df.drop_duplicates(subset='id', keep='first')
# Adding points to MarkerClusters and then adding MarkerClusters to the map
folium.plugins.FastMarkerCluster(data=list(zip(df_filtered['x'], df_filtered['y'])), callback=DEFAULT_CALLBACK).add_to(map.m)
Then I convert the map instance into a string and send it to the frontend, where I load it using the webView.loadHTML(string) method
Item {
id: item_showMap
Connections {
target: backend
function onGetHTML(html) { webView.loadHtml(html) }
}
Rectangle {
id: rectangle
color: "#d4d4d4"
anchors.fill: parent
anchors.rightMargin: -320
anchors.bottomMargin: 0
anchors.leftMargin: -320
anchors.topMargin: 1
WebEngineView {
id: webView
anchors.fill: parent
}
Component.onCompleted: backend.create_default_map()
}
}
Unfortunately, despite using clusters, performance is very poor, especially when scrolling. It is possible that hardware acceleration is disabled? Or some other feature? Maybe If there is another, more performance friendly, way to render the points.
I have tried another marker styling, using marker clusters and faster marker clusters.