1//////////////////////////////////////////////////////////////////////////////////////// 2// Events // 3//////////////////////////////////////////////////////////////////////////////////////// 4//////////////////////////////////////////////////////////////////////////////////////// 5// Constants // 6//////////////////////////////////////////////////////////////////////////////////////// 7//////////////////////////////////////////////////////////////////////////////////////// 8// Variables // 9//////////////////////////////////////////////////////////////////////////////////////// 10var frontendData = []; 11var cnterLat, cnterLng; 12var ajaxData = {}; 13 14//////////////////////////////////////////////////////////////////////////////////////// 15// Constructor & Destructor // 16//////////////////////////////////////////////////////////////////////////////////////// 17 18function gmwdReadyFunction(key){ 19 // serach box 20 if(gmwdmapData["enableSerchBox" + key] == 1){ 21 initSerachBox(key); 22 } 23 // geolocate user 24 if(gmwdmapData["geolocateUser" + key] == 1){ 25 geoLocateUser(key); 26 } 27 28 //store locator 29 if(gmwdmapData["enableStoreLocatior" + key] == 1 && gmwdmapData["widget" + key] == 0){ 30 31 jQuery(".gmwd_my_location_store_locator" + key).click(function(){ 32 var input = jQuery("#gmwd_store_locator_address" + key); 33 getMyLocation(input); 34 }); 35
36 var input = /** @type {!HTMLInputElement} */( 37 document.getElementById('gmwd_store_locator_address' + key)); 38 39 var autocomplete = new google.maps.places.Autocomplete(input); 40 autocomplete.bindTo('bounds', gmwdmapData["main_map" + key]); 41 42 /*autocomplete.addListener('place_changed', function() { 43 var place = autocomplete.getPlace(); 44 if (!place.geometry) { 45 window.alert("Autocomplete's returned place contains no geometry"); 46 return; 47 } 48 cnterLat = place.geometry.location.lat(); 49 cnterLng = place.geometry.location.lng(); 50 });*/ 51 52 jQuery("#gmwd_store_locator_search" + key).click(function(){ 53 if(jQuery(".gmwd_store_locator_address" + key).val() == ""){ 54 alert("Please set location."); 55 return false; 56 } 57 if(gmwdmapDataOptions["storeLocatorCircle" + key]){ 58 gmwdmapDataOptions["storeLocatorCircle" + key].setMap(null); 59 } 60 if(gmwdmapData["storeLocatorDistanceIn" + key] == "km"){ 61 var radius = Number(jQuery("#gmwd_store_locator_radius" + key + " :selected").val())*1000; 62 } 63 else if(gmwdmapData["storeLocatorDistanceIn" + key] == "mile"){ 64 var radius = Number(jQuery("#gmwd_store_locator_radius" + key + " :selected").val())*1609.34; 65 } 66 67 var geocoder = new google.maps.Geocoder(); 68 geocoder.geocode({ 69 "address": jQuery(".gmwd_store_locator_address" + key).val() 70 }, function(results) { 71 cnterLat = results[0].geometry.location.lat(); 72 cnterLng = results[0].geometry.location.lng(); 73 74 gmwdmapData["ajaxData" + key]["map_id"] = gmwdmapData["mapId" + key]; 75 gmwdmapData["ajaxData" + key]["page"] = "map"; 76 gmwdmapData["ajaxData" + key]["action"] = "get_ajax_store_loactor"; 77 gmwdmapData["ajaxData" + key]["task"] = "get_ajax_store_loactor";
78 gmwdmapData["ajaxData" + key]["radius"] = Number(jQuery("#gmwd_store_locator_radius" + key + " :selected").val()); 79 gmwdmapData["ajaxData" + key]["lat"] = cnterLat; 80 gmwdmapData["ajaxData" + key]["lng"] = cnterLng; 81 gmwdmapData["ajaxData" + key]["distance_in"] = gmwdmapData["storeLocatorDistanceIn" + key]; 82 gmwdmapData["ajaxData" + key]["categories"] = []; 83 84 jQuery.post(ajaxURL, gmwdmapData["ajaxData" + key], function (response){ 85 86 gmwdmapData["mapMarkers" + key] = JSON.parse(response); 87 for(var i=0; i<gmwdmapData["allMarkers" + key].length; i++){ 88 gmwdmapData["allMarkers" + key][i].setMap(null); 89 } 90 gmwdmapData["allMarkers" + key] = []; 91 gmwdSetMapMarkers(key); 92 if(gmwdmapData["markerListInsideMap" + key] == 1){ 93 gmwdMarkerListInsideMap(key, gmwdmapData["mapMarkers" + key]); 94 } 95 }); 96 97 gmwdmapDataOptions["storeLocatorCircle" + key] = new google.maps.Circle({ 98 strokeWeight: 2, 99 strokeColor: "#000000", 100 strokeOpacity: 0.6, 101 fillColor: "#7FDF16", 102 fillOpacity: 0.3, 103 center: {lat : cnterLat, lng: cnterLng}, 104 radius: radius 105 }); 106 107 gmwdmapDataOptions["storeLocatorCircle" + key].setMap(gmwdmapData["main_map" + key]); 108 109 gmwdmapData["main_map" + key].setCenter({lat : cnterLat, lng: cnterLng}); 110 gmwdmapData["main_map" + key].setZoom(Number(gmwdmapData["zoom" + key])); 111 }); 112 113 return false; 114 115 }); 116 117 jQuery("#gmwd_store_locator_reset" + key).click(function(){ 118 if(gmwdmapDataOptions["storeLocatorCircle" + key]){ 119 gmwdmapDataOptions["storeLocatorCircle" + key].setMap(null); 120 } 121 gmwdmapData["ajaxData" + key] = {}; 122 gmwdmapData["ajaxData" + key]["map_id"] = gmwdmapData["mapId" + key]; 123 gmwdmapData["ajaxData" + key]["page"] = "map"; 124 gmwdmapData["ajaxData" + key]["action"] = "get_ajax_markers"; 125 gmwdmapData["ajaxData" + key]["task"] = "get_ajax_markers"; 126 127 jQuery.post(ajaxURL, gmwdmapData["ajaxData" + key], function (data){ 128 gmwdmapData["mapMarkers" + key] = JSON.parse(data); 129 for(var i=0; i<gmwdmapData["allMarkers" + key].length; i++){ 130 gmwdmapData["allMarkers" + key][i].setMap(null); 131 } 132 gmwdmapData["allMarkers" + key] = []; 133 gmwdSetMapMarkers(key); 134 135 }); 136 137 jQuery("#gmwd_store_locator_address" + key).val(""); 138 return false; 139 }); 140 141 } 142} 143//////////////////////////////////////////////////////////////////////////////////////// 144// Public Methods // 145//////////////////////////////////////////////////////////////////////////////////////// 146 147function gmwdSearch(fieldName, values, key ){ 148 gmwdmapData["ajaxData" + key]["page"] = "map"; 149 gmwdmapData["ajaxData" + key][fieldName] = values; 150 gmwdmapData["ajaxData" + key]["map_id"] = gmwdmapData["mapId" + key]; 151 gmwdmapData["ajaxData" + key]["action"] = "get_ajax_markers"; 152 gmwdmapData["ajaxData" + key]["task"] = "get_ajax_markers"; 153 154 jQuery.post(ajaxURL, gmwdmapData["ajaxData" + key], function (data){ 155 gmwdmapData["mapMarkers" + key] = JSON.parse(data); 156 for(var i=0; i<gmwdmapData["allMarkers" + key].length; i++){ 157 gmwdmapData["allMarkers" + key][i].setMap(null); 158 } 159 gmwdmapData["allMarkers" + key] = []; 160 gmwdSetMapMarkers(key); 161 162 }); 163 164} 165 166 167function geoLocateUser(key){ 168 if (navigator.geolocation) { 169 navigator.geolocation.getCurrentPosition(function(position) { 170 var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 171 var marker = new google.maps.Marker({ 172 map: gmwdmapData["main_map" + key], 173 position: latlng, 174 icon: GMWD_URL + '/images/geoloc.png' 175 }); 176 var geocoder = new google.maps.Geocoder(); 177 geocoder.geocode({"latLng":latlng},function(data,status){ 178 if(status == google.maps.GeocoderStatus.OK){ 179 var address = data[1].formatted_address; 180 181 gmwdmapData["main_map" + key].setCenter(latlng); 182 gmwdmapData["main_map" + key].setZoom(13); 183 var infoWindow = new google.maps.InfoWindow({map: gmwdmapData["main_map" + key]}); 184 infoWindow.setPosition(latlng); 185 var contentString = address; 186 if(gmwdmapData["enableDirections" + key] == 1 ){ 187 contentString += "<br> <a href='javascript:void(0)' data-lat='" + position.coords.latitude + "' data-lng='" +Number(position.coords.longitude) + "' data-address='" + address + "' class='gmwd_direction' onclick='showDirectionsBox(this);' data-key='" + key + "'>Get Directions</a>"; 188 } 189 infoWindow.setContent(contentString); 190 } 191 }); 192 193 }, function() { 194 alert('Error: Your browser doesn\'t support geolocation.'); 195 }); 196 } 197 else { 198 // Browser doesn't support Geolocation 199 alert('Error: Your browser doesn\'t support geolocation.'); 200 } 201} 202function getMyLocation(input){ 203 if (navigator.geolocation) { 204 navigator.geolocation.getCurrentPosition(function(position) { 205 var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); 206 var geocoder = new google.maps.Geocoder(); 207 geocoder.geocode({"latLng":latlng},function(data,status){ 208 if(status == google.maps.GeocoderStatus.OK){ 209 var address = data[1].formatted_address; 210 input.val(address); 211 cnterLat = data[1].geometry.location.lat(); 212 cnterLng = data[1].geometry.location.lng(); 213 } 214 }); 215 }); 216 } 217 else{ 218 alert("Browser doesn't support Geolocation."); 219 } 220 221} 222 223function initSerachBox(key){ 224 var input = document.createElement("input"); 225 input.id = "gmwd_serach_box" + key; 226 input.type = "text"; 227 input.style.cssText = "width:400px;"; 228 input.setAttribute("onkeypress", "if(event.keyCode == 13) return false;") ; 229 input.setAttribute("class", "gmwd_serach_box") ; 230 231 searchBox = new google.maps.places.SearchBox(input); 232 gmwdmapData["main_map" + key].controls[gmwdmapData["serchBoxPosition" + key]].push(input); 233 234 gmwdmapData["main_map" + key].addListener('bounds_changed', function() { 235 searchBox.setBounds( gmwdmapData["main_map" + key].getBounds()); 236 }); 237 238 searchBox.addListener('places_changed', function() { 239 var places = searchBox.getPlaces(); 240 var bounds = new google.maps.LatLngBounds();
241 places.forEach(function(place) { 242 if (place.geometry.viewport) { 243 // Only geocodes have viewport. 244 bounds.union(place.geometry.viewport); 245 } else { 246 bounds.extend(place.geometry.location); 247 } 248 }); 249 gmwdmapData["main_map" + key].fitBounds(bounds); 250 }); 251 252} 253//////////////////////////////////////////////////////////////////////////////////////// 254// Getters & Setters // 255//////////////////////////////////////////////////////////////////////////////////////// 256//////////////////////////////////////////////////////////////////////////////////////// 257// Private Methods // 258//////////////////////////////////////////////////////////////////////////////////////// 259//////////////////////////////////////////////////////////////////////////////////////// 260// Listeners // 261////////////////////////////////////////////////////////////////////////////////////////
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.