diff --git a/src/views/Map.js b/src/views/Map.js index 085a453..5cd426f 100644 --- a/src/views/Map.js +++ b/src/views/Map.js @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useLayoutEffect } from 'react'; +import React, {useEffect, useState, useLayoutEffect } from 'react'; import MapView, { Circle, PROVIDER_GOOGLE, } from 'react-native-maps'; import Constants from 'expo-constants'; import { Text, Container, View, Icon } from 'native-base'; @@ -8,7 +8,6 @@ import { User, WeatherContainer, LightBeacon, NavigationLine, NauticalWarning, D import { digiTrafficService, firebaseService, finnshTransportService } from '../services'; import { Distance } from '../utilities'; import { mapStyles } from '../styles'; -import Speedometer from 'react-native-speedometer-chart'; const apiURL = 'https://pfa.foreca.com'; @@ -65,8 +64,8 @@ const Map = ({ navigation }) => { const proximityAlert = Distance.isDistanceLessThen(updateVessel, lastLatitude, lastLongitude, alertRadius); - if (proximityAlert) { - if (!vesselsInProximity.some(vesselInProximity => vesselInProximity.id === updateVessel.id)) { + if ( proximityAlert ){ + if ( !vesselsInProximity.some( vesselInProximity => vesselInProximity.id === updateVessel.id) ) { setVesselsInProximity([...vesselsInProximity, updateVessel]); } } else { @@ -131,13 +130,13 @@ const Map = ({ navigation }) => { }) } - const updateLightBeacons = (latestLatitude, latestLongitude) => { - finnshTransportService.updateLightBeacons(latestLongitude, latestLatitude) - .then(lightBeacons => { - if (lightBeacons && lightBeacons.length > 0) { - setLightBeacons(lightBeacons); - } - }) + const updateLightBeacons = (latestLatitude, latestLongitude) => { + finnshTransportService.updateLightBeacons(latestLongitude,latestLatitude) + .then( lightBeacons => { + if ( lightBeacons && lightBeacons.length > 0 ){ + setLightBeacons(lightBeacons); + } + }) } const updateSurroundingDigiTrafficVessels = (latestLatitude, latestLongitude) => { @@ -212,7 +211,7 @@ const Map = ({ navigation }) => { { toggleSwitch() }}> Mode @@ -247,8 +246,8 @@ const Map = ({ navigation }) => { } }, [isLocationUpdateFirstTime]); - useEffect(() => { - if (isVesselsFirstLoad) { + useEffect( () => { + if ( isVesselsFirstLoad ){ const vesselsInProximity = vessels.filter(vessel => { return Distance.isDistanceLessThen(vessel, lastLatitude, lastLongitude, alertRadius); @@ -260,7 +259,7 @@ const Map = ({ navigation }) => { }, [isVesselsFirstLoad]); useEffect(() => { - if (vesselsInProximity.length > 0) { + if ( vesselsInProximity.length > 0 ){ setIsCollisionDetected(true); } else { setIsCollisionDetected(false); @@ -296,7 +295,7 @@ const Map = ({ navigation }) => { /> { radius={alertRadius * 1000} fillColor={'rgba(255, 0, 0, 0.2)'} strokeColor="rgba(0,0,0,0.5)" - />} + /> } {/* TODO move following code to new component SpeedMeter*/} - `${ number } knot`} - percentStyle={{ color: '#ff6e40' }} - /> + + {(lastSpeed * METER_TO_KILOMETER_CONSTANT).toFixed(1)} Km/h + + + {(lastSpeed * METER_TO_KNOT_CONSTANT).toFixed(1)} Knots +