Browse Source

minor updates to web facing part

* ignore bad data from geojson and gtfs data
* grow map according to window resize
abram 4 years ago
parent
commit
5551523e6f
2 changed files with 12 additions and 0 deletions
  1. 1 0
      html/index.html
  2. 11 0
      html/js/RideLogicAVLS.js

+ 1 - 0
html/index.html

@@ -12,6 +12,7 @@
       .map {
         width: 100%;
         height:500px;
+        /* height:100%; */
       }
     </style>
   </head>

+ 11 - 0
html/js/RideLogicAVLS.js

@@ -190,6 +190,7 @@ function update_buses(json_gtfs) {
     let lonlat = [ lon , lat ];
     let merc = fromLonLat(lonlat);
 
+    if (typeof _icon[ii] === "undefined") { continue; }
 
     _icon[ii].feature.getGeometry().setCoordinates(merc);
 
@@ -231,6 +232,7 @@ function fetch_gtfs_vehicle_position() {
 //--
 
 function update_route_layer(geojson) {
+  if (!geojson) { return; }
   var route_points = geojson.features[0].geometry.coordinates;
   var merc_points = [];
   for (let ii=0; ii<route_points.length; ii++) {
@@ -259,6 +261,7 @@ function update_route_layer(geojson) {
 }
 
 function update_stop_layer(geojson) {
+  if (!geojson) { return; }
   let stop_points = geojson.features[0].properties.route_stops;
 
   let merc_points = [];
@@ -330,9 +333,17 @@ function fetch_geojson(url) {
 
 //--
 
+function _resize() {
+  let h = $(window).height();
+  let m = document.getElementById("map");
+  m.style.height = (h-10) + "px";
+}
+
 function init() {
   setInterval(fetch_gtfs_vehicle_position, 1000);
   setTimeout( function() { fetch_geojson("geojson/test_route.geojson"); }, 100);
+
+  $(window).on('resize', _resize);
 }
 
 init();