 
 		$scope.etoggleLatLng = () ->
 			if(navigator.geolocation)
-				navigator.geolocation.getCurrentPosition(showPosition);
+				navigator.geolocation.getCurrentPosition(showPositionOnEdit);
 			else
 				alert("Browser not supported");
 			return true
+
 		$scope.updateJob = (editjob) ->
 			editjob.lat = $scope.editjob.lat;
 			editjob.lng = $scope.editjob.lng;

		$scope.lat = null;
		$scope.lng = null;
		$scope.editjob = {};
		$scope.map = {};
		$scope.emap = {};
		$scope.newjob = {};
		$scope.editjob = null;
		$scope.marker = {

		showPosition = (position) ->
			$scope.lat = position.coords.latitude;
			$scope.lng = position.coords.longitude;
			$scope.map.center = { latitude: $scope.lat, longitude: $scope.lng};
			$scope.marker.coord =  {latitude: $scope.lat, longitude: $scope.lng}; 
			$scope.$apply();
			return true
		
		showPositionOnEdit = (position) ->                                                                                                 
                        $scope.lat = position.coords.latitude;                                                                               
                        $scope.lng = position.coords.longitude;                                                                              
                        $scope.emap.center = { latitude: $scope.lat, longitude: $scope.lng};                                                  
                        $scope.emarker.coord =  {latitude: $scope.lat, longitude: $scope.lng};                                                
                        $scope.$apply();                                                                                                     
                        return true   	
	
		$scope.toggleLatLng = () ->                                                                                                  
                        if(navigator.geolocation)                                                                                            
                                navigator.geolocation.getCurrentPosition(showPosition);                                                      
                        else                                                                                                                 
                                alert("Browser not supported");                                                                              
                        return true                                                                                                          
                                                                                                                                             
                $scope.toggleLatLng();   

		$scope.$watchCollection 'marker.coord',(newValue, oldValue) -> 
			if(oldValue != newValue)
				$scope.lat = $scope.marker.coord.latitude
				$scope.lng = $scope.marker.coord.longitude
				$scope.map.center = {latitude: $scope.lat, longitude: $scope.lng};
				$http({url: '/getaddress', params: {lat: $scope.lat, lng: $scope.lng}}).then (response) -> 
					if response.data.result? 
						$scope.newjob.address = response.data.result

		$scope.$watchCollection 'emarker.coord', (newValue, oldValue) -> 
			if oldValue != newValue
				if $scope.editjob
					$scope.editjob.lat = $scope.emarker.coord.latitude
					$scope.editjob.lng = $scope.emarker.coord.longitude
					$scope.emap.center = {latitude: $scope.editjob.lat, longitude: $scope.editjob.lng};
					$http({url: '/getaddress', params: {lat: $scope.editjob.lat, lng: $scope.editjob.lng}}).then (response) ->
						if response.data.result?
							$scope.editjob.address = response.data.result

		$scope.edit = (job) ->
			$timeout ()->
				$scope.modalshow = true
