maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.25k stars 642 forks source link

Using tileserver-gl in docker-compose linked containers #181

Open psychemedia opened 7 years ago

psychemedia commented 7 years ago

Are there any examples of using tileserver-gl with linked containers launched using docker-compose?

For example

Related to this, is it possible to define the Dockerfile such that it would allow the setting of environment variables in the docker-compose.yaml file that would allow the setting of the -b,--bind (bind address) ?

tileserver:
  image: klokantech/tileserver-gl
  ports:
    - 8085:80
  volumes:
    - .:/data

jupyterscipy:
  image: psychemedia/ou-tm351-jupyter-custom-pystack-test
  ports:
    - 8899:8888
  links:
    - tileserver:tileserver
    - postcodes:postcodes 
  volumes:
    - .:/home/jovyan/work

but can seem to load any served tiles in a map in a Jupyter notebook in the linked Jupyter container?

I'm wondering if it's a bind issue?

smellman commented 7 years ago

@psychemedia Why do you use links with tileserver-gl? Do you want to access from your jupyterscipy image to tileserver image using http://tileserver/data/v3/{z}/{x}/{y}.pbf url?

https://gist.github.com/smellman/e6e839fa1cc10e7e2008f9a7bf72aa70 In my case, varnish cache access to raster-tileserver(s) using 80 port.

psychemedia commented 7 years ago

@smellman re: Do you want to access from your jupyterscipy image to tileserver image using http://tileserver/data/v3/{z}/{x}/{y}.pbf url?

Yes... Ideally, I want to be able to use folium python package in notebook to render maps in Jupyter notebook with tiles served from the tileserver-gl container.

smellman commented 7 years ago

@psychemedia How about following code?

tileset = r'http://localhost:8085/styles/klokantech-basic/{z}/{x}/{y}.png'
# tileset = r'http://localhost:8085/styles/{your style}/{z}/{x}/{y}.png'
map = folium.Map(location=[45.372, -121.6972], zoom_start=12,
                 tiles=tileset, attr='your attribution message')

folium seems make leaflet container, it means Jupyter notebook and folium don't care about local access to tile, it only need access from browser.

psychemedia commented 7 years ago

@smellman Yes, doh!, of course... also realised my issue was with serving .pbf rather than png. I thought I'd seen a folium demo of that working but I must have imagined it...

I guess I need to rethink doing something built around mapbox-gl.js?

smellman commented 7 years ago

@psychemedia You can access via http://localhost:8085/data/v3.json or directly http://localhost:8085/data/v3/{z}/{x}/{y}.pbf. But folium doesn't support Mapbox GL JS yet. https://github.com/python-visualization/folium/issues/416#issuecomment-248753090 See this comment and check folium repository (or to become contributor:-) ).

If you want to only embed map in Jupyter Notebooks , this article seem good. https://www.ryanbaumann.com/blog/2016/4/3/embedding-mapbox-plots-in-jupyter-notebooks Also, you need change javascript code in this article.

// mapboxgl.accessToken = 'pk.eyJ1IjoicnNiYXVtYW5uIiwiYSI6IjdiOWEzZGIyMGNkOGY3NWQ4ZTBhN2Y5ZGU2Mzg2NDY2In0.jycgv7qwF8MMIWt4cT0RaQ';
var map = new mapboxgl.Map({
    container: 'map', // container id
    style: 'http://localhost:8085/styles/klokantech-basic/style.json', //stylesheet location
    center: [-89.948470, 40.783860], // starting position
    zoom: 10 // starting zoom
});
psychemedia commented 7 years ago

@smellman Thanks.. I thought I'd seen a connection string example using .pbf and assumed that meant handling was autodetected. But I must have been mistaken (can't find it anywhere now...)

Will have a play when I get back from a w/e away and see if I can figure out to patch folium, if indeed @ryanbaumann hasn't already done so...

ryanbaumann commented 7 years ago

@psychemedia another good notebook if you're looking at how to integrate Mapbox GL into Jupyter notebooks (from last year):

https://apsportal.ibm.com/analytics/notebooks/196b9950-8d46-48bc-bf7c-bc18a38dc53c/view?access_token=12e821847919c627a77c7e7178683789fec57e8df06ee296c12f12be34e8a535