Localhost map source


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 sources",
            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]