@@ -18,12 +24,17 @@
@@ -39,6 +50,15 @@ export default {
isComponentModalActive: { type: Boolean, default: false },
agencyFeatures: { type: Object, default () { return {} } }
},
+ computed: {
+ hasFeatures() {
+ return Object.keys(this.agencyFeatures).some(agency => {
+ const features = this.agencyFeatures[agency]
+ return (features.routes && Object.keys(features.routes).length > 0) ||
+ (features.stops && Object.keys(features.stops).length > 0)
+ })
+ }
+ },
methods: {
close () {
this.$emit('close')
diff --git a/src/runtime/components/map-viewer.vue b/src/runtime/components/map-viewer.vue
index 6fadcf6..f5f0e46 100644
--- a/src/runtime/components/map-viewer.vue
+++ b/src/runtime/components/map-viewer.vue
@@ -34,7 +34,8 @@ export default {
return {
map: null,
marker: null,
- hovering: []
+ hoveringRoutes: [],
+ hoveringStops: []
}
},
watch: {
@@ -363,28 +364,57 @@ export default {
},
mapMouseMove (e) {
const map = this.map
- const features = map.queryRenderedFeatures(e.point, { layers: ['route-active'] })
+ // Query both routes and stops
+ const routeFeatures = map.queryRenderedFeatures(e.point, { layers: ['route-active'] })
+ const stopFeatures = map.queryRenderedFeatures(e.point, { layers: ['stop-active'] })
+
map.getCanvas().style.cursor = 'pointer'
- for (const k of this.hovering) {
+
+ // Handle route hover states
+ for (const k of this.hoveringRoutes) {
map.setFeatureState(
{ source: 'routes', id: k, sourceLayer: this.routeTiles ? this.routeTiles.id : null },
{ hover: false }
)
}
- this.hovering = []
- for (const v of features) {
- this.hovering.push(v.id)
+ this.hoveringRoutes = []
+ for (const v of routeFeatures) {
+ this.hoveringRoutes.push(v.id)
map.setFeatureState({ source: 'routes', id: v.id, sourceLayer: this.routeTiles ? this.routeTiles.id : null }, { hover: true })
}
+
+ // Handle stop hover states
+ for (const k of this.hoveringStops) {
+ map.setFeatureState(
+ { source: 'stops', id: k, sourceLayer: this.stopTiles ? this.stopTiles.id : null },
+ { hover: false }
+ )
+ }
+ this.hoveringStops = []
+ for (const v of stopFeatures) {
+ this.hoveringStops.push(v.id)
+ map.setFeatureState({ source: 'stops', id: v.id, sourceLayer: this.stopTiles ? this.stopTiles.id : null }, { hover: true })
+ }
+
+ // Combine features for emission
const agencyFeatures = {}
- for (const v of features) {
+ const processFeature = (v) => {
const agencyId = v.properties.agency_name
- const routeId = v.properties.route_id
+ const featureId = v.properties.route_id || v.properties.stop_id
+ const featureType = v.properties.route_id ? 'route' : 'stop'
if (agencyFeatures[agencyId] == null) {
- agencyFeatures[agencyId] = {}
+ agencyFeatures[agencyId] = { routes: {}, stops: {} }
+ }
+ if (featureType === 'route') {
+ agencyFeatures[agencyId].routes[featureId] = v.properties
+ } else {
+ agencyFeatures[agencyId].stops[featureId] = v.properties
}
- agencyFeatures[agencyId][routeId] = v.properties
}
+
+ routeFeatures.forEach(processFeature)
+ stopFeatures.forEach(processFeature)
+ console.log(agencyFeatures)
this.$emit('setAgencyFeatures', agencyFeatures)
}
}
diff --git a/src/runtime/components/pages/map.vue b/src/runtime/components/pages/map.vue
index 6dc6bbf..c757e0d 100644
--- a/src/runtime/components/pages/map.vue
+++ b/src/runtime/components/pages/map.vue
@@ -28,7 +28,7 @@
/> -->
- Zoom in to select routes and to see stop points.
+ Zoom in to select route lines and to see stop points.
@@ -39,10 +39,10 @@
@close="isComponentModalActive = false"
>
- Select routes
+ Select routes and stops
- Use your cursor to highlight routes and see their names here.
Click for more details.
+ Use your cursor to highlight routes lines or stop points. Click for details.
@@ -197,7 +197,12 @@ export default {
} else {
this.setCoords(null)
}
- if (Object.keys(this.agencyFeatures).length > 0) {
+ // Check if we have any routes or stops to show in the modal
+ const hasFeatures = Object.keys(this.agencyFeatures).some(agency => {
+ return Object.keys(this.agencyFeatures[agency].routes || {}).length > 0 ||
+ Object.keys(this.agencyFeatures[agency].stops || {}).length > 0
+ })
+ if (hasFeatures) {
this.isComponentModalActive = true
}
}
diff --git a/src/runtime/components/route-select.vue b/src/runtime/components/route-select.vue
index 7528a3f..37291c3 100644
--- a/src/runtime/components/route-select.vue
+++ b/src/runtime/components/route-select.vue
@@ -1,33 +1,60 @@
-
+
{{ agency }}
- {{ Object.keys(routes).length }} routes
+
+ {{ Object.keys(features.routes || {}).length }} routes,
+ {{ Object.keys(features.stops || {}).length }} stops
+
-
-
-
-
-
-
-
+
+
+
Routes:
+
+
+
+
+
+
+
+
+
+
+
+
+
Stops:
+
+
+
+ {{ stop.stop_name }}
+
+
+
+
+ {{ stop.stop_name }}
+
+
+
@@ -41,19 +68,32 @@ export default {
maxAgencyRows: { type: Number, default () { return 5 } },
collapse: { type: Boolean },
linkVersion: { type: Boolean, default: false },
+ showStops: { type: Boolean, default: true },
agencyFeatures: { type: Object, default () { return {} } }
},
computed: {
isCollapsed () {
- return this.routeCount > this.maxAgencyRows && this.collapse
+ return this.totalFeatureCount > this.maxAgencyRows && this.collapse
},
- routeCount () {
+ totalFeatureCount () {
let count = 0
- for (const v of Object.values(this.agencyFeatures)) {
- count = count + Object.keys(v).length
+ for (const agency of Object.values(this.agencyFeatures)) {
+ count += Object.keys(agency.routes || {}).length
+ count += Object.keys(agency.stops || {}).length
}
return count
}
}
}
+
+