From 7cbc4e75d779eb08c8093636b6780877e7007404 Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Wed, 8 Feb 2017 21:12:04 +0100 Subject: [PATCH] [TASK] Configure displayed map with rectangle --- README.md | 24 +++++++++++++----------- config.json | 18 +++++++++++++----- lib/map.js | 11 +---------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 02adacc..fb022a7 100644 --- a/README.md +++ b/README.md @@ -159,21 +159,23 @@ Start a time range to put this mapLayer on first position. End a time range for first map. Stops sort this mapLayer. -## fixedCenter (array, optional) +## fixedCenter (array[array, array]) -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 +Choose a rectangle that must be displayed on the map. Set 2 Locations and everything between will displayed. Examples for `fixedCenter`: - "fixedCenter": { - "lat": 50.80, - "lng": 12.07, - "radius": 30 - } + // Set a visible frame + "fixedCenter": [ + [ + 49.3522, + 11.7752 + ], + [ + 48.7480, + 12.8917 + ] + ], ## nodeInfos (array, optional) diff --git a/config.json b/config.json index 0cc85de..fd834dd 100644 --- a/config.json +++ b/config.json @@ -99,11 +99,19 @@ } } ], - "fixedCenter": { - "lat": 49.01722, - "lng": 12.0969, - "radius": 45 - }, + // Set a visible frame + "fixedCenter": [ + // Northwest + [ + 49.3522, + 11.7752 + ], + // Southeast + [ + 48.7480, + 12.8917 + ] + ], "siteNames": [ { "site": "ffrgb-bat15", diff --git a/lib/map.js b/lib/map.js index 5811b6e..13e4e5c 100644 --- a/lib/map.js +++ b/lib/map.js @@ -154,7 +154,6 @@ define(['map/clientlayer', 'map/labelslayer', return function (config, linkScale, sidebar, router, buttons) { var self = this; - var barycenter; var groupOnline; var groupOffline; var groupNew; @@ -345,9 +344,7 @@ define(['map/clientlayer', 'map/labelslayer', } function resetZoom() { - if (barycenter) { - setView(barycenter.getBounds()); - } + setView(config.fixedCenter); } function goto(m) { @@ -431,12 +428,6 @@ define(['map/clientlayer', 'map/labelslayer', var lines = addLinksToMap(linkDict, linkScale, data.graph.links, router); groupLines = L.featureGroup(lines).addTo(map); - if (typeof config.fixedCenter === 'undefined') { - console.error('FixedCenter is required'); - } else { - barycenter = L.circle(L.latLng(new L.LatLng(config.fixedCenter.lat, config.fixedCenter.lng)), config.fixedCenter.radius * 1000); - } - var nodesOnline = helper.subtract(data.nodes.all.filter(helper.online), data.nodes.new); var nodesOffline = helper.subtract(data.nodes.all.filter(helper.offline), data.nodes.lost);