/** @expose */ MsuMap.prototype.ShowInactiveRoutes = function (elem) { elem.parentNode.removeChild(elem); document.getElementsByClassName('inactiveRoutes')[0].style.display = 'block'; }; /** @expose */ MsuMap.prototype.HideLinkPanel = function () { document.getElementById('LinkPanel').style.display = 'none'; }; /** @expose */ MsuMap.prototype.ToggleLinkPanel = function () { var linkOptions = [], i, linkPanel = document.getElementById('LinkPanel'), CurrentUrl = location.protocol + '//' + location.host + location.pathname.replace(/\/default\.aspx$/i, '/'), layers = [], routes = []; if (linkPanel.style.display == "block") { linkPanel.style.display = "none"; return; } linkOptions.push('z=' + this.map.getZoom()); linkOptions.push('ll=' + this.map.getCenter().toUrlValue()); switch (this.map.getMapTypeId()) { case google.maps.MapTypeId.HYBRID: linkOptions.push('t=h'); break; case google.maps.MapTypeId.SATELLITE: linkOptions.push('t=s'); break; default: break; } var q = document.getElementById('q').value; q = q.replace(/^\s*/, '').replace(/\s*$/, ''); if (q.length > 0 && q != 'Search Map') { linkOptions.push('q=' + encodeURIComponent(q)); } else { q = MsuMap.getQ('locationId'); if (q.length > 0) { q = parseInt(q, 10); if (!isNaN(q)) { linkOptions.push('locationId=' + q); } } } if (this.ParkingOverlay.getMap() != null) { layers.push('parking'); } if (this.Bikeracks.getMap() != null) { layers.push('bikeways'); } if (this.ShuttleStopsLayer.getMap() != null) { layers.push('shuttle'); if (!this.showActiveRoutes) { for (var route in missouristate['MapData']['routes']) { if (this.ShuttleRouteLayers[route].getMap() != null) { routes.push(route); } } } } if (layers.length > 0) { linkOptions.push('layer=' + layers.join(',')); } if (routes.length > 0) { linkOptions.push('routes=' + routes.join(',')); } var Querystring = linkOptions.join('&'); document.getElementById('LinkTB').value = CurrentUrl + '#!' + Querystring; document.getElementById('EmbedTB').value = ''; document.getElementById('AdvancedHref').href = CurrentUrl + "advancedlink.aspx?" + Querystring; linkPanel.style.display = 'block'; document.getElementById('LinkTB').focus(); }; if(navigator.userAgent && (/Android/.test(navigator.userAgent) || /iPad/.test(navigator.userAgent))) { MsuMap.prototype.Pause = function () { //Chrome bug - focus and blur events are called twice. if (this.isPaused) { return; } this.isPaused = true; this.geoMarker.setMap(null); if (this.ShuttleStopsLayer.getMap() != null) { this.ShowShuttleMapOnResume = true; if (this.ShuttleLocationPollingInterval >= 0) { clearInterval(this.ShuttleLocationPollingInterval); this.ShuttleLocationPollingInterval = -1; } if (this.ShuttleLocationLongPollingInterval >= 0) { clearInterval(this.ShuttleLocationLongPollingInterval); this.ShuttleLocationLongPollingInterval = -1; } } else { this.ShowShuttleMapOnResume = false; } }; MsuMap.prototype.Resume = function () { if (this.isPaused) { //Chrome bug - focus and blur events are called twice. this.isPaused = false; this.geoMarker.setMap(this.map); if (this.ShowShuttleMapOnResume) { this.GetShuttleLocations(); } } }; } /** * @constructor * @param {google.maps.Map} map */ function MsuControls(map) { this.div = document.createElement('div'); this.div.id = 'MsuMapControls'; this.map = map; var t = this; if (map.mapTypes && map.mapTypes[google.maps.MapTypeId.ROADMAP]) { this.setContent(); } else { google.maps.event.addListenerOnce(map, 'projection_changed', function () { t.setContent(); }); } this.searchMarkers = []; missouristate.Map['Search'] = function (elem) { if (navigator.userAgent && (/Android/.test(navigator.userAgent) || /iPad/.test(navigator.userAgent))) { var q = document.getElementById('q'); q.setAttribute('readonly', 'readonly'); setTimeout(function () { q.blur(); q.removeAttribute('readonly'); }, 50); } return t.Search(elem); }; missouristate.Map['SearchResults'] = function (results, startIndex) { t.SearchResults(results, startIndex); }; missouristate.Map['ShowSearchResult'] = function (index) { t.ShowSearchResult(index); }; } MsuControls.prototype.setContent = function () { var layers = MsuMap.getQ('layer').split(','), activeLayers = {}, i; for (i = 0; i < layers.length; i++) { activeLayers[layers[i]] = true; } this.div.innerHTML = missouristate.Map.Templates.MapControls({ activeLayers: activeLayers, SpriteUrl: MsuMap.SPRITE_URL, SpriteWidth: MsuMap.SPRITE_SIZE.width, SpriteHeight: MsuMap.SPRITE_SIZE.height }); this.AfterInit(); } MsuControls.prototype.resize = function () { var mapdiv = this.map.getDiv(); var boundingRect = missouristate.getBoundingClientRect(mapdiv); var height = boundingRect.height - this.heightLimiter; this.mapControlDiv.style.maxHeight = height + 'px'; }; MsuControls.prototype.AfterInit = function () { var q = document.getElementById('q'); var t = this; if (!q) { setTimeout(function () { t.AfterInit(); }, 500); return; } this.initialized = true; var h2 = this.div.getElementsByTagName('h2')[0]; var boundingRect = missouristate.getBoundingClientRect(h2); this.heightLimiter = 90 + boundingRect.height; this.mapControlDiv = document.getElementsByClassName('MapControls')[0]; this.ResultsDiv = document.getElementById('SearchResults'); /** @const */ this.SearchMarkerSize = new google.maps.Size(21, 36); /** @const */ this.SearchMarkerAnchor = new google.maps.Point(10, 36); /** @const */ this.SearchMarkerShadow = { 'url': MsuMap.SPRITE_URL, 'size': new google.maps.Size(64, 18), 'scaledSize': MsuMap.SPRITE_SIZE, 'origin': new google.maps.Point(47, 30) }; google.maps.event.trigger(this, 'initialized'); this.SearchResultsBlank = true; var initialSearch = MsuMap.getQ('q', ''); if (initialSearch.length > 0) { q.value = initialSearch; this.Search(q.form); } else { initialSearch = parseInt(MsuMap.getQ('locationId', ''), 0); if (!isNaN(initialSearch)) { missouristate.requireScript(location.protocol + '//missouristate.info/feeds/map_locations_search.aspx?locationId=' + initialSearch, true, function () { if (this.parentNode) { this.parentNode.removeChild(this); } }); } } google.maps.event.addDomListener(q, 'focus', function () { if (this.value == '') { t.SearchResultsBlank = true; } }); google.maps.event.addDomListener(q, 'change', function () { if (this.value.length == 0) { t.ResultsDiv.innerHTML = ''; t.clearAllSearchMarkers(); t.SearchResultsBlank = true; } }); missouristate.Map['SearchSuggest'] = missouristate.AddSearchSuggestions(q, location.protocol + "//missouristate.info/suggest/map_locations.aspx?callback=missouristate.Map.SearchSuggest&q=", function (val, href) { q.value = val; t.Search(q.form); if (t.SearchResultsBlank) { t.ResultsDiv.innerHTML = missouristate.Map.Templates.SearchLoading(); } }); google.maps.event.addDomListener(window, 'resize', function () { t.resize(); }); t.resize(); this.SetupShuttleRoutes(); google.maps.event.addListener(missouristate.Map, 'layers_changed', function (id) { t.LayersChanged(id); }); }; MsuControls.prototype.LayersChanged = function (Elem) { if (Elem.id == 'ShuttleMap') { var routesDiv = document.getElementById('ShuttleRoutes'); if (Elem.checked) { routesDiv.style.display = 'block'; if (missouristate.Map.showActiveRoutes) { for (var route in missouristate['MapData']['routes']) { if (missouristate.Map.ShuttleRouteLayers[route].isRunning()) { var checkbox = document.getElementById(route + 'Route'); if (checkbox) { checkbox.checked = true; } } } } else { var checkboxes = routesDiv.getElementsByTagName('input'); for (var i = 0; i < checkboxes.length; i++) { missouristate.Map.UpdateRoutes_(checkboxes[i], true); } } } else { routesDiv.style.display = 'none'; } } }; MsuControls.prototype.SetupShuttleRoutes = function () { var div = document.getElementById('ShuttleRoutes'); var route, activeRoutes = [], inactiveRoutes = [], checkedRoutes = {}, selectedRoutes = MsuMap.getQ('routes').split(','), hasCheckedRoute = false, hasActiveRoute = false, runningRoutes = {}; for (var i = 0; i < selectedRoutes.length; i++) { if (selectedRoutes[i].length > 0) { checkedRoutes[selectedRoutes[i]] = true; hasCheckedRoute = true; } } for (route in missouristate['MapData']['routes']) { if (missouristate['MapData']['routes'][route]['points'].length && missouristate['MapData']['routes'][route]['points'][0].length && missouristate['MapData']['routes'][route]['points'][0].length > 0) { if (missouristate['MapData']['routes'][route]['active']) { activeRoutes.push(missouristate['MapData']['routes'][route]); } else { inactiveRoutes.push(missouristate['MapData']['routes'][route]); } if (!hasCheckedRoute && missouristate.Map.showActiveRoutes && missouristate.Map.ShuttleRouteLayers[route].isRunning()) { checkedRoutes[route] = true; runningRoutes[route] = true; hasActiveRoute = true; } } } div.innerHTML = missouristate.Map.Templates.ShuttleRoutes({ ShuttleRoutes: activeRoutes, ActiveByDefault: checkedRoutes, ActiveRoutes: runningRoutes }) + 'Show unscheduled routes