如何在我的计算机中将 GTK Champlain 与本地 .osm 磁贴一起使用?

How to use GTK Champlain with local .osm tiles in my computer?

我正在尝试在 python 中制作一个 GPS 应用程序,并且我正在使用 GTK-Champlain 作为一个小部件,同时还使用了 Clutter。但是现在我在尝试使用从 OpenStreetMaps 下载的本地图块文件时遇到问题。看这个:

 class LauncherGTK:

       def __init__(self):
        self.window = Gtk.Window()
        self.window.set_border_width(10)
        self.window.set_title("GPS")
        self.window.connect("destroy", Gtk.main_quit)

        vbox = Gtk.VBox(False, 10)

        embed = GtkChamplain.Embed()

        self.view = embed.get_view()
        self.view.set_reactive(True)
        self.view.connect('button-release-event', self.mouse_click_cb, self.view)

        projector = Champlain.MapProjection.MAP_PROJECTION_MERCATOR
        renderer = Champlain.ImageRenderer()

        map_new = Champlain.FileTileSource.new_full('1','Colombia','OSM','Champlain',10,15,256, projector, renderer)
        map_source = Champlain.FileTileSource.load_map_data(map_new,'Utilidades/map.osm')

        self.view.set_property('kinetic-mode', True)
        self.view.set_property('map-source', map_source)

        #...

        self.window.add(vbox)
        self.window.show_all()

当我尝试 运行 代码时,出现下一个错误:

Traceback (most recent call last): File "GUI.py", line 125, in LauncherGTK() File "GUI.py", line 33, in init projector = Champlain.MapProjection.MAP_PROJECTION_MERCATOR AttributeError: type object 'ChamplainMapProjection' has no attribute 'MAP_PROJECTION_MERCATOR' Press any key to continue . . .

有人知道我做错了什么吗?

基于 PyGObject 的绑定 drop the enum name from the enum values themselves。在您的情况下,您的代码应该使用 Champlain.MapProjection.MERCATOR,而不是 Champlain.MapProjection.MAP_PROJECTION_MERCATOR