@osimatic/helpers-js 1.4.10 → 1.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/open_street_map.js +49 -45
  2. package/package.json +1 -1
@@ -45,7 +45,8 @@ class OpenStreetMap {
45
45
  attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
46
46
  }).addTo(map);
47
47
 
48
- OpenStreetMap.centerOnFrance(map);
48
+ const country = options['country'] || 'FR';
49
+ OpenStreetMap.centerMapOnCountry(map, country);
49
50
 
50
51
  return map;
51
52
  }
@@ -121,49 +122,51 @@ class OpenStreetMap {
121
122
  map.setView([46.52863469527167, 2.43896484375], 6);
122
123
  }
123
124
 
124
- static COUNTRY_BOUNDING_BOXES = {
125
- // Europe
126
- "fr": [[41.333, -5.142], [51.091, 9.559]], // France,
127
- "de": [[47.270, 5.866], [55.058, 15.041]], // Germany
128
- "es": [[27.642, -18.167],[43.792, 4.327]], // Spain incl. Canaries (approx)
129
- "it": [[36.619, 6.627], [47.095, 18.520]], // Italy
130
- "pt": [[36.840, -9.500], [42.280, -6.190]], // Portugal
131
- "be": [[49.497, 2.545], [51.505, 6.407]], // Belgium
132
- "nl": [[50.753, 3.358], [53.555, 7.227]], // Netherlands
133
- "ch": [[45.818, 5.957], [47.808, 10.492]], // Switzerland
134
- "at": [[46.372, 9.530], [49.021, 17.162]], // Austria
135
- "gb": [[49.959, -8.649], [59.478, 1.759]], // United Kingdom,
136
- "ie": [[51.390, -10.480],[55.387, -5.432]], // Ireland
137
- "pl": [[49.003, 14.123], [54.836, 24.145]], // Poland
138
- "se": [[55.340, 11.112], [69.061, 24.177]], // Sweden
139
- "no": [[57.980, 4.500], [71.188, 31.078]], // Norway (Mainland approx)
140
- "fi": [[59.810, 20.556], [70.092, 31.586]], // Finland
141
- "dk": [[54.560, 8.089], [57.752, 12.690]], // Denmark
142
-
143
- // Afrique / Moyen-Orient
144
- "ma": [[27.662, -13.172],[35.922, -0.996]], // Morocco
145
- "dz": [[18.976, -8.669], [37.093, 11.999]], // Algeria
146
- "tn": [[30.233, 7.524], [37.544, 11.598]], // Tunisia
147
- "eg": [[21.725, 24.700], [31.667, 36.895]], // Egypt
148
- "za": [[-34.833, 16.470],[-22.126, 32.893]], // South Africa
149
- "sa": [[15.615, 34.495], [32.154, 55.666]], // Saudi Arabia
150
- "ae": [[22.634, 51.570], [26.084, 56.383]], // United Arab Emirates
151
- "il": [[29.487, 34.268], [33.277, 35.876]], // Israel
152
-
153
- // Amériques
154
- "us": [[24.396, -124.848],[49.384, -66.885]], // United States (Contiguous)
155
- "ca": [[41.675, -141.000],[83.113, -52.648]], // Canada
156
- "mx": [[14.538, -118.365],[32.720, -86.711]], // Mexico
157
- "br": [[-33.751, -73.987],[5.271, -34.729]], // Brazil
158
- "ar": [[-55.051, -73.582],[-21.781, -53.591]], // Argentina
159
-
160
- // Asie / Océanie
161
- "cn": [[18.159, 73.499], [53.560, 134.772]], // China (mainland approx)
162
- "in": [[6.554, 68.176], [35.674, 97.402]], // India
163
- "jp": [[24.249, 122.938],[45.557, 153.987]], // Japan
164
- "au": [[-43.740, 112.921],[-10.668, 153.639]], // Australia
165
- "nz": [[-47.290, 166.509],[-34.392, 178.517]], // New Zealand
166
- };
125
+ static getCountryBoundingBoxes() {
126
+ return {
127
+ // Europe
128
+ "fr": [[41.333, -5.142], [51.091, 9.559]], // France,
129
+ "de": [[47.270, 5.866], [55.058, 15.041]], // Germany
130
+ "es": [[27.642, -18.167], [43.792, 4.327]], // Spain incl. Canaries (approx)
131
+ "it": [[36.619, 6.627], [47.095, 18.520]], // Italy
132
+ "pt": [[36.840, -9.500], [42.280, -6.190]], // Portugal
133
+ "be": [[49.497, 2.545], [51.505, 6.407]], // Belgium
134
+ "nl": [[50.753, 3.358], [53.555, 7.227]], // Netherlands
135
+ "ch": [[45.818, 5.957], [47.808, 10.492]], // Switzerland
136
+ "at": [[46.372, 9.530], [49.021, 17.162]], // Austria
137
+ "gb": [[49.959, -8.649], [59.478, 1.759]], // United Kingdom,
138
+ "ie": [[51.390, -10.480], [55.387, -5.432]], // Ireland
139
+ "pl": [[49.003, 14.123], [54.836, 24.145]], // Poland
140
+ "se": [[55.340, 11.112], [69.061, 24.177]], // Sweden
141
+ "no": [[57.980, 4.500], [71.188, 31.078]], // Norway (Mainland approx)
142
+ "fi": [[59.810, 20.556], [70.092, 31.586]], // Finland
143
+ "dk": [[54.560, 8.089], [57.752, 12.690]], // Denmark
144
+
145
+ // Afrique / Moyen-Orient
146
+ "ma": [[27.662, -13.172], [35.922, -0.996]], // Morocco
147
+ "dz": [[18.976, -8.669], [37.093, 11.999]], // Algeria
148
+ "tn": [[30.233, 7.524], [37.544, 11.598]], // Tunisia
149
+ "eg": [[21.725, 24.700], [31.667, 36.895]], // Egypt
150
+ "za": [[-34.833, 16.470], [-22.126, 32.893]], // South Africa
151
+ "sa": [[15.615, 34.495], [32.154, 55.666]], // Saudi Arabia
152
+ "ae": [[22.634, 51.570], [26.084, 56.383]], // United Arab Emirates
153
+ "il": [[29.487, 34.268], [33.277, 35.876]], // Israel
154
+
155
+ // Amériques
156
+ "us": [[24.396, -124.848], [49.384, -66.885]], // United States (Contiguous)
157
+ "ca": [[41.675, -141.000], [83.113, -52.648]], // Canada
158
+ "mx": [[14.538, -118.365], [32.720, -86.711]], // Mexico
159
+ "br": [[-33.751, -73.987], [5.271, -34.729]], // Brazil
160
+ "ar": [[-55.051, -73.582], [-21.781, -53.591]], // Argentina
161
+
162
+ // Asie / Océanie
163
+ "cn": [[18.159, 73.499], [53.560, 134.772]], // China (mainland approx)
164
+ "in": [[6.554, 68.176], [35.674, 97.402]], // India
165
+ "jp": [[24.249, 122.938], [45.557, 153.987]], // Japan
166
+ "au": [[-43.740, 112.921], [-10.668, 153.639]], // Australia
167
+ "nz": [[-47.290, 166.509], [-34.392, 178.517]], // New Zealand
168
+ };
169
+ }
167
170
 
168
171
  static getCountryBoundingBox(countryIsoCode) {
169
172
  if (!countryIsoCode) {
@@ -171,7 +174,8 @@ class OpenStreetMap {
171
174
  }
172
175
 
173
176
  const key = countryIsoCode.toLowerCase().trim();
174
- return OpenStreetMap.COUNTRY_BOUNDING_BOXES[key] ? OpenStreetMap.COUNTRY_BOUNDING_BOXES[key] : null;
177
+ const countryBox = OpenStreetMap.getCountryBoundingBoxes()[key];
178
+ return countryBox ? countryBox : null;
175
179
  }
176
180
 
177
181
  static centerMapOnCountry(map, countryIsoCode, opts = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.4.10",
3
+ "version": "1.4.12",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"