Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion data/atlas.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<gresources>
<gresource prefix="/com/github/ryonakano/atlas/icons">
<file compressed="true" preprocess="xml-stripblanks" alias="pointer.svg">icons/pointer.svg</file>
<file compressed="true" preprocess="xml-stripblanks" alias="location.svg">icons/location.svg</file>
</gresource>
</gresources>
121 changes: 0 additions & 121 deletions data/icons/location.svg

This file was deleted.

53 changes: 47 additions & 6 deletions src/MapWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ public class Atlas.MapWidget : Gtk.Box {

private Shumate.SimpleMap map_widget;
private Shumate.Map base_map;
// Displays the "pin" icon at a specified place by search
private Shumate.MarkerLayer pin_layer;
// Displays the position of current location
private Shumate.MarkerLayer location_layer;

private GClue.Location? location = null;

private MarkerLayerManager manager;
private bool is_watching_location = false;

// The Royal Observatory
Expand All @@ -40,7 +44,11 @@ public class Atlas.MapWidget : Gtk.Box {
}

public void init_marker_layers () {
manager = new MarkerLayerManager (map_widget);
pin_layer = new Shumate.MarkerLayer (map_widget.viewport);
map_widget.add_overlay_layer (pin_layer);

location_layer = new Shumate.MarkerLayer (map_widget.viewport);
map_widget.add_overlay_layer (location_layer);
}

// Set the initial location of the map widget.
Expand Down Expand Up @@ -101,8 +109,8 @@ public class Atlas.MapWidget : Gtk.Box {
this.location.longitude = lng;
}

manager.clear_markers (MarkerType.LOCATION);
manager.new_marker_at_pos (MarkerType.LOCATION, lat, lng);
clear_location ();
mark_location_at (lat, lng);
}

// Inspired from https://gitlab.gnome.org/GNOME/gnome-clocks/blob/master/src/geocoding.vala
Expand Down Expand Up @@ -130,8 +138,8 @@ public class Atlas.MapWidget : Gtk.Box {
public void go_to_place (Geocode.Place place) {
Geocode.Location loc = place.location;

manager.clear_markers (MarkerType.POINTER);
manager.new_marker_at_pos (MarkerType.POINTER, loc.latitude, loc.longitude);
clear_pin ();
mark_pin_at (loc.latitude, loc.longitude);
base_map.go_to (loc.latitude, loc.longitude);
}

Expand All @@ -141,4 +149,37 @@ public class Atlas.MapWidget : Gtk.Box {
Atlas.Application.settings.set_double ("longitude", base_map.viewport.longitude);
Atlas.Application.settings.set_double ("zoom-level", base_map.viewport.zoom_level);
}

private void clear_location () {
location_layer.remove_all ();
}

private void clear_pin () {
pin_layer.remove_all ();
}

private void mark_location_at (double latitude, double longitude) {
var marker = new Shumate.Point () {
latitude = latitude,
longitude = longitude,
selectable = true
};

location_layer.add_marker (marker);
}

private void mark_pin_at (double latitude, double longitude) {
var image = new Gtk.Image.from_icon_name ("pointer") {
icon_size = Gtk.IconSize.LARGE
};

var marker = new Shumate.Marker () {
latitude = latitude,
longitude = longitude,
child = image,
selectable = true
};

pin_layer.add_marker (marker);
}
}
67 changes: 0 additions & 67 deletions src/MarkerLayerManager.vala

This file was deleted.

1 change: 0 additions & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ sources = files(
'Define.vala',
'MainWindow.vala',
'MapWidget.vala',
'MarkerLayerManager.vala',
'Util.vala',
)

Expand Down