[TASK] FixedCenter required
This commit is contained in:
parent
4f30c9af27
commit
7f2ab672c2
@ -12,6 +12,7 @@
|
||||
- Load only german locale from 101 languages from moment.js
|
||||
- Right click open layermenu
|
||||
- Remove ruby dependency
|
||||
- FixedCenter is required
|
||||
|
||||
# Screenshots
|
||||
|
||||
|
41
lib/map.js
41
lib/map.js
@ -1,7 +1,7 @@
|
||||
define(["map/clientlayer", "map/labelslayer",
|
||||
"d3", "leaflet", "moment", "locationmarker", "rbush", "helper",
|
||||
"leaflet", "moment", "locationmarker", "rbush", "helper",
|
||||
"leaflet.label", "leaflet.providers", "moment.de"],
|
||||
function (ClientLayer, LabelsLayer, d3, L, moment, LocationMarker, rbush, helper) {
|
||||
function (ClientLayer, LabelsLayer, L, moment, LocationMarker, rbush, helper) {
|
||||
var options = {
|
||||
worldCopyJump: true,
|
||||
zoomControl: false
|
||||
@ -427,41 +427,6 @@ define(["map/clientlayer", "map/labelslayer",
|
||||
}
|
||||
}
|
||||
|
||||
function calcBarycenter(nodes) {
|
||||
nodes = nodes.map(function (d) {
|
||||
return d.nodeinfo.location;
|
||||
});
|
||||
|
||||
if (nodes.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var lats = nodes.map(function (d) {
|
||||
return d.latitude;
|
||||
});
|
||||
var lngs = nodes.map(function (d) {
|
||||
return d.longitude;
|
||||
});
|
||||
|
||||
var barycenter = L.latLng(d3.median(lats), d3.median(lngs));
|
||||
var barycenterDev = [d3.deviation(lats), d3.deviation(lngs)];
|
||||
|
||||
if (barycenterDev[0] === undefined) {
|
||||
barycenterDev[0] = 0;
|
||||
}
|
||||
|
||||
if (barycenterDev[1] === undefined) {
|
||||
barycenterDev[1] = 0;
|
||||
}
|
||||
|
||||
var barycenterCircle = L.latLng(barycenter.lat + barycenterDev[0],
|
||||
barycenter.lng + barycenterDev[1]);
|
||||
|
||||
var r = barycenter.distanceTo(barycenterCircle);
|
||||
|
||||
return L.circle(barycenter, r * config.mapSigmaScale);
|
||||
}
|
||||
|
||||
function mapRTree(d) {
|
||||
var o = [d.nodeinfo.location.latitude, d.nodeinfo.location.longitude,
|
||||
d.nodeinfo.location.latitude, d.nodeinfo.location.longitude];
|
||||
@ -499,7 +464,7 @@ define(["map/clientlayer", "map/labelslayer",
|
||||
groupLines = L.featureGroup(lines).addTo(map);
|
||||
|
||||
if (typeof config.fixedCenter === "undefined") {
|
||||
barycenter = calcBarycenter(data.nodes.all.filter(has_location));
|
||||
console.error('FixedCenter is required');
|
||||
} else {
|
||||
barycenter = L.circle(L.latLng(new L.LatLng(config.fixedCenter.lat, config.fixedCenter.lng)), config.fixedCenter.radius * 1000);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user