Skip to content

Commit

Permalink
Set custom map source
Browse files Browse the repository at this point in the history
  • Loading branch information
phako committed May 3, 2018
1 parent 66cbf91 commit c315ce7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion meson.build
Expand Up @@ -56,7 +56,7 @@ gexiv2 = dependency('gexiv2', version: '>= 0.10.4')
libraw = dependency('libraw', version : '>= 0.13.2')
libexif = dependency('libexif', version : '>= 0.6.16')
unity = dependency('unity', required : false)
champlain = dependency('champlain-0.12')
champlain = dependency('champlain-0.12', version: '>= 0.12.16')
champlain_gtk = dependency('champlain-gtk-0.12')
clutter = dependency('clutter-1.0')
clutter_gtk = dependency('clutter-gtk-1.0')
Expand Down
24 changes: 24 additions & 0 deletions src/MapWidget.vala
Expand Up @@ -581,9 +581,33 @@ private class MapWidget : Gtk.Bin {
marker_group_raster.regroup();
}

private Champlain.MapSource create_map_source() {
var map_source = new Champlain.MapSourceChain();
var file_cache = new Champlain.FileCache.full(10 * 1024 * 1024,
AppDirs.get_cache_dir().get_child("tiles").get_path(), new Champlain.ImageRenderer());
var memory_cache = new Champlain.MemoryCache.full(10 * 1024 * 1024, new Champlain.ImageRenderer());
var error_source = new Champlain.NullTileSource.full(new Champlain.ImageRenderer());
var osm = Champlain.MapSourceFactory.dup_default().create(Champlain.MAP_SOURCE_OSM_MAPNIK);
var user_agent = "Shotwell/%s libchamplain/%s".printf(_VERSION, Champlain.VERSION_S);
if (osm is Champlain.NetworkTileSource) {
(osm as Champlain.NetworkTileSource).set_user_agent(user_agent);
(osm as Champlain.NetworkTileSource).max_conns = 2;
} else if (osm is Champlain.NetworkBboxTileSource) {
(osm as Champlain.NetworkBboxTileSource).set_user_agent(user_agent);
}

map_source.push(error_source);
map_source.push(osm);
map_source.push(file_cache);
map_source.push(memory_cache);

return map_source;
}

private void setup_map() {
map_view = gtk_champlain_widget.get_view();
map_view.add_layer(marker_layer);
map_view.set_map_source(create_map_source());

// add lock/unlock button to top left corner of map
map_edit_lock_button.content_gravity = Clutter.ContentGravity.TOP_RIGHT;
Expand Down

0 comments on commit c315ce7

Please sign in to comment.