diff --git a/mauricio/Metro-LA/.jshintrc b/mauricio/Metro-LA/.jshintrc new file mode 100644 index 0000000..53b202c --- /dev/null +++ b/mauricio/Metro-LA/.jshintrc @@ -0,0 +1,3 @@ +{ + "esversion": 6 +} \ No newline at end of file diff --git a/mauricio/Metro-LA/css/style.css b/mauricio/Metro-LA/css/style.css new file mode 100644 index 0000000..33c0c7a --- /dev/null +++ b/mauricio/Metro-LA/css/style.css @@ -0,0 +1,20 @@ +html, body { + height: 100%; + margin: 0; + padding: 0; +} + +#map { + height: 100%; +} + +#spinner{ + display: block; + background: url(../img/spinner.gif); + background-position: center center; + background-repeat: no-repeat; + background-origin: inherit; + position: absolute; + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/mauricio/Metro-LA/img/spinner.gif b/mauricio/Metro-LA/img/spinner.gif new file mode 100644 index 0000000..00f9f96 Binary files /dev/null and b/mauricio/Metro-LA/img/spinner.gif differ diff --git a/mauricio/Metro-LA/index.html b/mauricio/Metro-LA/index.html new file mode 100644 index 0000000..7d40960 --- /dev/null +++ b/mauricio/Metro-LA/index.html @@ -0,0 +1,22 @@ + + + +
+ + +Algo ha ido mal, vuelve a intentarlo mas tarde
'; + } + } catch (error) { + console.log(error); + } + } + + function getIds(resRoutes) { + const array = resRoutes.items; + return array.map(item => item.id); + } + + function searchAndReplaceNumberVehicle(arrayIds, URL_ROUTE) { + let replaced = []; + arrayIds.forEach(item => { + replaced.push(URL_ROUTE.replace(/number/, item)); + }); + return replaced; + } + + async function getAllVehicles(arrayUrlsParsed) { + let promises = arrayUrlsParsed.map(async item => { + try{ + const json = await fetch(item); + if (json.status !== 200) { + throw new Error("Error"); + } + const data = await json.json(); + return data.items + } catch(error) { + console.log(error); + } + }); + return await Promise.all(promises); + }; + + function getAllRoutes(vehicles) { + let vehiclesConcat = []; + vehiclesConcat = Array.prototype.concat.apply([], vehicles); + + const coordinates = vehiclesConcat.map(item => { + return { + lat: item.latitude, + lng: item.longitude + }; + }); + + initMap(coordinates); + } + + function initMap(coordinates) { + const map = new google.maps.Map(document.getElementById("map"), { + zoom: 11, + center: { + lat: 34.052235, + lng: -118.243683 + } + }); + + const labels = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + const markers = coordinates.map(function (location, i) { + return new google.maps.Marker({ + position: location, + label: labels[i % labels.length] + }); + }); + + const markerCluster = new MarkerClusterer(map, markers, { + imagePath: "https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m" + }); + } + + init(URL); +})(); \ No newline at end of file diff --git a/miguelGarcia/.DS_Store b/miguelGarcia/.DS_Store index 10e8366..200ca5c 100644 Binary files a/miguelGarcia/.DS_Store and b/miguelGarcia/.DS_Store differ