After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 769559 - Include mapbox as tile source?
Include mapbox as tile source?
Status: RESOLVED OBSOLETE
Product: libchamplain
Classification: Core
Component: view
unspecified
Other Linux
: Normal normal
: ---
Assigned To: libchamplain-maint
libchamplain-maint
Depends on:
Blocks:
 
 
Reported: 2016-08-05 14:11 UTC by Mike Cornelison
Modified: 2018-05-22 13:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Mike Cornelison 2016-08-05 14:11:42 UTC
I changed Fotoxx libchamplain interface from OSM to mapnik but the maps are not as good. Is there a plan to include mapbox as a libchamplain tile source? If there is a license issue, how about a way to provide libchamplain with a license key?
Comment 1 Mattias Bengtsson 2016-08-05 14:18:28 UTC
I lean towards not doing this, since we'd need to keep libchamplain updated with regards to new versions of mapbox's tilesets.

Just do something like this instead: 
https://git.gnome.org/browse/gnome-maps/tree/src/mapSource.js#n45
Comment 2 Mattias Bengtsson 2016-08-05 14:18:45 UTC
In the end it's up to Jiri though. :)
Comment 3 Jiri Techet 2016-08-09 21:53:02 UTC
I'd probably prefer having only map sources in libchamplain that work without any additional configuration (at the moment we don't have any mechanism to add e.g. the access token parameter to a factory tile source).

However, it's really easy to create a custom tile source - I've just added a new sample to libchamplain demonstrating this. It uses the same caching which is used for the factory sources and everything should work the same way as if it was part of libchamplain. You can find it here:

https://git.gnome.org/browse/libchamplain/tree/demos/mapbox.py

You only need to provide the ACCESS_TOKEN value and everything should work.
Comment 4 Jiri Techet 2016-08-09 22:03:50 UTC
If you want to do the same in C, this:

https://git.gnome.org/browse/libchamplain/tree/champlain/champlain-map-source-factory.c#n456

might help you. Let me know if you need some help.
Comment 5 Mike Cornelison 2016-08-18 17:50:04 UTC
(Jiri Techet)
 
Here is what I ended up doing with mapbox, and it seems to be working fine.
(I don't fully understand this API - just enough to get it working).

Thanks for your help. The application is fotoxx in case you want to know.
 
One problem remains: place names are in the local language (e.g. Chinese characters)
(the same issue I had with mapnik). Do you have an easy fix?
If not, I will spend more time on the mapbox developer pages to see if this can be customized.
Gnome maps does not have this problem. Also using mapbox?


//-------------------------------------------------------------------------------

   #define LICENSE_TEXT ""
   #define LICENSE_URI "https://www.mapbox.com/tos/"
   #define ACCESS_TOKEN "pk.***************"
   #define URI "https://a.tiles.mapbox.com/v4/mapbox.streets/#Z#/#X#/#Y#.png?access_token=" ACCESS_TOKEN
   #define FILE_CACHE 200000000     /* MB */
   #define MEMORY_CACHE 200         /* tiles */

   ChamplainMapSourceFactory   *map_factory;
   ChamplainRenderer           *renderer;
   ChamplainMapSource          *error_source;
   ChamplainNetworkTileSource  *tile_source;
   ChamplainFileCache          *file_cache;
   ChamplainMemoryCache        *memory_cache;
   ChamplainMapSourceChain     *source_chain;

   renderer = CHAMPLAIN_RENDERER(champlain_image_renderer_new());

   map_factory = champlain_map_source_factory_dup_default();
   
   tile_source = champlain_network_tile_source_new_full (
         "mapbox", "mapbox", LICENSE_TEXT, LICENSE_URI, 0, 19, 256,
         CHAMPLAIN_MAP_PROJECTION_MERCATOR, URI, renderer);
   
   error_source = champlain_map_source_factory_create_error_source(map_factory,256);
   file_cache = champlain_file_cache_new_full(FILE_CACHE, null, renderer);
   memory_cache = champlain_memory_cache_new_full(MEMORY_CACHE, renderer);

   source_chain = champlain_map_source_chain_new();
   champlain_map_source_chain_push(source_chain, error_source);
   champlain_map_source_chain_push(source_chain, CHAMPLAIN_MAP_SOURCE(tile_source));
   champlain_map_source_chain_push(source_chain, CHAMPLAIN_MAP_SOURCE(file_cache));
   champlain_map_source_chain_push(source_chain, CHAMPLAIN_MAP_SOURCE(memory_cache));
   
   champlain_view_set_map_source(mapview, CHAMPLAIN_MAP_SOURCE(source_chain));

//-------------------------------------------------------------------------------
Comment 6 GNOME Infrastructure Team 2018-05-22 13:00:49 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/libchamplain/issues/31.