@osimatic/helpers-js 1.4.5 → 1.4.7
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/open_street_map.js +7 -5
- package/package.json +1 -1
package/open_street_map.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
class OpenStreetMap {
|
|
7
7
|
|
|
8
|
-
constructor(mapContainer, options) {
|
|
8
|
+
constructor(mapContainer, options={}) {
|
|
9
9
|
/*let [lat, lng] = button.data('coordinates').split(',');
|
|
10
10
|
let map = L.map('modal_map_canvas2').setView([lat, lng], 17);
|
|
11
11
|
|
|
@@ -29,7 +29,7 @@ class OpenStreetMap {
|
|
|
29
29
|
this.centerOnFrance();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
static createMap(mapContainer, options) {
|
|
32
|
+
static createMap(mapContainer, options={}) {
|
|
33
33
|
if (!mapContainer.length) {
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
@@ -39,12 +39,14 @@ class OpenStreetMap {
|
|
|
39
39
|
container._leaflet_id = null;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const map = L.map(mapContainer[0], options
|
|
42
|
+
const map = L.map(mapContainer[0], options);
|
|
43
43
|
|
|
44
44
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
45
45
|
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
|
46
46
|
}).addTo(map);
|
|
47
47
|
|
|
48
|
+
OpenStreetMap.centerOnFrance(map);
|
|
49
|
+
|
|
48
50
|
return map;
|
|
49
51
|
}
|
|
50
52
|
|
|
@@ -55,7 +57,7 @@ class OpenStreetMap {
|
|
|
55
57
|
|
|
56
58
|
static getUrlFromCoordinates(locationCoordinates) {
|
|
57
59
|
locationCoordinates = locationCoordinates.split(',');
|
|
58
|
-
return
|
|
60
|
+
return OpenStreetMap.getUrl(parseFloat(locationCoordinates[0]), parseFloat(locationCoordinates[1]));
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
setZoom(zoom) {
|
|
@@ -138,7 +140,7 @@ class OpenStreetMap {
|
|
|
138
140
|
}
|
|
139
141
|
|
|
140
142
|
static centerMapToGooglePlace(map, place) {
|
|
141
|
-
if (place
|
|
143
|
+
if (place && place.geometry && place.geometry.location) {
|
|
142
144
|
const loc = place.geometry.location;
|
|
143
145
|
OpenStreetMap.centerMapToCoordinates(map, loc.lat(), loc.lng());
|
|
144
146
|
}
|