tag, and before any other scripts. Your first data will appear automatically in just a few seconds. -->

Press iBiN to see availability

Locality: ' + element.localityName + '' + '

Content: ' + element.content + '' + //'

Fill level: ' + element.fullLevel + '%' + '

Address: ' + element.address + '' + 'Switch to google maps'; infowindow.setContent(content); map.setCenter(binLagos); } function positionError(position) { switch (position.code) { case position.PERMISSION_DENIED: $('#spanError').text('Please enable Location Services in your device.'); break; case position.POSITION_UNAVAILABLE: $('#spanError').text('Location information is unavailable.'); break; case position.TIMEOUT: $('#spanError').text('The request to get user location timed out.'); break; default: $('#spanError').text('An unknown error occurred.'); break; } // Create user marker createMap(0, 0); } function getCurrentLocality(lat, long) { $.ajax({ type: 'GET', dataType: "json", url: "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + long + "&key=AIzaSyBdQAGw6l58DfRkcVUqLU6FaOF_kxRqVlo", data: {}, success: function (data) { //var founded = false; var locationUpdated = false; $.each(data['results'], function (i, val) { if (!locationUpdated) { $('#lblYourLocation').text(val['formatted_address'].replace(', Malta', '')); locationUpdated = true; return false; } //$.each(val['address_components'], function (i, val) { // if (val['types'] == "locality,political") { // if (val['long_name'] != "") { // var longName = val['long_name'].split(" "); // var myLocality = longName[longName.length - 1]; // var myLocality = myLocality.replace(/[^a-zA-Z0-9]/g, ''); // // handle special case for special characters // if (myLocality === "Birebbua") { // myLocality = "Birzebbuga"; // } // if (myLocality === "Luija") { // myLocality = "Lucija"; // } // if (myLocality === "Xgajra") { // myLocality = "Xghajra"; // } // if (myLocality === "aabbar") { // myLocality = "Zabbar"; // } // var localities = document.getElementById('localitySearch'); // for (i = 0; i < localities.options.length; i++) { // var value = localities.options[i].value; // if (value.includes(myLocality)) { // $('#localitySearch').val(value); // founded = true; // return false; // } // } // } // } //}); //return !founded; }); updateLocality(); } }); } function updateLocation() { var lat = Number($('#lat').val()); var long = Number($('#long').val()); if (lat === 0 || long === 0) { var answer = confirm("The iBins Web App requests your location to find the nearest available recycling bin. Do you allow access to your location?"); if (answer) { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, positionError, geo_options); } else { $('#spanError').text('Your browser does not support geo location'); } } else { createMap(lat, long); } } else { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, positionError, geo_options); } else { $('#spanError').text('Your browser does not support geo location'); } } } function initMap() { var lat = Number($('#lat').val()); var long = Number($('#long').val()); if (lat === 0 || long === 0) { var answer = confirm("The iBins Web App requests your location to find the nearest available recycling bin. Do you allow access to your location?"); if (answer) { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, positionError, geo_options); } else { $('#spanError').text('Your browser does not support geo location'); } } else { createMap(lat, long); } } else { createMap(lat, long); } }