def search_completed(self, entry, model, itr): """Go to the selected location.""" self.last_search = itr.copy() MapView.emit('realize') MapView.set_zoom_level(MapView.get_max_zoom_level()) Widgets.redraw_interface() MapView.center_on(*model.get(itr, LATITUDE, LONGITUDE)) MapView.set_zoom_level(11)
def go_back(*ignore): """Return the map view to where the user last set it.""" history = list(Gst.get('history')) lat, lon, zoom = history.pop() if valid_coords(lat, lon): MapView.set_zoom_level(zoom) MapView.center_on(lat, lon) if len(history) > 1: Gst.set_history(history) else: Gst.reset('history')
def move_by_arrow_keys(accel_group, acceleratable, keyval, modifier): """Move the map view by 5% of its length in the given direction.""" key = Gdk.keyval_name(keyval) factor = 0.45 if key in ('Up', 'Left') else 0.55 if key in ('Up', 'Down'): lat = MapView.y_to_latitude(MapView.get_height() * factor) lon = MapView.get_center_longitude() else: lat = MapView.get_center_latitude() lon = MapView.x_to_longitude(MapView.get_width() * factor) if valid_coords(lat, lon): MapView.center_on(lat, lon)