From 8d22417789aadf794723baba0ed512b35e2d04f9 Mon Sep 17 00:00:00 2001 From: "ffggrz.de" Date: Wed, 16 Mar 2016 00:39:09 +0100 Subject: [PATCH] added fixed center option added option to fix the map on a specific coordinate --- README.md | 16 ++++++++++++++++ lib/map.js | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 04bd923..8b6100b 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,22 @@ property and optionally `url` and `config` properties. If no `url` is supplied `name` is assumed to name a [Leaflet-provider](http://leaflet-extras.github.io/leaflet-providers/preview/). +## fixedCenter (array, optional) + +This option allows to fix the map at one specific coordinate depending on following case-sensitive parameters: + +- `lat` latitude of the center point +- `lng` longitude of the center point +- `radius` visible radius around the center in km + +Examples for `fixedCenter`: + + "fixedCenter": { + "lat": 50.80, + "lng": 12.07, + "radius": 30 + } + ## nodeInfos (array, optional) This option allows to show node statistics depending on following case-sensitive parameters: diff --git a/lib/map.js b/lib/map.js index 712839e..43f75b6 100644 --- a/lib/map.js +++ b/lib/map.js @@ -447,7 +447,10 @@ define(["map/clientlayer", "map/labelslayer", var lines = addLinksToMap(linkDict, linkScale, data.graph.links, router) groupLines = L.featureGroup(lines).addTo(map) - barycenter = calcBarycenter(data.nodes.all.filter(has_location)) + if (typeof config.fixedCenter === "undefined") + barycenter = calcBarycenter(data.nodes.all.filter(has_location)) + else + barycenter = L.circle(L.latLng(new L.LatLng(config.fixedCenter.lat, config.fixedCenter.lng)), config.fixedCenter.radius * 1000) var nodesOnline = subtract(data.nodes.all.filter(online), data.nodes.new) var nodesOffline = subtract(data.nodes.all.filter(offline), data.nodes.lost)