function loadScript() {
     	var script = document.createElement('script');
     	script.type = 'text/javascript';
     	script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyAgYK3ytwWRRFM3OHhKQ88Uezpt3i-4NQI'
     	document.body.appendChild(script);
     	getLocation()
     }

     window.onload = loadScript;
     
     function savePosition(position) {   
         $.ajax({
          	url: "/profile/editLastCoord?lat="+position.coords.latitude+"&lng="+position.coords.longitude
          	});
             }
      function errorCallback(pos) { console.log("Error happened on geolocation.watchPosition!"); }
      function getLocation() {
          if (navigator.geolocation) {
            watchOpts = {
              enableHighAccuracy:true,
              timeout:60000,
              maximumAge:0
            };
            navigator.geolocation.watchPosition(savePosition, errorCallback, watchOpts);
          } 
      }