Subversion Repositories SmartDukaan

Rev

Rev 23783 | Rev 23946 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23783 Rev 23837
Line 22... Line 22...
22
	$('#retailerAddressState').live('change', function() { 
22
	$('#retailerAddressState').live('change', function() { 
23
	    var stateName = $(this).find('option:selected').text();
23
	    var stateName = $(this).find('option:selected').text();
24
	    loadDistrictNames(stateName);
24
	    loadDistrictNames(stateName);
25
	});
25
	});
26
	
26
	
-
 
27
	var actualLatitude = $('.fofo-store-latitude').val();
-
 
28
	var actualLongitude = $('.fofo-store-longitude').val();
-
 
29
	if(actualLatitude != null && actualLongitude != null){
-
 
30
		navigator.geolocation.getCurrentPosition(
-
 
31
			function showPosition(position) {
-
 
32
				console.log("actualLatitude : "+actualLatitude);
-
 
33
				console.log("actualLongitude : "+actualLongitude);
-
 
34
				console.log("latitude : "+position.coords.latitude);
-
 
35
				console.log("longitude : "+position.coords.longitude);
-
 
36
				var distance = getDistance(actualLatitude, actualLongitude, position.coords.latitude, position.coords.longitude);
-
 
37
				$('.fofo-store-distance-in-meter>span').text(distance * 1000);
-
 
38
				$('.fofo-store-distance').val(distance * 1000);
-
 
39
			}
-
 
40
		);
-
 
41
	}
27
});
42
});
28
 
43
 
-
 
44
function getDistance(lat1, lon1, lat2, lon2) {
-
 
45
	  var deg2rad = 0.017453292519943295; // === Math.PI / 180
-
 
46
	  var cos = Math.cos;
-
 
47
	  lat1 *= deg2rad;
-
 
48
	  lon1 *= deg2rad;
-
 
49
	  lat2 *= deg2rad;
-
 
50
	  lon2 *= deg2rad;
-
 
51
	  var diam = 12742; // Diameter of the earth in km (2 * 6371)
-
 
52
	  var dLat = lat2 - lat1;
-
 
53
	  var dLon = lon2 - lon1;
-
 
54
	  var a = (
-
 
55
	    (1 - cos(dLat)) +
-
 
56
	    (1 - cos(dLon)) * cos(lat1) * cos(lat2)
-
 
57
	  ) / 2;
-
 
58
	
-
 
59
	  return parseFloat(diam * Math.asin(Math.sqrt(a))).toFixed(2);
-
 
60
  }
-
 
61
 
-
 
62
 
29
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber){
63
function getRetailerDetailsByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber){
30
	doGetAjaxRequestHandler(context+"/retailerDetails?emailIdOrMobileNumber="+emailIdOrMobileNumber, function(response){
64
	doGetAjaxRequestHandler(context+"/retailerDetails?emailIdOrMobileNumber="+emailIdOrMobileNumber, function(response){
31
		$('#' + domId).html(response);
65
		$('#' + domId).html(response);
32
	});
66
	});
33
}
67
}