@osimatic/helpers-js 1.4.1 → 1.4.3

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.
package/location.js CHANGED
@@ -428,7 +428,7 @@ class PostalAddress {
428
428
  }
429
429
 
430
430
  class Polygon {
431
- static polygonSummary(geoJsonPolygon) {
431
+ static format(geoJsonPolygon) {
432
432
  const rings = geoJsonPolygon.coordinates || [];
433
433
  const ring0 = rings[0] || [];
434
434
  const n = ring0.length ? ring0.length - (JSON.stringify(ring0[0])===JSON.stringify(ring0[ring0.length-1]) ? 1 : 0) : 0;
@@ -21,22 +21,31 @@ class OpenStreetMap {
21
21
  this.markers = [];
22
22
  this.locations = [];
23
23
 
24
- if (!mapContainer.length) {
24
+ this.map = OpenStreetMap.createMap(mapContainer, options);
25
+ if (null === this.map) {
25
26
  return;
26
27
  }
27
28
 
29
+ this.centerOnFrance();
30
+ }
31
+
32
+ static createMap(mapContainer, options) {
33
+ if (!mapContainer.length) {
34
+ return null;
35
+ }
36
+
28
37
  const container = L.DomUtil.get(mapContainer[0]);
29
38
  if (container != null) {
30
39
  container._leaflet_id = null;
31
40
  }
32
41
 
33
- this.map = L.map(mapContainer[0], options || {});
42
+ const map = L.map(mapContainer[0], options || {});
34
43
 
35
44
  L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
36
- attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
37
- }).addTo(this.map);
45
+ attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
46
+ }).addTo(map);
38
47
 
39
- this.centerOnFrance();
48
+ return map;
40
49
  }
41
50
 
42
51
  static getUrl(latitude, longitude) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osimatic/helpers-js",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "main": "main.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"