如何在我的计算机中使用GTK Champlain和local.osm tiles?

2024-09-28 22:21:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试用python制作一个GPS应用程序,并使用GTK Champlain作为一个小部件,同时使用clart。但是现在我在使用从OpenStreetMaps下载的本地tiles文件时遇到了问题。注意这个:

 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 . . .

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


Tags: selfviewmapsourcegtknewwindowgps