import GoogleMapLoader from 'google-maps';
import Promise from 'bluebird';
import { forEach } from 'ramda';

import config from './config';

let map;
let googleObj;

export const setMapLocation = ({ maps }) => {
  if (navigator.geolocation) {
    navigator
      .geolocation
      .getCurrentPosition(
        ({ coords }) => map.setCenter(new maps.LatLng(coords.latitude, coords.longitude))
      );
  }
};

export const createWispMarkers = forEach(
  ({ lat, lng, message }) =>
    new googleObj.maps.Marker({ position: { lat, lng }, map })
    .addListener('click', () => console.log(message))
);

export const init = config =>
  new Promise(resolve => {
    // init google maps
    GoogleMapLoader.KEY = config.apiKey;
    GoogleMapLoader.load(google => {
      googleObj = google;
      map = new googleObj.maps.Map(document.querySelector('#map'), config.options);
      resolve(googleObj);
    });
  });

@@ -176,14 +176,15 @@
 nst 
-setMap
+getUser
 Loca
@@ -195,23 +195,52 @@
  = (
-%7B maps %7D
+) =%3E%0A  new Promise((resolve, reject
 ) =%3E %7B%0A
+  
   if
@@ -270,16 +270,18 @@
 ) %7B%0A    
+  
 navigato
@@ -281,23 +281,16 @@
 avigator
-%0A      
 .geoloca
@@ -294,16 +294,18 @@
 ocation%0A
+  
       .g
@@ -322,25 +322,16 @@
 osition(
-%0A        
 (%7B coord
@@ -331,22 +331,155 @@
 %7B coords
+ %7D) =%3E resolve(coords));%0A    %7D%0A  %7D);%0A%0Aexport const setMapLocation = (%7B maps %7D) =%3E%0A  getUserLocation().then((%7B latitude, longitude
  %7D) =%3E
+%0A   
  map.set
@@ -501,23 +501,16 @@
 .LatLng(
-coords.
 latitude
@@ -515,15 +515,8 @@
 de, 
-coords.
 long
@@ -529,20 +529,9 @@
 )%0A  
-    );%0A  %7D%0A%7D
+)
 ;%0A%0Ae

Add get user location util function