def setup_marker(self): layer = champlain.Layer() self.view.add_layer(layer) #Set up and position sprite actor = clutter.Texture(filename="pirate-ship-1.jpg") marker = champlain.marker_new_with_image(actor) marker.set_draw_background(False) marker.set_position(0,0) layer.add(marker) marker.raise_top() return marker
def image_download_cb(data, layer, latitude, longitude, url): if not data: return pixbuf = pixbuf_new_from_data(data) if not pixbuf: print "Failed to convert %s into an image" % url # Then transform the pixbuf into a texture texture = texture_new_from_pixbuf(pixbuf) if not texture: print "Failed to convert %s into an texture" % url # Finally create a marker with the texture marker = champlain.marker_new_with_image(texture) marker.set_position(latitude, longitude) layer.add(marker) marker.show_all()
def __init__(self): global location global talker global loading global track global marker global auto_center talker = testtalker.TestTalker("data/gps2.out", 0) talker.runLoop() auto_center = True loading = True track = [] #where I've been self.window = gtk.Window() self.window.set_border_width(10) self.window.set_title("Shortqut v0.5a") self.window.connect("destroy", lambda x: self.cleanup()) vbox = gtk.VBox(False, 12) champ = champlaingtk.ChamplainEmbed() champ.set_size_request(640,480) self.view = champ.get_view() self.view.set_reactive(True) self.view.connect('button-release-event', self.mouse_click_cb, self.view) self.view.set_property('scroll-mode', champlain.SCROLL_MODE_KINETIC) self.view.set_property('zoom-level', 15) self.view.set_property('license-text', ".") self.view.set_property('show-scale', True) layer = champlain.Layer() self.view.add_layer(layer) self.map_source_factory = champlain.map_source_factory_dup_default() self.map_data_source = None self.load_memphis_rules() self.load_osm_file() #Add the image ''' bboxTitle = gtk.HBox(False, 6) image = gtk.Image() image.set_from_file("Shortqut_banner.jpg") bboxTitle.add(image) image.show() vbox.pack_start(bboxTitle, expand = False, fill = False) ''' #Add the buttons bbox = gtk.HBox(False, 6) #Add the label self.label = gtk.Label("Loading OSM File") bbox.add(self.label) center_check = gtk.CheckButton("Centered") center_check.set_active(True) center_check.connect("clicked", self.toggle_auto_centered) bbox.add(center_check) button = gtk.Button(stock=gtk.STOCK_ZOOM_IN) button.connect("clicked", self.zoom_in) bbox.add(button) button = gtk.Button(stock=gtk.STOCK_ZOOM_OUT) button.connect("clicked", self.zoom_out) bbox.add(button) self.spinbutton = gtk.SpinButton(gtk.Adjustment(lower=0, upper=20, value=1, step_incr=1)) self.spinbutton.connect("changed", self.zoom_changed) self.view.connect("notify::zoom-level", self.map_zoom_changed) self.spinbutton.set_value(15) bbox.add(self.spinbutton) button = gtk.Image() self.view.connect("notify::state", self.view_state_changed, button) bbox.pack_end(button, False, False, 0) vbox.pack_start(bbox, expand=False, fill=False) vbox.add(champ) self.window.add(vbox) self.window.show_all() #lat = 28.568542 + (random.random() - 0.5) #lon = -81.207504 + (random.random() - 0.5) lat = 28.541492 lon = -81.195965 self.view.center_on(lat,lon) #Set up and position sprite actor = clutter.Texture(filename="pirate-ship-1.jpg") marker = champlain.marker_new_with_image(actor) marker.set_draw_background(False) #marker.set_position(0,0) marker.set_position(lat,lon) layer.add(marker) marker.raise_top() self.draw_route(gpsfiletoroute("data/gps2.out")) location = talker.getMsg() #gobject.timeout_add(1000, random_view, self.view) gobject.timeout_add(500, center_gps, self.view, location) gobject.timeout_add(1000, is_loaded, self.view, self.label)