PageSourceSearch

https://www.geico.com/public/scripts/geolocation.js

js geico.com collected 2026-09-24 08:33:02 UTC 3,024 bytes, 108 lines download raw bytes

1var timeout_time = 5000;
2var geo_type = ''; //default to returning zip data
3
4//get current geolocation position and send to coords_to_zip function
5function get_geo_data(type, source) {
6	if (source === undefined) {
7		source = '';
8	}
9	geo_type = type;
10	if (source == 'google') {
11		$.post("https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyAskAOptfxbD3ZKWxCxk4WwBRhJvU4HBdM", function (data) {
12			position = { coords: { latitude: data.location.lat, longitude: data.location.lng } };
13			coords_to_data(position);
14		});
15	}
16	else if (source == 'radar') {
17		$.ajax({
18			async: true,
19			cache: false,
20			url: "https://api.radar.io/v1/geocode/ip?ip=",
21			type: "GET",
22			headers: { 'Authorization': 'prj_live_pk_655593f19d4b923745728ffe7ca03f733a975ee2' },
23			success: function (data) {
24				position = { coords: { latitude: data.address.latitude, longitude: data.address.longitude } };
25				coords_to_data(position);
26			}
27		});
28    }
29	else {
30		navigator.geolocation.getCurrentPosition(coords_to_data);
31	}
32}
33
34//convert coordinates to a zip code through ajax call
35function coords_to_data(position) {
36	//show a geolocation loading marker if needed
37	$('.geo-loading-marker').show();
38
39	coords = { latitude: position.coords.latitude.toFixed(2), longitude: position.coords.longitude.toFixed(2) };
40
41	$.ajax({
42		async: true,
43		cache: false,
44		url: "/public/php/geo_data.php",
45		data: coords,
46		success: function (data) {
47			if (data == '') {
48				show_error();
49			} else {
50				switch (geo_type) {
51					case 'city':
52						geo_city_success(data[geo_type]);
53						break;
54
55					case 'state':
56						geo_state_success(data[geo_type]);
57						break;
58
59					case 'zip':
60						geo_zip_success(data[geo_type]);
61						break;
62
63					default:
64						geo_data_success(data);
65				}
66
67				//hide geolocation loading marker
68				$('.geo-loading-marker').hide();
69
70				//if DTM variables exist, update DTM tag with generalAction
71				if ((typeof geicoDtm !== 'undefined') && (typeof _gtm !== 'undefined')) {
72					geicoDtm["generalAction"] = "Static:ShareGeolocation";
73
74					if (typeof _gtm !== 'undefined') {
75						_gtm.track("updateDataNoPageturn");
76					}
77				}
78
79			}
80		},
81		error: function () {
82			//hide geolocation loading marker
83			$('.geo-loading-marker').hide();
84			alert('Could not determine your location at this time. Please try again later.');
85		},
86		timeout: timeout_time,
87	});
88}
89
90function get_distance(lat1, lon1, lat2, lon2, unit) {
91	//South latitudes are negative, east longitudes are positive    
92	//Unit options: M - miles (default), K - kilometers, N - nautical miles
93
94	var radlat1 = Math.PI * lat1 / 180;
95	var radlat2 = Math.PI * lat2 / 180;
96	var theta = lon1 - lon2;;
97	var radtheta = Math.PI * theta / 180;
98	var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
99	if (dist > 1) {
100		dist = 1;
101	}
102	dist = Math.acos(dist);
103	dist = dist * 180 / Math.PI;
104	dist = dist * 60 * 1.1515;
105	if (unit == "K") { dist = dist * 1.609344 }
106	if (unit == "N") { dist = dist * 0.8684 }
107	return dist;
108}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.