Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const MBView = require('./mbview');
const params = {
center: argv.center || [-122.42, 37.75],
mbtiles: mbtiles,
url: argv.url || 'http://localhost',
port: argv.port || 3000,
zoom: 12,
quiet: argv.q || argv.quiet,
Expand All @@ -48,6 +49,7 @@ const params = {
};

MBView.serve(params, (err, config) => {
console.log('Listening on http://localhost:' + config.port);
if (!argv.n) open('http://localhost:' + config.port);
const fullUrl = config.url + ':' + config.port;
console.log('Listening on ' + fullUrl);
if (!argv.n) open(fullUrl);
});
1 change: 1 addition & 0 deletions test/mbview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ test('MBView.serve', (t) => {
__dirname + '/fixtures/twolayers.mbtiles',
__dirname + '/fixtures/038.mbtiles'
],
url: 'http://localhost',
port: 9000,
accessToken: 'pk.foo.bar'
};
Expand Down
1 change: 1 addition & 0 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports.usage = function () {
u.push('usage: mbview [options] [files]');
u.push('');
u.push(' --port sets port to use (default: 3000)');
u.push(' --url sets host to use (default: http://localhost)');
u.push(' --quiet or -q supress all logging except the address to visit');
u.push(' -n don\'t automatically open the browser on start');
u.push(' --basemap, --base or --map sets the basemap style (default: dark)');
Expand Down
2 changes: 1 addition & 1 deletion views/raster.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
L.mapbox.accessToken = '<%= accessToken %>';
var map = L.mapbox.map('map').setView([center[1], center[0]], center[2]);
var baselayer = L.tileLayer('http://b.tiles.mapbox.com/v4/mapbox.<%= basemap %>/{z}/{x}/{y}.png?access_token=<%= accessToken %>').addTo(map);
var tilelayer = L.tileLayer('http://localhost:<%= port %>/' + source + '/{z}/{x}/{y}.<%= format %>', { maxNativeZoom: <%= maxzoom %> }).addTo(map);
var tilelayer = L.tileLayer('<%= url %>:<%= port %>/' + source + '/{z}/{x}/{y}.<%= format %>', { maxNativeZoom: <%= maxzoom %> }).addTo(map);
var hash = L.hash(map);
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion views/vector.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ map.on('load', function () {
map.addSource('<%= sid %>', {
type: 'vector',
tiles: [
'http://localhost:<%= port %>/<%= sid %>/{z}/{x}/{y}.pbf'
'<%= url %>:<%= port %>/<%= sid %>/{z}/{x}/{y}.pbf'
],
maxzoom: <%= sources[sid].maxzoom %>
});
Expand Down