|
|
|
@ -16448,7 +16448,7 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
|
|
|
|
|
"class": "GlobalMapPage" |
|
|
|
|
}, m("div", { |
|
|
|
|
className: "container" |
|
|
|
|
}, m("h2", null, translate('justoverclock-users-map-location.forum.global-map.title2')), m("div", { |
|
|
|
|
}, m("h2", null, translate('justoverclock-users-map-location.forum.global-map.title2')), m("p", null, translate('justoverclock-users-map-location.forum.global-map.description')), m("div", { |
|
|
|
|
className: "global-map" |
|
|
|
|
}))); |
|
|
|
|
}; |
|
|
|
@ -16458,8 +16458,6 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
_proto.onupdate = function onupdate(vnode) { |
|
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
var dom = vnode.dom; |
|
|
|
|
var mapElements = dom.getElementsByClassName('global-map'); |
|
|
|
|
|
|
|
|
@ -16468,7 +16466,7 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
|
|
|
|
|
var mapElement = mapElements[0]; |
|
|
|
|
var publicToken = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('justoverclock-users-map-location.mapBox-api-key'); |
|
|
|
|
var markerIconPath = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; |
|
|
|
|
var markerIcon = L.icon({ |
|
|
|
|
this.userMarkerIcon = L.icon({ |
|
|
|
|
iconUrl: markerIconPath, |
|
|
|
|
iconSize: [25, 41], |
|
|
|
|
// size of the icon
|
|
|
|
@ -16485,33 +16483,47 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
|
|
|
|
|
accessToken: publicToken |
|
|
|
|
}).addTo(this.map); |
|
|
|
|
this.map.setView([47, 2], 6); |
|
|
|
|
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().store.find('user-locations', { |
|
|
|
|
page: { |
|
|
|
|
limit: 1000 |
|
|
|
|
} |
|
|
|
|
}).then(function (response) { |
|
|
|
|
var markers = L.markerClusterGroup({ |
|
|
|
|
maxClusterRadius: 40 |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (var _iterator = _createForOfIteratorHelperLoose(response), _step; !(_step = _iterator()).done;) { |
|
|
|
|
var item = _step.value; |
|
|
|
|
var user = item.data.attributes; |
|
|
|
|
var marker = L.marker([parseFloat(user.location_latitude), parseFloat(user.location_longitude)], { |
|
|
|
|
icon: markerIcon |
|
|
|
|
}); |
|
|
|
|
marker.bindPopup('<a href="/u/' + escapeHtml(user.username) + '">' + escapeHtml(user.displayName) + '</a>'); |
|
|
|
|
markers.addLayer(marker); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_this.map.addLayer(markers); |
|
|
|
|
this.userMarkers = L.markerClusterGroup({ |
|
|
|
|
maxClusterRadius: 40 |
|
|
|
|
}); |
|
|
|
|
this.map.addLayer(this.userMarkers); // begin fetching users
|
|
|
|
|
|
|
|
|
|
this.fetchUsers(0); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
this.map = null; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
_proto.fetchUsers = function fetchUsers(offset) { |
|
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
var maxLocationsPerRequest = 50; |
|
|
|
|
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().store.find('user-locations', { |
|
|
|
|
page: { |
|
|
|
|
limit: maxLocationsPerRequest, |
|
|
|
|
offset: offset |
|
|
|
|
} |
|
|
|
|
}).then(function (response) { |
|
|
|
|
for (var _iterator = _createForOfIteratorHelperLoose(response), _step; !(_step = _iterator()).done;) { |
|
|
|
|
var item = _step.value; |
|
|
|
|
var user = item.data.attributes; |
|
|
|
|
var marker = L.marker([parseFloat(user.location_latitude), parseFloat(user.location_longitude)], { |
|
|
|
|
icon: _this.userMarkerIcon |
|
|
|
|
}); |
|
|
|
|
marker.bindPopup('<a href="/u/' + escapeHtml(user.username) + '">' + escapeHtml(user.displayName) + '</a>'); |
|
|
|
|
|
|
|
|
|
_this.userMarkers.addLayer(marker); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (response.length == maxLocationsPerRequest) { |
|
|
|
|
// we need to fetch more users
|
|
|
|
|
_this.fetchUsers(offset + response.length); |
|
|
|
|
} else {// finished fetching all users
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return GlobalMapPage; |
|
|
|
|
}((flarum_common_components_Page__WEBPACK_IMPORTED_MODULE_2___default())); |
|
|
|
|
|
|
|
|
|