diff --git a/src/config.example.json b/src/config.example.json
index 07786f0..178a301 100644
--- a/src/config.example.json
+++ b/src/config.example.json
@@ -43,7 +43,10 @@
"roles": [
"000000000000000000"
],
- "geofences": []
+ "geofences": [],
+ "startLat": 4,
+ "startLon": -100,
+ "startZoom": 11
},
{
"name": "Guild Name2",
@@ -51,7 +54,10 @@
"roles": [
"000000000000000000"
],
- "geofences": []
+ "geofences": [],
+ "startLat": 5,
+ "startLon": -200,
+ "startZoom": 11
}
],
"userIdWhitelist": []
@@ -66,9 +72,6 @@
{ "name": "Shuffle" }
],
"map": {
- "startLat": 4,
- "startLon": -100,
- "startZoom": 10,
"minZoom": 8,
"maxZoom": 18,
"tileserver": "https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png;Map tiles by Carto, under CC BY 3.0. Data by OpenStreetMap, under ODbL."
diff --git a/src/data/default.js b/src/data/default.js
index 76d4f44..5f16502 100644
--- a/src/data/default.js
+++ b/src/data/default.js
@@ -31,9 +31,6 @@ data.sizes = [
{ name: 'Big', value: 5, },
];
// Leaflet map properties
-data.start_lat = config.map.startLat;
-data.start_lon = config.map.startLon;
-data.start_zoom = config.map.startZoom;
data.min_zoom = config.map.minZoom;
data.max_zoom = config.map.maxZoom;
data.tileserver = config.map.tileserver;
diff --git a/src/routes/api.js b/src/routes/api.js
index 0117ccb..3681c90 100644
--- a/src/routes/api.js
+++ b/src/routes/api.js
@@ -336,6 +336,23 @@ router.post('/server/:guild_id/user/:user_id', async (req, res) => {
},
});
break;
+ case 'get_map_settings':
+ const guild = config.discord.guilds.find(x => x.id === guild_id);
+ if (!guild) {
+ // Failed to get guild map settings
+ return null;
+ }
+ res.json({
+ data: {
+ start_lat: guild.startLat,
+ start_lon: guild.startLon,
+ start_zoom: guild.startZoom,
+ min_zoom: config.map.minZoom,
+ max_zoom: config.map.maxZoom,
+ tileserver: config.map.tileserver,
+ },
+ });
+ break;
}
});
diff --git a/src/views/invasions/edit.mustache b/src/views/invasions/edit.mustache
index 0997ee9..8ebf95e 100644
--- a/src/views/invasions/edit.mustache
+++ b/src/views/invasions/edit.mustache
@@ -77,5 +77,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver,
+ {{{cities}}}
+ );
+ },
+ });
diff --git a/src/views/invasions/new.mustache b/src/views/invasions/new.mustache
index da8fc10..89f47ab 100644
--- a/src/views/invasions/new.mustache
+++ b/src/views/invasions/new.mustache
@@ -101,7 +101,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver
+ );
+ },
+ });
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
diff --git a/src/views/locations/edit.mustache b/src/views/locations/edit.mustache
index 382b53f..8304062 100644
--- a/src/views/locations/edit.mustache
+++ b/src/views/locations/edit.mustache
@@ -34,5 +34,20 @@
diff --git a/src/views/locations/new.mustache b/src/views/locations/new.mustache
index 59b48f1..9120f99 100644
--- a/src/views/locations/new.mustache
+++ b/src/views/locations/new.mustache
@@ -34,5 +34,18 @@
\ No newline at end of file
diff --git a/src/views/lures/edit.mustache b/src/views/lures/edit.mustache
index 35779eb..67babff 100644
--- a/src/views/lures/edit.mustache
+++ b/src/views/lures/edit.mustache
@@ -72,5 +72,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver,
+ {{{cities}}}
+ );
+ },
+ });
diff --git a/src/views/lures/new.mustache b/src/views/lures/new.mustache
index 50218de..9373549 100644
--- a/src/views/lures/new.mustache
+++ b/src/views/lures/new.mustache
@@ -76,7 +76,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver
+ );
+ },
+ });
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
diff --git a/src/views/pokemon/edit.mustache b/src/views/pokemon/edit.mustache
index 9cecc0c..438587b 100644
--- a/src/views/pokemon/edit.mustache
+++ b/src/views/pokemon/edit.mustache
@@ -131,5 +131,19 @@
$('#iv_list').change(function() {
$('#iv').prop('disabled', this.value.length > 0);
});
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver,
+ {{{cities}}}
+ );
+ },
+ });
\ No newline at end of file
diff --git a/src/views/pokemon/new.mustache b/src/views/pokemon/new.mustache
index d5b4d75..0289ebe 100644
--- a/src/views/pokemon/new.mustache
+++ b/src/views/pokemon/new.mustache
@@ -154,7 +154,20 @@
$('#iv_list').change(function() {
$('#iv').prop('disabled', this.value.length > 0);
});
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver
+ );
+ },
+ });
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
diff --git a/src/views/pvp/edit.mustache b/src/views/pvp/edit.mustache
index cefcff0..4569688 100644
--- a/src/views/pvp/edit.mustache
+++ b/src/views/pvp/edit.mustache
@@ -97,5 +97,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver,
+ {{{cities}}}
+ );
+ },
+ });
\ No newline at end of file
diff --git a/src/views/pvp/new.mustache b/src/views/pvp/new.mustache
index 1d0c94c..fb8e0f3 100644
--- a/src/views/pvp/new.mustache
+++ b/src/views/pvp/new.mustache
@@ -124,7 +124,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver
+ );
+ },
+ });
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
diff --git a/src/views/quests/edit.mustache b/src/views/quests/edit.mustache
index d9c83d8..ac969b2 100644
--- a/src/views/quests/edit.mustache
+++ b/src/views/quests/edit.mustache
@@ -72,5 +72,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver,
+ {{{cities}}}
+ );
+ },
+ });
diff --git a/src/views/quests/new.mustache b/src/views/quests/new.mustache
index 8890bd9..400c968 100644
--- a/src/views/quests/new.mustache
+++ b/src/views/quests/new.mustache
@@ -83,7 +83,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver
+ );
+ },
+ });
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {
diff --git a/src/views/raids/edit.mustache b/src/views/raids/edit.mustache
index b178eda..325b538 100644
--- a/src/views/raids/edit.mustache
+++ b/src/views/raids/edit.mustache
@@ -79,5 +79,19 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}", {{{cities}}});
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver,
+ {{{cities}}}
+ );
+ },
+ });
diff --git a/src/views/raids/new.mustache b/src/views/raids/new.mustache
index c2b7a86..7d74adb 100644
--- a/src/views/raids/new.mustache
+++ b/src/views/raids/new.mustache
@@ -104,7 +104,20 @@
if (guilds) {
guilds.forEach(guild => guild.hidden = false);
}
- initMap([{{start_lat}}, {{start_lon}}], {{start_zoom}}, {{min_zoom}}, {{max_zoom}}, "{{{tileserver}}}");
+ $.ajax({
+ url: '/api/server/' + $('#server_selector').val() + '/user/{{user_id}}?type=get_map_settings',
+ method: 'POST',
+ type: 'json',
+ success: function(result) {
+ initMap(
+ [result.data.start_lat, result.data.start_lon],
+ result.data.start_zoom,
+ result.data.min_zoom,
+ result.data.max_zoom,
+ result.data.tileserver
+ );
+ },
+ });
fetchLocations($('#server_selector').val(), '{{user_id}}', function(result) {
for (const location of result.data.locations) {