@draganfilipovic/confluence-map
Advanced tools
Comparing version 1.2.13 to 1.2.14
{ | ||
"name": "@draganfilipovic/confluence-map", | ||
"version": "1.2.13", | ||
"version": "1.2.14", | ||
"description": "embed OSM into Confluence pages", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -12,3 +12,3 @@ import { config } from './config.js'; | ||
this.addTiles(map); | ||
this.addMarkers(map, NS.state); | ||
this.addMarkers(map, NS.state, NS.center); | ||
@@ -32,10 +32,15 @@ return map; | ||
addMarkers(map, state) { | ||
addMarkers(map, state, center) { | ||
NS.L.Icon.Default.imagePath = `${config.LEAFLET.PATH}/images/`; | ||
Object.values(state).forEach(({ location, label }) => { | ||
const marker = NS.L.marker(location); | ||
marker.bindPopup(label).openPopup(); | ||
marker.addTo(map); | ||
}) | ||
this.addMarker(map, location, label); | ||
}); | ||
this.addMarker(map, center, 'Center'); | ||
} | ||
addMarker(map, location, label) { | ||
const marker = NS.L.marker(location); | ||
marker.bindPopup(label).openPopup(); | ||
marker.addTo(map); | ||
} | ||
} |
class NameSpace { | ||
constructor(name) { | ||
this._center = [0, 0]; | ||
this._state = {}; | ||
@@ -26,3 +27,24 @@ this._config = {}; | ||
}; | ||
if (typeof active === 'boolean') { | ||
this.updateCenter(); | ||
} | ||
} | ||
get center() { | ||
return this._center; | ||
} | ||
updateCenter() { | ||
const list = Object.values(this.state) | ||
.map(({ location }) => location.map(l => Number(l))); | ||
const size = list.length; | ||
if (size === 1) { | ||
return list; | ||
} | ||
this._center = list.reduce((acc, curr) => { | ||
return [acc[0] + curr[0]/size, acc[1] + curr[1]/size] | ||
}, [0, 0]); | ||
} | ||
} | ||
@@ -29,0 +51,0 @@ |
@@ -24,3 +24,3 @@ import { NS } from './ns.js'; | ||
this.multiRoutingControl = this.multiRoutingControl || {}; | ||
const center = this.getCenter(); | ||
const center = NS.center; | ||
const centerPoint = NS.L.latLng(center[0], center[1]); | ||
@@ -85,15 +85,6 @@ console.log({ centerPoint, waypoints }); | ||
async zoomToCenter() { | ||
const points = Object.values(NS.state).map(({ location }) => location); | ||
const points = Object.values(NS.cen).map(({ location }) => location); | ||
await NS.map.fitBounds(points); | ||
return this.__sleep(300); | ||
} | ||
getCenter() { | ||
const list = Object.values(NS.state) | ||
.map(({ location }) => location.map(l => Number(l))); | ||
const size = list.length; | ||
return list.reduce((acc, curr) => { | ||
return [acc[0] + curr[0]/size, acc[1] + curr[1]/size] | ||
}, [0, 0]); | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44592
462