|
|
@ -16448,7 +16448,7 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) { |
|
|
|
"class": "GlobalMapPage" |
|
|
|
"class": "GlobalMapPage" |
|
|
|
}, m("div", { |
|
|
|
}, m("div", { |
|
|
|
className: "container" |
|
|
|
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" |
|
|
|
className: "global-map" |
|
|
|
}))); |
|
|
|
}))); |
|
|
|
}; |
|
|
|
}; |
|
|
@ -16458,8 +16458,6 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
_proto.onupdate = function onupdate(vnode) { |
|
|
|
_proto.onupdate = function onupdate(vnode) { |
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dom = vnode.dom; |
|
|
|
var dom = vnode.dom; |
|
|
|
var mapElements = dom.getElementsByClassName('global-map'); |
|
|
|
var mapElements = dom.getElementsByClassName('global-map'); |
|
|
|
|
|
|
|
|
|
|
@ -16468,7 +16466,7 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) { |
|
|
|
var mapElement = mapElements[0]; |
|
|
|
var mapElement = mapElements[0]; |
|
|
|
var publicToken = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('justoverclock-users-map-location.mapBox-api-key'); |
|
|
|
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 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, |
|
|
|
iconUrl: markerIconPath, |
|
|
|
iconSize: [25, 41], |
|
|
|
iconSize: [25, 41], |
|
|
|
// size of the icon
|
|
|
|
// size of the icon
|
|
|
@ -16485,33 +16483,47 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) { |
|
|
|
accessToken: publicToken |
|
|
|
accessToken: publicToken |
|
|
|
}).addTo(this.map); |
|
|
|
}).addTo(this.map); |
|
|
|
this.map.setView([47, 2], 6); |
|
|
|
this.map.setView([47, 2], 6); |
|
|
|
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().store.find('user-locations', { |
|
|
|
this.userMarkers = L.markerClusterGroup({ |
|
|
|
page: { |
|
|
|
maxClusterRadius: 40 |
|
|
|
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.map.addLayer(this.userMarkers); // begin fetching users
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.fetchUsers(0); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.map = null; |
|
|
|
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; |
|
|
|
return GlobalMapPage; |
|
|
|
}((flarum_common_components_Page__WEBPACK_IMPORTED_MODULE_2___default())); |
|
|
|
}((flarum_common_components_Page__WEBPACK_IMPORTED_MODULE_2___default())); |
|
|
|
|
|
|
|
|
|
|
|