Networkmap bugfix
[ccsdk/features.git] / sdnr / wt / odlux / apps / networkMapApp / src / utils / mapUtils.ts
index 34cdc06..da3e97e 100644 (file)
@@ -21,6 +21,17 @@ const EARTHRADIUSM = 6378137;
 type updatedCoordinates = { south: number, west: number, north: number, east: number };
 
 
+export const increaseBoundingBox = (map: mapboxgl.Map) =>{
+
+    const bbox = map.getBounds();
+
+    const distance = map.getCenter().distanceTo(bbox.getNorthEast()); // radius of visible area (center -> corner) (in meters)
+
+    //calculate new boundingBox
+    const increasedBoundingBox = addDistance(bbox.getSouth(), bbox.getWest(), bbox.getNorth(), bbox.getEast(), (distance / 1000) / 2);
+    return increasedBoundingBox;
+}
+
 
 
 export const addDistance = (south: number, west: number, north: number, east: number, distanceKm: number): updatedCoordinates => {