import { INITIAL_LOCATION } from '../../../common/constants' ; import { Goto , MapCenterAndZoom } from '../../../common/descriptor_types' ; import { MapSettings } from '../../reducers/map' ; export async function getInitialView ( goto , settings ) { if ( settings . initialLocation === INITIAL_LOCATION . FIXED_LOCATION ) { return { lat : settings . fixedLocation . lat , lon : settings . fixedLocation . lon , zoom : settings . fixedLocation . zoom , } ; } if ( settings . initialLocation === INITIAL_LOCATION . BROWSER_LOCATION ) { return await new Promise ( ( resolve , reject ) => { navigator . geolocation . getCurrentPosition ( ( pos ) => { resolve ( { lat : pos . coords . latitude , lon : pos . coords . longitude , zoom : settings . browserLocation . zoom , } ) ; } , ( ) => { console . warn ( 'Unable to fetch browser location for initial map location' ) ; resolve ( null ) ; } ) ; } ) ; } if ( settings . initialLocation === INITIAL_LOCATION . AUTO_FIT_TO_BOUNDS ) { return null ; } return goto && goto . center ? goto . center : null ; }