diff --git a/src/components/map/Map.vue b/src/components/map/Map.vue new file mode 100644 index 0000000..28fd7ad --- /dev/null +++ b/src/components/map/Map.vue @@ -0,0 +1,324 @@ + + + + + + + + \ No newline at end of file diff --git a/src/components/station/Station.vue b/src/components/station/Station.vue index 13fce8d..346f0fb 100644 --- a/src/components/station/Station.vue +++ b/src/components/station/Station.vue @@ -227,7 +227,7 @@ icon: "place", title: "Station Map", function: function() { - window.location = "https://www.google.com/maps/search/?api=1&query=" + vm.stop.lat + "," + vm.stop.lon; + window.location = "/" + vm.agencyId + "/map?stop=" + vm.stop.id; } }, { diff --git a/src/components/trip/Trip.vue b/src/components/trip/Trip.vue index c8d792d..4e9d4cf 100644 --- a/src/components/trip/Trip.vue +++ b/src/components/trip/Trip.vue @@ -335,7 +335,7 @@ icon: "place", title: "Station Map", function: function() { - window.location = "https://www.google.com/maps/search/?api=1&query=" + stop.lat + "," + stop.lon; + window.location = "/" + vm.agencyId + "/map?stop=" + stop.id; } }); return { diff --git a/src/router.js b/src/router.js index 2a49b19..ac7cac2 100644 --- a/src/router.js +++ b/src/router.js @@ -17,6 +17,7 @@ import Trips from "@/components/trips/Trips.vue" import Trip from "@/components/trip/Trip.vue" import Stations from "@/components/stations/Stations.vue" import Station from "@/components/station/Station.vue" +import Map from "@/components/map/Map.vue" import PageNotFound from "@/components/PageNotFound.vue" @@ -111,6 +112,11 @@ var routes = [ name: "station", component: Station }, + { + path: "/:agency/map", + name: "map", + component: Map + }, { path: "**", name: "pageNotFound", diff --git a/src/utils/cache.js b/src/utils/cache.js index f70a081..c868a4e 100644 --- a/src/utils/cache.js +++ b/src/utils/cache.js @@ -95,6 +95,45 @@ getAgencyIcon = function(agency, callback) { } +/** + * Get the center of the shapes of the specified agency + * - Cache Length: 7 days + * @param {string} agency Agency ID Code + * @param {Function} callback Callback function(err, center) + */ +getAgencyMapCenter = function(agency, callback) { + _getCacheElseFresh("/maps/center/" + agency, 7*24*60*60, function(err, response) { + return callback(err, response); + }); +} + + +/** + * Get the GeoJSON shapes of the specified agency + * - Cache Length: 7 days + * @param {string} agency Agency ID Code + * @param {Function} callback Callback function(err, shapes) + */ +getAgencyMapShapes = function(agency, callback) { + _getCacheElseFresh("/maps/shapes/" + agency, 7*24*60*60, function(err, response) { + return callback(err, response); + }); +} + + +/** + * Get the GeoJSON stops of the specified agency + * - Cache Length: 7 days + * @param {string} agency Agency ID Code + * @param {Function} callback Callback function(err, stops) + */ + getAgencyMapStops = function(agency, callback) { + _getCacheElseFresh("/maps/stops/" + agency, 7*24*60*60, function(err, response) { + return callback(err, response); + }); +} + + /** * Get the Station Feed for the specified stop * - Cache Length: 45 seconds / max 2 hours @@ -505,6 +544,9 @@ module.exports = { getAgencies: getAgencies, getAgency: getAgency, getAgencyIcon: getAgencyIcon, + getAgencyMapCenter: getAgencyMapCenter, + getAgencyMapShapes: getAgencyMapShapes, + getAgencyMapStops: getAgencyMapStops, getStationFeed: getStationFeed, getTransitAgencies: getTransitAgencies, getTransitAgencyIcon: getTransitAgencyIcon, diff --git a/src/utils/menu.js b/src/utils/menu.js index 4fee89b..f955998 100644 --- a/src/utils/menu.js +++ b/src/utils/menu.js @@ -158,21 +158,28 @@ const MENU = function(vm) { }, { key: 25, - type: "favorites" + type: "item", + title: "Map", + icon: "map", + page: "map" }, { key: 26, - type: "divider" + type: "favorites" }, { key: 27, + type: "divider" + }, + { + key: 28, type: "item", title: "About", icon: "info", page: "agencyAbout" }, { - key: 28, + key: 29, type: "item", title: "Help & Feedback", icon: "help", @@ -182,7 +189,7 @@ const MENU = function(vm) { } }, { - key: 29, + key: 30, type: "item", title: "Settings", icon: "settings", @@ -192,11 +199,11 @@ const MENU = function(vm) { } }, { - key: 30, + key: 31, type: "divider" }, { - key: 31, + key: 32, type: "item", title: "Switch Agency", icon: "swap_horiz", diff --git a/static/index.html b/static/index.html index 418eae6..37a531e 100644 --- a/static/index.html +++ b/static/index.html @@ -13,6 +13,7 @@ +
@@ -31,5 +32,6 @@ } +