Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6e2baef67 | ||
|
|
6100013718 | ||
|
|
4eea8a91b8 | ||
|
|
d57f9f7a60 | ||
|
|
1307b29ff9 | ||
|
|
a9443edfc6 | ||
|
|
e6a1bf407c | ||
|
|
0ba2dcce53 | ||
|
|
ebd6662ebb | ||
|
|
6898be5bea | ||
|
|
a55b5ad69c | ||
|
|
1104bf8a57 | ||
|
|
1d4503b507 | ||
|
|
2d5dccc1e0 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "0.0.3",
|
||||
"version": "0.6.0",
|
||||
"description": "Map tile server for JSON GL styles - serverside generated raster tiles",
|
||||
"main": "src/main.js",
|
||||
"authors": [
|
||||
@@ -19,7 +19,7 @@
|
||||
"advanced-pool": "0.3.2",
|
||||
"canvas": "1.4.0",
|
||||
"clone": "1.0.2",
|
||||
"color": "0.11.2",
|
||||
"color": "0.11.3",
|
||||
"cors": "2.7.1",
|
||||
"express": "4.14.0",
|
||||
"handlebars": "4.0.5",
|
||||
|
||||
BIN
public/resources/favicon.ico
Normal file
BIN
public/resources/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -78,6 +78,11 @@
|
||||
padding: 5px;
|
||||
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%270%200%2020%2020%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%0A%20%20%3Cpath%20style%3D%27fill%3A%23333333%3B%27%20d%3D%27M%2010%206%20C%209.446%206%209%206.4459904%209%207%20L%209%209%20L%207%209%20C%206.446%209%206%209.446%206%2010%20C%206%2010.554%206.446%2011%207%2011%20L%209%2011%20L%209%2013%20C%209%2013.55401%209.446%2014%2010%2014%20C%2010.554%2014%2011%2013.55401%2011%2013%20L%2011%2011%20L%2013%2011%20C%2013.554%2011%2014%2010.554%2014%2010%20C%2014%209.446%2013.554%209%2013%209%20L%2011%209%20L%2011%207%20C%2011%206.4459904%2010.554%206%2010%206%20z%27%20%2F%3E%0A%3C%2Fsvg%3E%0A");
|
||||
}
|
||||
.mapboxgl-ctrl-icon.mapboxgl-ctrl-geolocate {
|
||||
padding: 5px;
|
||||
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20viewBox%3D%270%200%2020%2020%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%3E%3Cpath%20style%3D%27fill%3A%23333333%3B%27%20d%3D%27M13%2C7%20L10.5%2C11.75%20L10.25%2C10%20z%20M13.888%2C6.112%20C13.615%2C5.84%2013.382%2C6.076%2012.5%2C6.5%20C10.14%2C7.634%206%2C10%206%2C10%20L9.5%2C10.5%20L10%2C14%20C10%2C14%2012.366%2C9.86%2013.5%2C7.5%20C13.924%2C6.617%2014.16%2C6.385%2013.888%2C6.112%27%2F%3E%3C%2Fsvg%3E");
|
||||
}
|
||||
|
||||
.mapboxgl-ctrl-icon.mapboxgl-ctrl-compass > div.arrow {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
@@ -106,6 +111,8 @@
|
||||
|
||||
.mapboxgl-popup {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
will-change: transform;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -65,5 +65,3 @@ module.exports=window.L=require("leaflet/dist/leaflet-src");
|
||||
"use strict";function contains(n,t){if(!t||!t.length)return!1;for(var r=0;r<t.length;r++)if(t[r]===n)return!0;return!1}module.exports={idUrl:function(n,t){-1===n.indexOf("/")?t.loadID(n):t.loadURL(n)},log:function(n){"object"==typeof console&&"function"==typeof console.error&&console.error(n)},strict:function(n,t){if(typeof n!==t)throw new Error("Invalid argument: "+t+" expected")},strict_instance:function(n,t,r){if(!(n instanceof t))throw new Error("Invalid argument: "+r+" expected")},strict_oneof:function(n,t){if(!contains(n,t))throw new Error("Invalid argument: "+n+" given, valid values are "+t.join(", "))},strip_tags:function(n){return n.replace(/<[^<]+>/g,"")},lbounds:function(n){return new L.LatLngBounds([[n[1],n[0]],[n[3],n[2]]])}};
|
||||
},{}]},{},[17])
|
||||
|
||||
|
||||
//# sourceMappingURL=mapbox.js.map
|
||||
@@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<title>{{name}} - TileServer GL</title>
|
||||
{{#is_vector}}
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css" />
|
||||
<script src="/mapbox-gl.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css{{&key_query}}" />
|
||||
<script src="/mapbox-gl.js{{&key_query}}"></script>
|
||||
<style>
|
||||
body {background:#000;color:#ccc;}
|
||||
#map {position:absolute;top:0;left:0;right:250px;bottom:0;}
|
||||
@@ -16,9 +16,9 @@
|
||||
</style>
|
||||
{{/is_vector}}
|
||||
{{^is_vector}}
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox.css" />
|
||||
<script src="/mapbox.js"></script>
|
||||
<script src="/leaflet-hash.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox.css{{&key_query}}" />
|
||||
<script src="/mapbox.js{{&key_query}}"></script>
|
||||
<script src="/leaflet-hash.js{{&key_query}}"></script>
|
||||
<style>
|
||||
body { margin:0; padding:0; }
|
||||
#map { position:absolute; top:0; bottom:0; width:100%; }
|
||||
@@ -97,18 +97,24 @@
|
||||
}
|
||||
};
|
||||
xhttp.responseType = 'json';
|
||||
xhttp.open('GET', '/data/{{id}}.json', true);
|
||||
xhttp.open('GET', '/data/{{id}}.json{{&key_query}}', true);
|
||||
xhttp.send();
|
||||
|
||||
var propertyList = document.getElementById('propertyList');
|
||||
map.on('mousemove', function(e) {
|
||||
propertyList.innerHTML = '';
|
||||
map.featuresAt(e.point, {radius: 3}, function(err, features) {
|
||||
if (err) throw err;
|
||||
if (features[0]) {
|
||||
propertyList.innerHTML = JSON.stringify(features[0].properties, null, 2);
|
||||
}
|
||||
var width = 3, height = 3;
|
||||
var features = map.queryRenderedFeatures([
|
||||
[e.point.x - width / 2, e.point.y - height / 2],
|
||||
[e.point.x + width / 2, e.point.y + height / 2]
|
||||
]);
|
||||
if (features) {
|
||||
var html = '';
|
||||
features.forEach(function(feature) {
|
||||
html += JSON.stringify(feature.properties, null, 2) + '\n';
|
||||
});
|
||||
propertyList.innerHTML = html;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{{/is_vector}}
|
||||
@@ -116,7 +122,7 @@
|
||||
<h1 style="display:none;">{{name}}</h1>
|
||||
<div id='map'></div>
|
||||
<script>
|
||||
var map = L.mapbox.map('map', '/data/{{id}}.json', { zoomControl: false });
|
||||
var map = L.mapbox.map('map', '/data/{{id}}.json{{&key_query}}', { zoomControl: false });
|
||||
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
||||
setTimeout(function() {
|
||||
new L.Hash(map);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>TileServerGL</title>
|
||||
<link rel="stylesheet" type="text/css" href="/index.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/index.css{{&key_query}}" />
|
||||
</head>
|
||||
<body>
|
||||
<section>
|
||||
@@ -13,25 +13,28 @@
|
||||
{{#each styles}}
|
||||
<div class="item">
|
||||
{{#if thumbnail}}
|
||||
<img src="/styles/{{@key}}/rendered/{{thumbnail}}" alt="{{name}} preview" />
|
||||
<img src="/styles/{{@key}}/rendered/{{thumbnail}}{{&../key_query}}" alt="{{name}} preview" />
|
||||
{{else}}
|
||||
<div class="sample-img"></div>
|
||||
{{/if}}
|
||||
<h3>{{name}}</h3>
|
||||
<p>Id: {{@key}}
|
||||
{{#if serving_rendered}}
|
||||
| <a href="/styles/{{@key}}/rendered.json">TileJSON</a>
|
||||
| <a href="/styles/{{@key}}/rendered.json{{&../key_query}}">TileJSON</a>
|
||||
{{#if wmts_link}}
|
||||
| <a href="{{&wmts_link}}">WMTS Service</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</p>
|
||||
{{#if serving_data}}
|
||||
<a class="btn" href="/styles/{{@key}}/?vector{{viewer_hash}}">Vector view</a>
|
||||
<a class="btn" href="/styles/{{@key}}/?{{&../key_query_part}}vector{{viewer_hash}}">Vector view</a>
|
||||
{{/if}}
|
||||
{{#if serving_rendered}}
|
||||
<a class="btn" href="/styles/{{@key}}/?raster{{viewer_hash}}">Raster view</a>
|
||||
<a class="btn" href="/styles/{{@key}}/?{{&../key_query_part}}raster{{viewer_hash}}">Raster view</a>
|
||||
{{/if}}
|
||||
{{#if serving_data}}
|
||||
{{#if serving_rendered}}
|
||||
<a class="btn" href="/styles/{{@key}}/{{viewer_hash}}">Auto view</a>
|
||||
<a class="btn" href="/styles/{{@key}}/{{&../key_query}}{{viewer_hash}}">Auto view</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
@@ -42,17 +45,22 @@
|
||||
{{#each data}}
|
||||
<div class="item">
|
||||
{{#if thumbnail}}
|
||||
<img src="/data/{{@key}}/{{thumbnail}}" alt="{{name}} preview" />
|
||||
<img src="/data/{{@key}}/{{thumbnail}}{{&../key_query}}" alt="{{name}} preview" />
|
||||
{{else}}
|
||||
<div class="sample-img"></div>
|
||||
{{/if}}
|
||||
<h3>{{name}}</h3>
|
||||
<p>Id: {{@key}} |{{#if formatted_filesize}} {{formatted_filesize}} |{{/if}} {{#is_vector}}Vector{{/is_vector}}{{^is_vector}}Raster{{/is_vector}} data | <a href="/data/{{@key}}.json">TileJSON</a></p>
|
||||
<p>Id: {{@key}} |{{#if formatted_filesize}} {{formatted_filesize}} |{{/if}} {{#is_vector}}Vector{{/is_vector}}{{^is_vector}}Raster{{/is_vector}} data
|
||||
| <a href="/data/{{@key}}.json{{&../key_query}}">TileJSON</a>
|
||||
{{#if wmts_link}}
|
||||
| <a href="{{&wmts_link}}">WMTS Service</a>
|
||||
{{/if}}
|
||||
</p>
|
||||
{{#is_vector}}
|
||||
<a class="btn" href="/data/{{@key}}/{{viewer_hash}}">X-Ray view</a>
|
||||
<a class="btn" href="/data/{{@key}}/{{&../key_query}}{{viewer_hash}}">X-Ray view</a>
|
||||
{{/is_vector}}
|
||||
{{^is_vector}}
|
||||
<a class="btn" href="/data/{{@key}}/{{viewer_hash}}">Raster view</a>
|
||||
<a class="btn" href="/data/{{@key}}/{{&../key_query}}{{viewer_hash}}">Raster view</a>
|
||||
{{/is_vector}}
|
||||
</div>
|
||||
{{/each}}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{name}} - TileServer GL</title>
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css" />
|
||||
<script src="/mapbox-gl.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox.css" />
|
||||
<script src="/mapbox.js"></script>
|
||||
<script src="/leaflet-hash.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox-gl.css{{&key_query}}" />
|
||||
<script src="/mapbox-gl.js{{&key_query}}"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/mapbox.css{{&key_query}}" />
|
||||
<script src="/mapbox.js{{&key_query}}"></script>
|
||||
<script src="/leaflet-hash.js{{&key_query}}"></script>
|
||||
<style>
|
||||
body { margin:0; padding:0; }
|
||||
#map { position:absolute; top:0; bottom:0; width:100%; }
|
||||
@@ -17,19 +17,20 @@
|
||||
<h1 style="display:none;">{{name}}</h1>
|
||||
<div id='map'></div>
|
||||
<script>
|
||||
var preference = (location.search || '').substr(1);
|
||||
if (preference != 'vector' && preference != 'raster') {
|
||||
preference = mapboxgl.supported() ? 'vector' : 'raster';
|
||||
}
|
||||
var q = (location.search || '').substr(1).split('&');
|
||||
var preference =
|
||||
q.indexOf('vector') >= 0 ? 'vector' :
|
||||
(q.indexOf('raster') >= 0 ? 'raster' :
|
||||
(mapboxgl.supported() ? 'vector' : 'raster'));
|
||||
if (preference == 'vector') {
|
||||
var map = new mapboxgl.Map({
|
||||
container: 'map',
|
||||
style: '/styles/{{id}}.json',
|
||||
style: '/styles/{{id}}.json{{&key_query}}',
|
||||
hash: true
|
||||
});
|
||||
map.addControl(new mapboxgl.Navigation());
|
||||
} else {
|
||||
var map = L.mapbox.map('map', '/styles/{{id}}/rendered.json', { zoomControl: false });
|
||||
var map = L.mapbox.map('map', '/styles/{{id}}/rendered.json{{&key_query}}', { zoomControl: false });
|
||||
new L.Control.Zoom({ position: 'topright' }).addTo(map);
|
||||
setTimeout(function() {
|
||||
new L.Hash(map);
|
||||
|
||||
@@ -137,7 +137,7 @@ module.exports = function(options, repo, params, id) {
|
||||
});
|
||||
};
|
||||
|
||||
styleJSON = require(path.join(options.paths.styles, styleFile));
|
||||
styleJSON = clone(require(path.join(options.paths.styles, styleFile)));
|
||||
styleJSON.sprite = 'sprites://' + path.basename(styleFile, '.json');
|
||||
styleJSON.glyphs = 'fonts://{fontstack}/{range}.pbf';
|
||||
|
||||
|
||||
@@ -46,9 +46,13 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||
repo[id] = styleJSON;
|
||||
|
||||
app.get('/' + id + '.json', function(req, res, next) {
|
||||
var fixUrl = function(url) {
|
||||
var fixUrl = function(url, opt_nokey) {
|
||||
var query = '';
|
||||
if (!opt_nokey && req.query.key) {
|
||||
query = '?key=' + req.query.key;
|
||||
}
|
||||
return url.replace(
|
||||
'local://', req.protocol + '://' + req.headers.host + '/');
|
||||
'local://', req.protocol + '://' + req.headers.host + '/') + query;
|
||||
};
|
||||
|
||||
var styleJSON_ = clone(styleJSON);
|
||||
@@ -56,7 +60,8 @@ module.exports = function(options, repo, params, id, reportTiles, reportFont) {
|
||||
var source = styleJSON_.sources[name];
|
||||
source.url = fixUrl(source.url);
|
||||
});
|
||||
styleJSON_.sprite = fixUrl(styleJSON_.sprite);
|
||||
// mapbox-gl-js viewer cannot handle sprite urls with query
|
||||
styleJSON_.sprite = fixUrl(styleJSON_.sprite, true);
|
||||
styleJSON_.glyphs = fixUrl(styleJSON_.glyphs);
|
||||
return res.send(styleJSON_);
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = function(opts, callback) {
|
||||
|
||||
var config;
|
||||
try {
|
||||
config = require(configPath);
|
||||
config = clone(require(configPath));
|
||||
} catch (e) {
|
||||
console.log('ERROR: Config file not found or invalid!');
|
||||
console.log(' See README.md for instructions and sample data.');
|
||||
@@ -118,13 +118,15 @@ module.exports = function(opts, callback) {
|
||||
|
||||
app.get('/styles.json', function(req, res, next) {
|
||||
var result = [];
|
||||
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||
Object.keys(serving.styles).forEach(function(id) {
|
||||
var styleJSON = serving.styles[id];
|
||||
result.push({
|
||||
version: styleJSON.version,
|
||||
name: styleJSON.name,
|
||||
id: id,
|
||||
url: req.protocol + '://' + req.headers.host + '/styles/' + id + '.json'
|
||||
url: req.protocol + '://' + req.headers.host +
|
||||
'/styles/' + id + '.json' + query
|
||||
});
|
||||
});
|
||||
res.send(result);
|
||||
@@ -165,17 +167,20 @@ module.exports = function(opts, callback) {
|
||||
app.use(path, function(req, res, next) {
|
||||
var data = {};
|
||||
if (dataGetter) {
|
||||
data = dataGetter(req.params);
|
||||
data = dataGetter(req);
|
||||
if (!data) {
|
||||
return res.status(404).send('Not found');
|
||||
}
|
||||
}
|
||||
data['key_query_part'] =
|
||||
req.query.key ? 'key=' + req.query.key + '&' : '';
|
||||
data['key_query'] = req.query.key ? '?key=' + req.query.key : '';
|
||||
return res.status(200).send(compiled(data));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
serveTemplate('/$', 'index', function() {
|
||||
serveTemplate('/$', 'index', function(req) {
|
||||
var styles = clone(config.styles || {});
|
||||
Object.keys(styles).forEach(function(id) {
|
||||
var style = styles[id];
|
||||
@@ -194,6 +199,12 @@ module.exports = function(opts, callback) {
|
||||
Math.floor(centerPx[0] / 256) + '/' +
|
||||
Math.floor(centerPx[1] / 256) + '.png';
|
||||
}
|
||||
|
||||
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||
style.wmts_link = 'https://wmts.maptiler.com/' +
|
||||
new Buffer(req.protocol + '://' + req.headers.host +
|
||||
'/styles/' + id + '/rendered.json' + query).toString('base64') +
|
||||
'/wmts';
|
||||
}
|
||||
});
|
||||
var data = clone(serving.data || {});
|
||||
@@ -213,6 +224,11 @@ module.exports = function(opts, callback) {
|
||||
Math.floor(centerPx[0] / 256) + '/' +
|
||||
Math.floor(centerPx[1] / 256) + '.' + data_.format;
|
||||
}
|
||||
|
||||
var query = req.query.key ? ('?key=' + req.query.key) : '';
|
||||
data_.wmts_link = 'http://wmts.maptiler.com/' +
|
||||
new Buffer('http://' + req.headers.host +
|
||||
'/data/' + id + '.json' + query).toString('base64') + '/wmts';
|
||||
}
|
||||
if (data_.filesize) {
|
||||
var suffix = 'kB';
|
||||
@@ -234,8 +250,8 @@ module.exports = function(opts, callback) {
|
||||
};
|
||||
});
|
||||
|
||||
serveTemplate('/styles/:id/$', 'viewer', function(params) {
|
||||
var id = params.id;
|
||||
serveTemplate('/styles/:id/$', 'viewer', function(req) {
|
||||
var id = req.params.id;
|
||||
var style = clone((config.styles || {})[id]);
|
||||
if (!style) {
|
||||
return null;
|
||||
@@ -253,8 +269,8 @@ module.exports = function(opts, callback) {
|
||||
});
|
||||
*/
|
||||
|
||||
serveTemplate('/data/:id/$', 'data', function(params) {
|
||||
var id = params.id;
|
||||
serveTemplate('/data/:id/$', 'data', function(req) {
|
||||
var id = req.params.id;
|
||||
var data = clone(serving.data[id]);
|
||||
if (!data) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user