Sunday, 25 November 2018

web mapping - Using local mbtiles in openlayers?


--The problem-- I've successfully added mbtiles from Mapbox free online source to OpenLayers, but cannot figure out how to get the mbtiles I've created/stored locally to show up in OpenLayers.


--The process-- Style data in Tilemill, export mbtiles, add mbtiles to Tilestream running on localhost, then add to openlayers using the localhost:8888 url.


--The code--


This works:


// Add mapbox mbtiles from web
map.addLayer(new OpenLayers.Layer.TMS('geography-class',

'http://a.tiles.mapbox.com/mapbox/', {
maxResolution: 156543.0339,
type: 'png',
layername: 'geography-class',
isBaseLayer: true
}));

This doesn't work:


// Add tilestream mbtiles local data layer
map.addLayer(new OpenLayers.Layer.TMS('overlayWorld',

'http://localhost:8888/2.0.0/overlay_62ee43/{z}/{x}/{y}.png', {
maxResolution: 156543.0339,
type: 'png',
layername: 'overlayWorld',
isBaseLayer: false
}));

That localhost url comes from the 'TILE URL' field in Tilestream. I've tried multiple different edits to the localhost url but cannot get it right.


Any help is appreciated.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...