0

I am trying to write a sort of map app. The app should show the map of a building and show places of interest with a marker. If you were to then click on the marker you would see some information about that specific place on the map. I am trying to make this app with Kivy and MapView seems great for what I am trying to accomplish, since the scrolling around the map and showing the map markers are necessary for what I want. However, I can't seem to manage to use my locally stored custom map (which is a .png image) as a map shown with MapView.

At first I tried to just change the map source in the kv file by typing: map_source: 'custom_map.png (since the map is stored in the same folder as the python and kv files). This results in a KeyError since 'custom_map.png' is not in the list of maps from Kivy. So I then looked at the documentation (https://kivy-garden.github.io/mapview/usage.html) which said that the map providers can be changed in one of two ways, where one way seems to be for implementing your own map. The code shown in the documentation is as follows:

source = MapSource(url="http://my-custom-map.source.com/{z}/{x}/{y}.png",
                   cache_key="my-custom-map", tile_size=512,
                   image_ext="png", attribution="@ Myself")
map.map_source = source

However, I can't get this to work when I try to replace the url with the file path. If I do so in the python file and nothing in particular in the kv file, it still shows the regular MapView Map ('oms' I believe). When I try to put this code in my kv file, it says that MapSource is not defined.

I also tried some codes from chat gpt and bing, but neither of them worked. They generally implement a custom map class in the python code, but then it either still shows the MapView map, shows a blank screen or a black screen.

Any help with this is greatly appreciated, or if someone knows how to achieve the same functionality (so the scrolling, zooming and marker buttons on specific places on the map rather than on the screen) I would also love to know it!

(As for now I only have the regular MapView, in case it might be of importance:

from kivy.uix.screenmanager import ScreenManager, Screen
from kivy_garden.mapview import MapView

class HuidigeWeekWindow(Screen):    
    def build(self):
        mapview = MapView()
        return mapview

And in the kv file:

<VolgendeWeekWindow>:
    name: "volgende"
    MapView:
        size_hint: 1, 0.902

Timon
  • 11
  • 1

0 Answers0