PageSourceSearch

https://treasuresjewelryky.com/Scripts/Templates/googleMaps.js

js treasuresjewelryky.com collected 2026-09-29 03:42:36 UTC 4,572 bytes, 165 lines download raw bytes

1var map = '';
2var mapLoc = '';
3var originalAddress = '';
4var mapCoords = [];
5var mapCenter;
6
7function loadGoogleMap() {
8    $("#map").prependTo("#contact-content");
9    $('#map').append($('#map_canvas'));
10    $('#map').append($('#largerMap'));
11
12	$('#map_canvas').show();
13	$.when(loadGoogleMaps(3, 'AIzaSyDJpKDM2NxOFscKEYcHVjMQUo-Fo0_oREU', 'english'))
14	.then(function () {
15	    !!google.maps;
16	    mapLoc = $('#smallmapaddress').text();
17	    originalAddress = mapLoc;
18	    mapLoc = mapLoc.replace(/(\r\n|\n|\r|,|\r)/gm, "");
19
20	    LoadLocation(mapLoc);
21	});
22}
23
24function isMapCoordinates(value) {
25    //https://stackoverflow.com/a/3518546
26    return /^(\-?\d+(\.\d+)?)\,+\s*(\-?\d+(\.\d+)?)$/.test(value);
27}
28
29function LoadLocation(address) {
30    setTimeout(function () {
31        map = '';
32        geocoder = new google.maps.Geocoder();
33        geocoder.geocode({
34            'address': address
35        }, function (results, status) {
36            if (status == google.maps.GeocoderStatus.OK) {
37
38                if (isMapCoordinates(originalAddress)) {
39                    mapCoords = originalAddress.split(",").map(function (item) { return parseFloat(item.trim()); });
40                }
41
42                if (mapCoords[0] !== undefined && mapCoords[1] !== undefined) {
43                    mapCenter = new google.maps.LatLng(mapCoords[0], mapCoords[1]);
44                }
45                else {
46                    mapCenter = results[0].geometry.location;
47                }
48
49                var location_type = results[0].geometry.location_type;
50
51                var languageElemExists = document.getElementById("approximateLanguage");
52                if (!isMapCoordinates(originalAddress) && languageElemExists == null) {
53                    var mapWarning = '<div class="mapApproximateLanguage" id="approximateLanguage">The pin indicator on the map is only an approximate location.</div>';
54                    $('#largerMap').prepend(mapWarning);
55                }
56                var myOptions = {
57                    zoom: 17,
58                    center: mapCenter,
59                    mapTypeId: google.maps.MapTypeId.ROADMAP
60                };
61                map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
62
63                var marker = new google.maps.Marker({
64                    map: map,
65                    position: mapCenter
66                });
67
68                google.maps.event.addListenerOnce(map, 'idle', function () {
69                    mapLoaded = true;
70                });
71            } else {
72                LoadMap();
73            }
74        });
75    }, 1000);
76}
77
78function LoadMap(position) {
79
80  if (!position) {
81    var mapOptions = {
82      center: new google.maps.LatLng(-34.397, 150.644), zoom: 17
83    };
84  } else {
85    var mapOptions = {
86      center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude), zoom: 17
87    };
88  }
89
90  var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
91}
92
93var loadGoogleMaps = (function ($) {
94
95  var now = Date.now(),
96
97        promise;
98
99  return function (version, apiKey, language) {
100
101    if (promise) {
102      return promise;
103    }
104
105    var deferred = $.Deferred(),
106
107            resolve = function () {
108              deferred.resolve(window.google && google.maps ? google.maps : false);
109            },
110
111            callbackName = "loadGoogleMaps_" + (now++),
112
113            params = $.extend({
114              'sensor': false
115            }, apiKey ? {
116              "key": apiKey
117            } : {}, language ? {
118              "language": language
119            } : {}); ;
120
121    if (window.google && google.maps) {
122
123      resolve();
124
125    } else if (window.google && google.load) {
126
127      google.load("maps", version || 3, {
128        "other_params": $.param(params),
129        "callback": resolve
130      });
131
132    } else {
133
134      params = $.extend(params, {
135        'v': version || 3,
136        'callback': callbackName
137      });
138
139      window[callbackName] = function () {
140
141        resolve();
142
143        setTimeout(function () {
144          try {
145            delete window[callbackName];
146          } catch (e) { }
147        }, 20);
148      };
149
150      $.ajax({
151        dataType: 'script',
152        data: params,
153        url: 'https://maps.google.com/maps/api/js',
154        success: function () {
155        }
156      });
157
158    }
159
160    promise = deferred.promise();
161
162    return promise;
163  };
164
165} (jQuery));

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.