Skip to content

Commit a36b158

Browse files
author
Joe Hawes
committed
HTML working
1 parent bd87fd6 commit a36b158

File tree

5 files changed

+59
-68
lines changed

5 files changed

+59
-68
lines changed

assets/dist/waymark-js/js/waymark-js.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7731,37 +7731,34 @@ function Waymark_Map() {
77317731
Waymark.map._layersMaxZoom = 18;
77327732
Waymark.marker_cluster = L.markerClusterGroup({
77337733
iconCreateFunction: function(cluster) {
7734-
let clusterHTML = '';
7735-
7736-
const markers = cluster.getAllChildMarkers();
7737-
7738-
markers.forEach((marker) => {
7734+
//Each Marker
7735+
cluster.getAllChildMarkers().forEach((marker) => {
7736+
//Get data
77397737
const typeKey = marker.feature.properties.type;
77407738
const typeData = Waymark.get_type('marker', typeKey);
77417739
typeData.iconData = Waymark.build_icon_data(typeData);
77427740

7743-
clusterTypes.set(typeKey, typeData);
7744-
/*
7745-
7746-
//Icon
7747-
var icon_data = Waymark.build_icon_data(type);
7748-
7749-
//Marker DIV
7750-
overlay_preview
7751-
.addClass(icon_data.className)
7752-
.html(icon_data.html)
7753-
.css({
7754-
'width': icon_data.iconSize[0],
7755-
'height': icon_data.iconSize[1]
7756-
})
7757-
;
7741+
//Keep Count
7742+
if(! clusterTypes.has(typeKey)) {
7743+
typeData.typeCount = 1;
7744+
} else {
7745+
typeData.typeCount++;
7746+
}
77587747

7759-
*/
7760-
clusterHTML += '<div class="' + typeData.iconData.className + '" style="width:' + typeData.iconData.iconSize[0] + 'px;height:' + typeData.iconData.iconSize[1] + 'px;">' + typeData.iconData.html + '</div>';
7748+
clusterTypes.set(typeKey, typeData);
77617749
});
77627750

77637751
console.debug(clusterTypes);
77647752

7753+
//Build HTML
7754+
let clusterHTML = '<div class="waymark-cluster">';
7755+
7756+
clusterTypes.forEach((typeData, index) => {
7757+
clusterHTML += ' <div class="' + typeData.iconData.className + '" style="width:' + typeData.iconData.iconSize[0] + 'px;height:' + typeData.iconData.iconSize[1] + 'px;">' + typeData.iconData.html + '</div>';
7758+
})
7759+
7760+
clusterHTML += '</div>';
7761+
77657762
return L.divIcon({ html: clusterHTML });
77667763
}
77677764
});

assets/dist/waymark-js/js/waymark-js.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

waymark-js/dist/js/waymark-js.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7731,37 +7731,34 @@ function Waymark_Map() {
77317731
Waymark.map._layersMaxZoom = 18;
77327732
Waymark.marker_cluster = L.markerClusterGroup({
77337733
iconCreateFunction: function(cluster) {
7734-
let clusterHTML = '';
7735-
7736-
const markers = cluster.getAllChildMarkers();
7737-
7738-
markers.forEach((marker) => {
7734+
//Each Marker
7735+
cluster.getAllChildMarkers().forEach((marker) => {
7736+
//Get data
77397737
const typeKey = marker.feature.properties.type;
77407738
const typeData = Waymark.get_type('marker', typeKey);
77417739
typeData.iconData = Waymark.build_icon_data(typeData);
77427740

7743-
clusterTypes.set(typeKey, typeData);
7744-
/*
7745-
7746-
//Icon
7747-
var icon_data = Waymark.build_icon_data(type);
7748-
7749-
//Marker DIV
7750-
overlay_preview
7751-
.addClass(icon_data.className)
7752-
.html(icon_data.html)
7753-
.css({
7754-
'width': icon_data.iconSize[0],
7755-
'height': icon_data.iconSize[1]
7756-
})
7757-
;
7741+
//Keep Count
7742+
if(! clusterTypes.has(typeKey)) {
7743+
typeData.typeCount = 1;
7744+
} else {
7745+
typeData.typeCount++;
7746+
}
77587747

7759-
*/
7760-
clusterHTML += '<div class="' + typeData.iconData.className + '" style="width:' + typeData.iconData.iconSize[0] + 'px;height:' + typeData.iconData.iconSize[1] + 'px;">' + typeData.iconData.html + '</div>';
7748+
clusterTypes.set(typeKey, typeData);
77617749
});
77627750

77637751
console.debug(clusterTypes);
77647752

7753+
//Build HTML
7754+
let clusterHTML = '<div class="waymark-cluster">';
7755+
7756+
clusterTypes.forEach((typeData, index) => {
7757+
clusterHTML += ' <div class="' + typeData.iconData.className + '" style="width:' + typeData.iconData.iconSize[0] + 'px;height:' + typeData.iconData.iconSize[1] + 'px;">' + typeData.iconData.html + '</div>';
7758+
})
7759+
7760+
clusterHTML += '</div>';
7761+
77657762
return L.divIcon({ html: clusterHTML });
77667763
}
77677764
});

waymark-js/dist/js/waymark-js.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

waymark-js/src/js/Waymark_Map.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -364,37 +364,34 @@ function Waymark_Map() {
364364
Waymark.map._layersMaxZoom = 18;
365365
Waymark.marker_cluster = L.markerClusterGroup({
366366
iconCreateFunction: function(cluster) {
367-
let clusterHTML = '';
368-
369-
const markers = cluster.getAllChildMarkers();
370-
371-
markers.forEach((marker) => {
367+
//Each Marker
368+
cluster.getAllChildMarkers().forEach((marker) => {
369+
//Get data
372370
const typeKey = marker.feature.properties.type;
373371
const typeData = Waymark.get_type('marker', typeKey);
374372
typeData.iconData = Waymark.build_icon_data(typeData);
375373

376-
clusterTypes.set(typeKey, typeData);
377-
/*
374+
//Keep Count
375+
if(! clusterTypes.has(typeKey)) {
376+
typeData.typeCount = 1;
377+
} else {
378+
typeData.typeCount++;
379+
}
378380

379-
//Icon
380-
var icon_data = Waymark.build_icon_data(type);
381-
382-
//Marker DIV
383-
overlay_preview
384-
.addClass(icon_data.className)
385-
.html(icon_data.html)
386-
.css({
387-
'width': icon_data.iconSize[0],
388-
'height': icon_data.iconSize[1]
389-
})
390-
;
391-
392-
*/
393-
clusterHTML += '<div class="' + typeData.iconData.className + '" style="width:' + typeData.iconData.iconSize[0] + 'px;height:' + typeData.iconData.iconSize[1] + 'px;">' + typeData.iconData.html + '</div>';
381+
clusterTypes.set(typeKey, typeData);
394382
});
395383

396384
console.debug(clusterTypes);
397385

386+
//Build HTML
387+
let clusterHTML = '<div class="waymark-cluster">';
388+
389+
clusterTypes.forEach((typeData, index) => {
390+
clusterHTML += ' <div class="' + typeData.iconData.className + '" style="width:' + typeData.iconData.iconSize[0] + 'px;height:' + typeData.iconData.iconSize[1] + 'px;">' + typeData.iconData.html + '</div>';
391+
})
392+
393+
clusterHTML += '</div>';
394+
398395
return L.divIcon({ html: clusterHTML });
399396
}
400397
});

0 commit comments

Comments
 (0)