Skip to content

Commit

Permalink
Allow embedders to control the marker pack via data-marker-pack="…"
Browse files Browse the repository at this point in the history
Issue: #43
  • Loading branch information
mathiasbynens committed May 21, 2022
1 parent 6e50d6a commit f910476
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
16 changes: 13 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ gulp.task('js', function() {
.pipe(gulp.dest('./dist/'));
});

gulp.task('img', function() {
gulp.task('css-img', function() {
gulp.src([
'node_modules/leaflet-fullscreen/dist/*.png',
'src/_css/*.png',
Expand All @@ -71,7 +71,17 @@ gulp.task('img', function() {
//}))
.pipe(gulp.dest('./dist/'));

gulp.src([
gulp.src([
'src/_img/marker-icons/*.png',
])
//.pipe(imagemin({
// 'optimizationLevel': 7
//}))
.pipe(gulp.dest('./dist/_img/marker-icons/'));
});

gulp.task('img-img', function() {
gulp.src([
'src/_img/marker-icons/*.png',
])
//.pipe(imagemin({
Expand Down Expand Up @@ -99,5 +109,5 @@ gulp.task('serve', function() {
}));
});

gulp.task('build', ['clean', 'html', 'css', 'js', 'img', 'copy']);
gulp.task('build', ['clean', 'html', 'css', 'js', 'css-img', 'img-img', 'copy']);
gulp.task('default', ['build', 'serve']);
4 changes: 3 additions & 1 deletion src/_js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@
});
});

const mapContainer = document.querySelector('#map');
const MARKERS_URL_PATH = mapContainer.dataset.markerPack ? mapContainer.dataset.markerPack : 'markers.json';
const xhr = new XMLHttpRequest();
xhr.open('GET', URL_PREFIX + 'markers.json');
xhr.open('GET', URL_PREFIX + MARKERS_URL_PATH);
xhr.responseType = 'json';
xhr.onload = function() {
if (xhr.status === 200) {
Expand Down
3 changes: 2 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Tibia Map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="../dist/map.css">
<style>
html, body {
Expand All @@ -20,6 +20,7 @@
<link rel="icon" href="favicon.ico">
</head>
<body>
<!--<div id="map" data-marker-pack="minimap-with-grid-overlay-and-poi-markers/markers.json"></div>-->
<div id="map"></div>
<script src="../dist/map.js"></script>
</body>
Expand Down

0 comments on commit f910476

Please sign in to comment.