Localhost map source
- From: Gerard Toonstra <gtoonstra gmail com>
- To: libchamplain-list gnome org
- Subject: Localhost map source
- Date: Thu, 6 Oct 2011 11:06:05 +0200
Hello,
This may be useful to others as well and hopefully this may lead the developers to rethink some of the API on map sources.
I'm using the gtkChamplain widget to display a map in a python based app. Rather than using the standard openstreetmap url, I rendered my own
tiles and wanted to redirect the mapview to use localhost for that purpose.
In C and with a bit of digging in the sources, it's not too difficult to figure out a way to do this using the factory and mapsourcedesc objects.
In python however, I got stuck somewhere and then figured out this way to use a mapchain created outside of the factory, which is set on the mapview instead:
---------------------------------
map_chain = Champlain.MapSourceChain()
errorRenderer = Champlain.ErrorTileRenderer.new( 256 )
null_source = Champlain.NullTileSource.new_full( errorRenderer )
map_chain.push( null_source )
imgrenderer = Champlain.ImageRenderer()
tile_source = Champlain.NetworkTileSource.new_full(
"Localhost",
"Localhost sources",
"license",
"license-uri",
0,
17,
256,
Champlain.MapProjection.MAP_PROJECTION_MERCATOR,
"
http://localhost/tiles/#Z#/#X#/#Y#.png",
imgrenderer )
map_chain.push( tile_source )
map_chain.push( Champlain.FileCache.new_full( 100000000, None, imgrenderer ) )
map_chain.push( Champlain.MemoryCache.new_full( 100, imgrenderer ))
self.view.set_map_source( map_chain )
---------------------------------------------
Hope that helps someone.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]