1var map = (function() { 2 3 var tipoAgencia = [158]; 4 var map; 5 var markers = []; 6 var options = { 7 zoom: 10, 8 center: {} 9 }; 10 var defaultInitialPosition = { lat: -15.7978015, lng: -47.8841214 }; 11 12 function setCurrentPosition(options) { 13 options.center.lat = defaultInitialPosition.lat; 14 options.center.lng = defaultInitialPosition.lng; 15 16 if (navigator.geolocation) { 17 navigator.geolocation.getCurrentPosition(function(position) { 18 options.center.lat = position.coords.latitude; 19 options.center.lng = position.coords.longitude; 20 }); 21 } 22 } 23 24 function init() { 25 jQuery('#frm-brb-map').on('submit', function (e) { 26 e.preventDefault(); 27 }); 28 } 29 30 function initMap() { 31 var ta = document.getElementById('tipoAgencia'); 32 tipoAgencia = ta ? ta.value.split(',').map(function (val) { return parseInt(val); }) : [158]; 33 34 setCurrentPosition(options); 35 map = new google.maps.Map(document.getElementById('map'), options); 36 getAgencias(handleMarkers); 37 38 onDragEnd(map); 39 } 40 41 function onDragEnd(map) { 42 // map.addListener('dragend', () => { 43 // var position = map.getCenter(); 44 // getAgencias(position.lat, position.lng, handleMarkers); 45 // }) 46 } 47 48 function addMarker(agencia, map) { 49 var marker = new google.maps.Marker({ 50 position: { 51 lat: parseFloat(agencia.latitude), 52 lng: parseFloat(agencia.longitude) 53 }, 54 map: map, 55 title: agencia.nome, 56 icon: { 57 url: '/wp-content/themes/oceanwp-child-nbr/images/marker.png', 58 scaledSize: new google.maps.Size(32, 48) 59 }, 60 url: 'https://www.google.com/maps/search/?api=1&query=' + agencia.latitude + ',' + agencia.longitude 61 }); 62 markers.push(marker); 63 64 marker.addListener('click', function() { 65 window.location.href = this.url; 66 }); 67 } 68 69 function handleMarkers(agencias) { 70 agencias.forEach(function(agencia) { 71 addMarker(agencia, map); 72 }); 73 } 74 75 function getAgencias(cb) { 76 var url = 'https://api.brb.com.br/unidade/v1.0.0/'; 77 78 if (tipoAgencia.length === 1) { 79 url += '?idTipo=' + tipoAgencia[0]; 80 } 81 82 jQuery.ajax({ 83 url: url, 84 dataType: 'json', 85 type: 'GET', 86 headers: { 87 'Authorization': 'Basic NzZjMDMyZTQtZWZjYy00N2ZhLTgxNGUtYjU5Y2MwMGM0ZTE1OjIxOGYyZDJkLTg0YWItNGNkOC1iZDNlLTQwZDQ5YzMzNDJjMg==' 88 }, 89 success: function (data) { 90 91 var filteredData = data.unidades.filter(function(value) { 92 return (tipoAgencia.indexOf(parseInt(value.idTipo)) >= 0) ? value : false; 93 }); 94 95 setupAutocompleteAgencia(filteredData); 96 cb(filteredData); 97 } 98 }); 99 } 100 101 function setupAutocompleteAgencia(data) { 102 jQuery("#agencia").easyAutocomplete({ 103 data: data, 104 getValue: 'nome', 105 list: { 106 maxNumberOfElements: 100, 107 match: { enabled: true}, 108 showAnimation: { 109 type: "fade", //normal|slide|fade 110 time: 400, 111 callback: function() {} 112 }, 113 hideAnimation: { 114 type: "slide", //normal|slide|fade 115 time: 400, 116 callback: function() {} 117 }, 118 onChooseEvent: function() { 119 handleSelectAgencia(); 120 } 121 } 122 }); 123 jQuery(".easy-autocomplete").css("width", "100%"); 124 } 125 126 function handleSelectAgencia() { 127 var lat = jQuery("#agencia").getSelectedItemData().latitude; 128 var lng = jQuery("#agencia").getSelectedItemData().longitude; 129 var position = { lat: parseFloat(lat), lng: parseFloat(lng) }; 130 131 for (var i = 0; i < markers.length; i++) { 132 var p = markers[i].getPosition(); 133 if (p.lat().toFixed(7) == position.lat && p.lng().toFixed(7) == position.lng) { 134 markers[i].setAnimation(google.maps.Animation.BOUNCE); 135 } else { 136 markers[i].setAnimation(null); 137 } 138 } 139 140 map.panTo(position); 141 map.setZoom(17); 142 } 143 144 init(); 145 146 return { 147 init: initMap 148 }; 149})();
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.