map: work with no or little nodes

This commit is contained in:
Nils Schneider 2015-07-07 21:28:44 +02:00
parent e67c61d7d3
commit 02a03e5a61
2 changed files with 12 additions and 3 deletions

View file

@ -327,6 +327,12 @@ define(["map/clientlayer", "map/labelslayer",
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])

View file

@ -155,7 +155,10 @@ define(["leaflet", "rbush"],
return undefined
}).filter(function (d) { return d !== undefined })
this.margin = 16 + labels.map(function (d) {
this.margin = 16
if (labels.length > 0)
this.margin += labels.map(function (d) {
return d.width
}).sort().reverse()[0]