Skip to content

Commit f910476

Browse files
committed
Allow embedders to control the marker pack via data-marker-pack="…"
Issue: #43
1 parent 6e50d6a commit f910476

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

gulpfile.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ gulp.task('js', function() {
6161
.pipe(gulp.dest('./dist/'));
6262
});
6363

64-
gulp.task('img', function() {
64+
gulp.task('css-img', function() {
6565
gulp.src([
6666
'node_modules/leaflet-fullscreen/dist/*.png',
6767
'src/_css/*.png',
@@ -71,7 +71,17 @@ gulp.task('img', function() {
7171
//}))
7272
.pipe(gulp.dest('./dist/'));
7373

74-
gulp.src([
74+
gulp.src([
75+
'src/_img/marker-icons/*.png',
76+
])
77+
//.pipe(imagemin({
78+
// 'optimizationLevel': 7
79+
//}))
80+
.pipe(gulp.dest('./dist/_img/marker-icons/'));
81+
});
82+
83+
gulp.task('img-img', function() {
84+
gulp.src([
7585
'src/_img/marker-icons/*.png',
7686
])
7787
//.pipe(imagemin({
@@ -99,5 +109,5 @@ gulp.task('serve', function() {
99109
}));
100110
});
101111

102-
gulp.task('build', ['clean', 'html', 'css', 'js', 'img', 'copy']);
112+
gulp.task('build', ['clean', 'html', 'css', 'js', 'css-img', 'img-img', 'copy']);
103113
gulp.task('default', ['build', 'serve']);

src/_js/map.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,10 @@
199199
});
200200
});
201201

202+
const mapContainer = document.querySelector('#map');
203+
const MARKERS_URL_PATH = mapContainer.dataset.markerPack ? mapContainer.dataset.markerPack : 'markers.json';
202204
const xhr = new XMLHttpRequest();
203-
xhr.open('GET', URL_PREFIX + 'markers.json');
205+
xhr.open('GET', URL_PREFIX + MARKERS_URL_PATH);
204206
xhr.responseType = 'json';
205207
xhr.onload = function() {
206208
if (xhr.status === 200) {

src/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Tibia Map</title>
6-
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
6+
<meta name="viewport" content="width=device-width">
77
<link rel="stylesheet" href="../dist/map.css">
88
<style>
99
html, body {
@@ -20,6 +20,7 @@
2020
<link rel="icon" href="favicon.ico">
2121
</head>
2222
<body>
23+
<!--<div id="map" data-marker-pack="minimap-with-grid-overlay-and-poi-markers/markers.json"></div>-->
2324
<div id="map"></div>
2425
<script src="../dist/map.js"></script>
2526
</body>

0 commit comments

Comments
 (0)