--- title: "Home" description: "24/7 Emergency Service Available Las Vegas’ Most Trusted AC Repair & Installation Experts Same-Day Service Free Estimates 100% Satisfaction Guaranteed (702) 381-5080 Book An Appointment 4.9/5 Rating 2,300+ Reviews Licensed & Insured EPA Certified 100% Guaranteed Workmanship Promise Quality service What do you need help with? AC installation & Replacement GET QUOTE → AC Repair […]" url: "https://bobsrepair.com/" date_modified: "2026-06-17T09:20:18-07:00" --- ### 24/7 Emergency Service Available # Las Vegas' Most Trusted AC Repair & Installation Experts - Same-Day Service - Free Estimates - 100% Satisfaction Guaranteed [(702) 381-5080](tel:+17023815080) [Book An Appointment](https://bobsrepair.com/request-an-appointment/) ### 4.9/5 Rating 2,300+ Reviews ### Licensed & Insured EPA Certified ### 100% Guaranteed Workmanship Promise --- ![bi-logo-white](https://bobsrepair.com/wp-content/uploads/2024/10/bi-logo-white.svg) ![marketwatch-corp-logo](https://bobsrepair.com/wp-content/uploads/2024/10/marketwatch-corp-logo.svg) ![benzinga](https://bobsrepair.com/wp-content/uploads/2024/10/benzinga.svg) ![yahoo-finance-logo-white](https://bobsrepair.com/wp-content/uploads/2024/10/yahoo-finance-logo-white.svg) ![ap-news-white-logo](https://bobsrepair.com/wp-content/uploads/2024/10/ap-news-white-logo.svg) ![Winner_Gold-white](https://bobsrepair.com/wp-content/uploads/2025/03/Winner_Gold-white.png) --- Quality service --- ## What do you need help with? --- AC installation & Replacement GET QUOTE → AC Repair GET QUOTE → HeatingRepair GET QUOTE → Air Duct Cleaning& Replacement GET QUOTE → --- SolarInstallation GET QUOTE → ElectricalServices GET QUOTE → AtticInsulation GET QUOTE → Dryer VentCleaning GET QUOTE → --- Tune-Up Special $89 Special Complete System Inspection Performance Optimization Energy Efficiency Check Covers One Unit TUNEUP89 Ending Soon HVAC Repair $50 OFF Valid for Any Repair Service Heating System Repairs Cooling System Repairs REPAIR50 Save Now Premium Upgrade $500 OFF Save up to $500 NV Energy approved - Official rebate program backed by your local utility provider Energy Efficient - Lower bills UPGRADE500 VIP SAVINGS --- Open 7 Days A Week Got an Emergency? Call: (702) 381-5080 --- ## Las Vegas' Local AC Experts When your AC breaks down in the Las Vegas heat, you need a local team that shows up fast. That’s exactly what we’ve delivered since 2014. Our family-owned team keeps your home comfortable with top-rated [AC repair](https://bobsrepair.com/services/ac-repair-las-vegas/), new [AC installations](https://bobsrepair.com/services/ac-installation-las-vegas/), [heating services](https://bobsrepair.com/services/heating-repair-las-vegas/), [duct cleaning](https://ducts.bobsrepair.com/), and [solar](https://bobsrepair.com/solar/). Here’s how we deliver: - Direct Savings: Factory-direct pricing. No middlemen, no markups. - Flexible Financing: Affordable payment options so a broken AC never has to wait. - Las Vegas-Tested: Built for desert climates, we know how 115°F summers stress your system and exactly what to do about it. --- ## The Bob's Repair Difference: Honest, Quality Service --- ![Honest. Reliable. Local.](https://bobsrepair.com/wp-content/uploads/2023/09/Honest-Icon.svg) ### Honest. Reliable. Local. We promise our Las Vegas community 100% transparency with zero hidden fees. ![A Five-Star Reputation](https://bobsrepair.com/wp-content/uploads/2023/09/Reputation-icon.svg) ### A Five-Star Reputation We put your comfort first and have proudly earned over 2,500 five-star reviews from your neighbors. ![Excellent Workmanship](https://bobsrepair.com/wp-content/uploads/2023/09/Degree-Icon.svg) ### Excellent Workmanship Count on our NATE-certified experts for fully warrantied work and reliable service 7 days a week. --- [Meet Bob's Team](https://bobsrepair.com/about/) --- Locally Owned --- ## Serving Our Las Vegas Neighbors From Henderson and Summerlin to North Las Vegas and the Strip corridor, we’re the local AC repair team homeowners call first. Count on us for professional repairs, new installations, and reliable maintenance across the entire valley. [Visit the service area page](https://bobsrepair.com/service-area/) to learn more about our [AC services in your Las Vegas neighborhood](https://bobsrepair.com/services/). [Find Your Neighborhood](https://bobsrepair.com/service-area/) --- ## Fast, Fair, & Pro AC Specialists Bob’s Repair has kept Las Vegas homes comfortable through scorching 115°F summers for over a decade. Our certified technicians diagnose fast, explain clearly, and get the job done right across AC repair, installation, and maintenance, all backed by a 100% satisfaction guarantee. [Call: (702) 381-5080](tel:+17023815080) --- ## Our Local Customer Reviews [Read All Testimonials](https://bobsrepair.com/reviews/) ![GOOGLE REVIEWS](https://bobsrepair.com/wp-content/uploads/2023/09/GOOGLE-REVIEWS.png) Excellent Bob’s Repair AC, Heating and Solar Experts Las Vegas 4.9 Based on 1890 reviews See all reviews review us on Lorin C. 1 day ago Victor checked the system, answered questions clearly, all good. Vince 2 days ago Matt spent a ton of time with us going through options and answering every question we had. Really knowledgeable and never once felt like a sales pitch. He helped us narrow down our decision a lot, and even though we went with another company this time, I'll definitely be calling Bob's Repair for any HVAC needs down the road. I'd definitely recommend them to anyone shopping around. larry T. 2 days ago Adan is the best clean work and honest opinion and Ron did a great job replacing the a/c flap for one of the rooms and filter change..dont know Mr. BOB but he's got great help and knows how to do honest business and service at fair pricing with next day service for customers with a yearly service agreement. Worth evey penny Jason R. 3 days ago Excellent service from Jordan. Very professional and informative. Margaret C. 3 days ago Another great experience with Bob’s AC! Their technician Victor was here this morning complete a City of Henderson inspection of our new HVAC system. He was super polite, explained everything perfectly, and was very neat - booties on at all time and no mess at all. We’re very happy with Bob’s! (function(p){if(!p)return;let w=p.offsetWidth,m=function(a,b){return Math.min(a,b)===a};p.querySelector('.rpi-cnt').classList.replace('rpi-col-m','rpi-col-'+(m(w,510)?'xs':m(w,750)?'x':m(w,1050)?'s':m(w,1450)?'m':m(w,1800)?'l':'xl'))})(document.getElementById('rpi-1281-6aa4b43f39268')) --- ## Diagnostic Guides ## Common AC Problems in Las Vegas Homes Not sure what’s wrong with your AC? These guides break down the most common problems we see in Las Vegas homes – and how to fix them. [AC running but not cooling?](https://bobsrepair.com/problem/ac-not-cooling-well/) [Why is upstairs hotter than downstairs?](https://bobsrepair.com/problem/why-is-my-upstairs-so-hot/) [Why is my AC failing early?](https://bobsrepair.com/problem/ac-failing-early/) [Weak airflow from your vents?](https://bobsrepair.com/problem/weak-ac-airflow/) [Should I replace my AC and furnace together?](https://bobsrepair.com/problem/full-system-replacement/) [Was my AC installed wrong?](https://bobsrepair.com/problem/was-my-ac-installed-wrong/) --- [See all common AC problems](https://bobsrepair.com/problem/) --- ## HVAC Tips from Las Vegas Experts AC Installation Heat Pump vs AC Las Vegas: Which Wins in 2026? Frideric Prandecki, Co-Owner September 9, 2026 Heating Repair 8 Signs Your Furnace Needs Cleaning (Las Vegas, 2026) Frideric Prandecki, Co-Owner September 2, 2026 AC Questions AC Not Working After Power Outage in Las Vegas? Here’s What to Do Frideric Prandecki, Co-Owner August 26, 2026 AC Repair Mini-Split Not Cooling in Your Las Vegas Casita? Here’s What’s Actually Wrong Frideric Prandecki, Co-Owner August 12, 2026 AC Repair How to Fix a Noisy AC Compressor Before the Las Vegas Heat Wins Frideric Prandecki, Co-Owner July 20, 2026 AC Maintenance & Repair AC Not Working In Apartment? 5 Steps For Las Vegas Renters Frideric Prandecki, Co-Owner July 15, 2026 [Discover HVAC Tips](https://bobsrepair.com/blog/) --- ## Las Vegas Solar Experts Bob’s Repair helps Las Vegas homeowners cut energy bills with custom solar installations. Our licensed Nevada technicians handle all permits and paperwork, install premium equipment with strong warranties, and show you exactly how much you’ll save. [Start Your Solar Journey](https://solar.bobsrepair.com/) --- ### Las Vegas AC FAQ Here are straight answers to the most common AC questions we hear from our Las Vegas neighbors. ### How to install an air conditioning unit in North Las Vegas? AC installation involves selecting the right system for your home's square footage, preparing the site, and making precise electrical and refrigerant connections. Mistakes at any of these steps can lead to efficiency loss, voided warranties, or code violations that cost more to fix later. Bob's Repair handles every part of the installation process, from system selection to final testing, so you get a unit that performs correctly from day one. ### How can regular maintenance extend the life of my AC unit and HVAC system? Your AC works harder in Las Vegas than almost anywhere else in the country. Without regular maintenance, small issues like low refrigerant, dirty coils, or worn fan belts build up quietly until the system fails, usually on the hottest day of the year. Routine tune-ups from Bob's Repair keep your system running efficiently, catch problems early, and can add years to the life of your unit, saving you significantly on both energy bills and early replacement costs. ### How to troubleshoot an AC that is not cooling, compromising home comfort? Start with the basics: confirm your thermostat is set to COOL and set below the current room temperature, then check your air filter, as a clogged filter is the most common cause of poor cooling in Las Vegas homes. Also, check your breaker to make sure the unit is getting full power. If those checks don't solve it, the problem is likely a refrigerant leak, frozen evaporator coil, or a failing compressor, all of which need a professional. Bob's Repair offers same-day diagnostics across the Las Vegas area. ### What are common AC repair issues? Refrigerant leaks, frozen evaporator coils, thermostat failures, and faulty capacitors are the issues our techs fix most often. In Las Vegas, dust buildup in condenser coils is also a major culprit since it forces your system to work harder and overheat. Most of these problems start small and become expensive if ignored. The sooner you call, the less a repair typically costs, and the less strain your system takes before the fix. ### What should I consider when replacing my air conditioning unit? The two biggest factors are the age of your current system and its SEER rating. If your unit is over 10 years old and needs frequent repairs, replacement usually makes more financial sense than another fix. A newer system with a higher SEER rating will cut your monthly energy bills noticeably in a climate like Las Vegas. Sizing also matters. An oversized unit short-cycles and wears out faster, while an undersized one runs constantly without ever fully cooling your home. Bob's Repair will assess your home properly and give you an honest recommendation, not just the most expensive option. ### How often should I change my AC filter in Las Vegas? Las Vegas air carries significantly more dust, pollen, and debris than most cities, which means your filter clogs faster than the manufacturer's general guidelines suggest. For standard 1-inch filters, plan to swap them every 30 days during peak cooling season. Thicker media filters can go 3 to 6 months, but should still be checked monthly. A dirty filter is the single easiest thing to fix and one of the most common reasons AC units underperform or fail early. Replacing it takes two minutes and can prevent a service call that costs far more. --- East North Central Southwest Bob's Repair AC, Heating and Solar Experts Las Vegas 3874 Silvestri Lane, Las Vegas, NV 89120 CALL: (702) 381-5080 Directions Service Areas Henderson, NV Paradise, NV Green Valley, NV Anthem, NV Seven Hills, NV Boulder City, NV Sunrise Manor, NV Inspirada, NV MacDonald Ranch, NV Bob's Repair AC, Heating and Solar Experts Las Vegas 6628 Sky Pointe, Suite 123, Las Vegas, NV 89131 CALL: (702) 444-2073 Directions Service Areas Centennial Hills, NV North Las Vegas, NV Bob's Repair AC, Heating and Solar Experts Las Vegas 2500 N Buffalo Dr, Suite 100, Las Vegas, NV 89128 CALL: (702) 530-3991 Directions Service Areas Summerlin, NV The Lakes, NV Bob's Repair AC, Heating and Solar Experts Las Vegas 758 Shiva St, Las Vegas, NV 89178 CALL: (702) 444-2073 Directions Service Areas Enterprise, NV Southern Highlands, NV Spanish Hills, NV Spanish Trail, NV Spring Valley, NV .brm-wrap { position: relative; width: 100%; height: 660px; overflow: hidden; font-family: Arial, sans-serif; } /* Compact map on service-area pages */ .brm-wrap--compact { height: 500px; } /* Map fills the container */ .brm-map { position: absolute; inset: 0; width: 100%; height: 100%; background: #f5f0e8; /* brand cream, so the box looks intentional before tiles arrive */ } .brm-map canvas { outline: none; } /* Location markers */ .brm-marker { cursor: pointer; } /* Themes style aggressively; force every decoration off */ #brm-map .brm-marker, #brm-map .brm-marker:hover, #brm-map .brm-marker:focus, #brm-map .brm-marker:active { background: none !important; background-color: transparent !important; background-image: none !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; min-width: 0 !important; min-height: 0 !important; width: 36px !important; height: 44px !important; border-radius: 0 !important; filter: none !important; line-height: 0 !important; -webkit-appearance: none; appearance: none; } #brm-map .brm-marker::before, #brm-map .brm-marker::after { content: none !important; display: none !important; } #brm-map .brm-marker svg { width: 36px; height: 44px; display: block; transition: transform .15s; transform-origin: 50% 100%; } #brm-map .brm-marker path { fill: #ffffff; stroke: #f5832a; stroke-width: 2; } #brm-map .brm-marker circle { fill: #f5832a; } #brm-map .brm-marker--active path { fill: #f5832a; } #brm-map .brm-marker--active circle { fill: #ffffff; } #brm-map .brm-marker:hover svg, #brm-map .brm-marker--active svg { transform: scale(1.1); } #brm-map .brm-marker:focus-visible { outline: 2px solid #002035; outline-offset: 2px; } /* Keep Mapbox's own controls clear of the info card */ .brm-map .mapboxgl-ctrl-bottom-left, .brm-map .mapboxgl-ctrl-bottom-right { z-index: 11; } /* White overlay card floating at bottom center */ .brm-overlay { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); width: min(800px, calc(100% - 32px)); background: #ffffff; box-shadow: 0 4px 24px rgba(0,0,0,.18); z-index: 10; border-radius:10px; } /* Tabs */ .brm-tabs { display: flex; border-bottom: 1px solid #e8e3dc; } .brm-tab { flex: 1; padding: 12px 8px; font-size: 13px; font-weight: 600; color: #999; background: none; border: none; border-radius:0px !important; border-left: 1px solid #fff; cursor: pointer; text-align: center; transition: color .15s, border-color .15s; white-space: nowrap; line-height: 1.3; } .brm-tab.brm-tab--active { background-color:#002035 !important; } .brm-tab:hover { background-color: #002035; } .brm-tab--active { color: #f5832a; border-bottom-color: #f5832a; } button.brm-tab:first-child { border-top-left-radius: 10px !important; } button.brm-tab:last-child { border-top-right-radius: 10px !important; } /* Info panel */ .brm-panel { display: none; padding: 18px 24px; gap: 24px; align-items: flex-start; } .brm-panel--active { display: flex; } .brm-panel-left { flex: 0 0 45%; min-width: 0; } .brm-name { font-size: 16px; font-weight: 700; color: #002035; margin-bottom: 5px; line-height: 1.4; } .brm-addr { font-size: 14px; color: #333; margin-bottom: 20px; line-height: 1.5; } .brm-phone { display: block; font-size: 14px; font-weight: 700; color: #f5832a; text-decoration: none; margin-bottom: 14px; transition: color .15s; } .brm-phone:hover { color: #e36c15; } .brm-actions { display: flex; gap: 10px; flex-wrap: wrap; } .brm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 22px; font-size: 12px; line-height:1em; font-weight: 700; text-decoration: none; cursor: pointer; border: none; border-radius: 10px; text-transform: uppercase; letter-spacing: .5px; transition: background .15s, color .15s; white-space: nowrap; color:#fff !important; } .brm-btn svg { width: 15px; height: 15px; flex-shrink: 0; } .brm-btn--primary { background: #4ab3e8; color: #fff; } .brm-btn--primary:hover { background: #33a0d8; color: #fff; } .brm-btn--secondary { background: #f5a623; border: none; color: #fff; } .brm-btn--secondary:hover { background: #e09515; color: #fff; } /* Vertical divider */ .brm-divider { width: 1px; background: #e8e3dc; align-self: stretch; flex-shrink: 0; } /* Service areas */ .brm-panel-right { flex: 1; min-width: 0; } .brm-areas-label { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #aaa; margin-bottom: 8px; } .brm-areas { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; padding: 0; margin: 0; } .brm-areas li { font-size: 11px; background: #f7f5f2; border: 1px solid #e8e3dc; padding: 3px 9px; transition: border-color .15s; } .brm-areas li a { color: #444; text-decoration: none; display: block; font-size:14px; } .brm-areas li:hover { border-color: #f5832a; } .brm-areas li:hover a { color: #f5832a; } /* Mobile */ @media (max-width: 640px) { .brm-wrap { height: 620px; } .brm-overlay { bottom: 0; width: 100%; } .brm-panel { flex-direction: column; padding: 14px 16px; } .brm-divider { width: 100%; height: 1px; align-self: auto; } .brm-tab { font-size: 11px; padding: 10px 4px; } } @media (max-width: 900px) { .brm-overlay { width: calc(100% - 32px); } } @media (max-width: 640px) { .brm-wrap { height: 720px; } .brm-overlay { bottom: 0; width: 100%; border-radius: 10px 10px 0 0; } .brm-panel { flex-direction: column; padding: 14px 16px; gap: 14px; } .brm-panel-left { flex: none; width: 100%; } .brm-divider { width: 100%; height: 1px; align-self: auto; } .brm-tab { font-size: 11px; padding: 10px 4px; } .brm-btn { padding: 11px 14px; font-size: 11px; } .brm-panel-right { width: 100%; } .brm-areas li a { font-size: 12px; } } @media (max-width: 420px) { .brm-wrap { height: 780px; } .brm-tabs { overflow-x: auto; } .brm-tab { font-size: 10px !important; padding: 10px 6px !important; min-width: 70px; } .brm-btn { justify-content: center; } } (function() { var BR_LOCATIONS = [{"id":"loc-east","label":"East Las Vegas","tab":"East","address":"3874 Silvestri Lane, Las Vegas, NV 89120","phone":"(702) 381-5080","lat":36.0867,"lng":-115.0742,"areas":[{"name":"Henderson, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-henderson-nv\/"},{"name":"Paradise, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-paradise-nv\/"},{"name":"Green Valley, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-green-valley-nv\/"},{"name":"Anthem, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-anthem-nv\/"},{"name":"Seven Hills, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-seven-hills-nv\/"},{"name":"Boulder City, NV","url":"https:\/\/bobsrepair.com\/service-area\/boulder-city-nv\/"},{"name":"Sunrise Manor, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-sunrise-manor-nv\/"},{"name":"Inspirada, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-inspirada-nv\/"},{"name":"MacDonald Ranch, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-macdonald-ranch-nv\/"}]},{"id":"loc-north","label":"North Las Vegas","tab":"North","address":"6628 Sky Pointe, Suite 123, Las Vegas, NV 89131","phone":"(702) 444-2073","lat":36.2724,"lng":-115.2521,"areas":[{"name":"Centennial Hills, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-centennial-hills-nv\/"},{"name":"North Las Vegas, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-north-las-vegas-nv\/"}]},{"id":"loc-central","label":"Central Las Vegas","tab":"Central","address":"2500 N Buffalo Dr, Suite 100, Las Vegas, NV 89128","phone":"(702) 530-3991","lat":36.1866,"lng":-115.2631,"areas":[{"name":"Summerlin, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-summerlin-nv\/"},{"name":"The Lakes, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-the-lakes-nv\/"}]},{"id":"loc-southwest","label":"Southwest Las Vegas","tab":"Southwest","address":"758 Shiva St, Las Vegas, NV 89178","phone":"(702) 444-2073","lat":36.0397,"lng":-115.2398,"areas":[{"name":"Enterprise, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-enterprise-nv\/"},{"name":"Southern Highlands, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-southern-highlands\/"},{"name":"Spanish Hills, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-spanish-hills-nv\/"},{"name":"Spanish Trail, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-spanish-trail-nv\/"},{"name":"Spring Valley, NV","url":"https:\/\/bobsrepair.com\/service-area\/ac-repair-spring-valley-nv\/"}]}]; var BR_TOKEN = "pk.eyJ1IjoiY2F2YWxsb2FnZW5jeSIsImEiOiJjbXR4NW9vZ2EwMXI1MnhvbW5sc2xtOXQ1In0.E8yG8nF8aMYr2FsbGmeqTg"; var GL_VERSION = '3.30.0'; var GL_JS = 'https://api.mapbox.com/mapbox-gl-js/v' + GL_VERSION + '/mapbox-gl.js'; var GL_CSS = 'https://api.mapbox.com/mapbox-gl-js/v' + GL_VERSION + '/mapbox-gl.css'; var GL_STYLE = 'mapbox://styles/mapbox/light-v11'; /* Brand palette, carried over from the previous map */ var C = { land: '#f5f0e8', water: '#c9dce8', park: '#d4e8d0', built: '#ece8e0', road: '#ffffff', highway: '#f5e6c8', label: '#555555', labelHalo: '#f5f0e8', roadLabel: '#777777', poiLabel: '#888888', parkLabel: '#6a9e6a', admin: '#cccccc' }; var PIN_SVG = ' ' + ' ' + ' '; var wrap = document.getElementById('brm-wrap'); var mapEl = document.getElementById('brm-map'); var overlay = document.getElementById('brm-overlay'); var tabEls = [].slice.call(document.querySelectorAll('.brm-tab')); var panelEls = [].slice.call(document.querySelectorAll('.brm-panel')); var map = null, markers = [], activeIndex = 0, armed = false, starting = false; /* Switch active location — called by tab clicks and marker clicks */ function switchTo(index) { activeIndex = index; tabEls.forEach(function(tab, i) { tab.classList.toggle('brm-tab--active', i === index); tab.setAttribute('aria-selected', i === index ? 'true' : 'false'); }); panelEls.forEach(function(panel, i) { panel.classList.toggle('brm-panel--active', i === index); }); markers.forEach(function(m, i) { m.getElement().classList.toggle('brm-marker--active', i === index); m.getElement().style.zIndex = i === index ? 3 : 2; }); /* Panning an already-loaded map is free, so this costs nothing */ var loc = BR_LOCATIONS[index]; if (map && loc) { map.flyTo({ center: [loc.lng, loc.lat], zoom: Math.max(map.getZoom(), 12), padding: mapPadding(), duration: 900 }); } } /* Keep the map's content clear of the floating info card */ function mapPadding() { var pad = { top: 50, bottom: 60, left: 50, right: 50 }; if (overlay && wrap) { var o = overlay.getBoundingClientRect(); var w = wrap.getBoundingClientRect(); if (o.height && w.height) { pad.bottom = Math.max(60, Math.min(w.height - 140, w.bottom - o.top + 16)); } } return pad; } /* Frame every office, or centre the single one */ function fitView(animate) { if (!map) { return; } var duration = animate ? 700 : 0; if (BR_LOCATIONS.length === 1) { map.easeTo({ center: [BR_LOCATIONS[0].lng, BR_LOCATIONS[0].lat], zoom: 12, padding: mapPadding(), duration: duration }); return; } var bounds = new mapboxgl.LngLatBounds(); BR_LOCATIONS.forEach(function(loc) { bounds.extend([loc.lng, loc.lat]); }); map.fitBounds(bounds, { padding: mapPadding(), maxZoom: 12, duration: duration }); } /* Recolour the stock light style to the brand palette */ function brandStyle() { var style = map.getStyle(); var layers = (style && style.layers) || []; layers.forEach(function(layer) { var id = layer.id; var type = layer.type; var src = layer['source-layer'] || ''; function paint(prop, value) { try { map.setPaintProperty(id, prop, value); } catch (e) {} } if (type === 'background') { paint('background-color', C.land); return; } if (type === 'symbol') { paint('text-halo-color', C.labelHalo); paint('text-halo-width', 1.2); if (src === 'poi_label') { paint('text-color', C.poiLabel); } else if (src === 'natural_label' || /park/.test(id)) { paint('text-color', C.parkLabel); } else if (src === 'road') { paint('text-color', C.roadLabel); } else { paint('text-color', C.label); } return; } var fillProp = type === 'line' ? 'line-color' : 'fill-color'; if (src === 'water' || src === 'waterway' || /water/.test(id)) { paint(fillProp, C.water); return; } if (/park|grass|pitch|golf|cemetery|wood|scrub|landcover/.test(id) || src === 'landcover') { paint(fillProp, C.park); return; } if (src === 'admin') { paint('line-color', C.admin); return; } if (src === 'building') { paint('fill-color', C.built); return; } if (src === 'road' || src === 'aeroway') { paint(fillProp, /motorway|trunk|primary/.test(id) ? C.highway : C.road); return; } if (src === 'landuse' || src === 'landuse_overlay' || src === 'structure') { paint(fillProp, C.built); return; } }); } function addMarkers() { BR_LOCATIONS.forEach(function(loc, i) { var el = document.createElement('button'); el.type = 'button'; el.className = 'brm-marker' + (i === activeIndex ? ' brm-marker--active' : ''); el.setAttribute('aria-label', loc.label + ' location'); el.innerHTML = PIN_SVG; el.style.zIndex = i === activeIndex ? 3 : 2; el.addEventListener('click', function(e) { e.stopPropagation(); switchTo(i); }); markers.push(new mapboxgl.Marker({ element: el, anchor: 'bottom' }) .setLngLat([loc.lng, loc.lat]) .addTo(map)); }); } function initMap() { if (!window.mapboxgl || !BR_TOKEN || BR_TOKEN.indexOf('pk.') !== 0) { return; } if (typeof mapboxgl.supported === 'function' && !mapboxgl.supported()) { return; } mapboxgl.accessToken = BR_TOKEN; var single = BR_LOCATIONS.length === 1; map = new mapboxgl.Map({ container: mapEl, style: GL_STYLE, projection: 'mercator', center: single ? [BR_LOCATIONS[0].lng, BR_LOCATIONS[0].lat] : [-115.18, 36.15], zoom: single ? 12 : 9.5, cooperativeGestures: true, /* page scroll keeps working over the map */ dragRotate: false, pitchWithRotate: false, attributionControl: true /* required by Mapbox's terms — leave it on */ }); if (map.touchZoomRotate && map.touchZoomRotate.disableRotation) { map.touchZoomRotate.disableRotation(); } map.addControl(new mapboxgl.NavigationControl({ showCompass: false }), 'bottom-right'); map.on('style.load', brandStyle); map.on('load', function() { addMarkers(); fitView(false); }); } /* Load the library, then the map. One map load per page view. */ function start() { if (map || starting) { return; } starting = true; if (!document.getElementById('brm-gl-css')) { var css = document.createElement('link'); css.id = 'brm-gl-css'; css.rel = 'stylesheet'; css.href = GL_CSS; document.head.appendChild(css); } if (window.mapboxgl) { initMap(); return; } var script = document.createElement('script'); script.async = true; script.src = GL_JS; script.onload = initMap; script.onerror = function() { starting = false; }; document.head.appendChild(script); } /* ---------------------------------------------------------------- */ /* Wiring */ /* ---------------------------------------------------------------- */ tabEls.forEach(function(tab, i) { tab.addEventListener('click', function() { switchTo(i); }); }); if (!wrap || !mapEl) { return; } window.addEventListener('resize', function() { if (map) { map.resize(); } }); /* * Nothing is requested from Mapbox until a real person interacts with the * page AND the map is near the viewport. Crawlers and headless browsers do * neither, so they never count as a map load. */ var GESTURES = ['wheel', 'touchstart', 'pointerdown', 'mousemove', 'keydown']; var GESTURE_OPTS = { passive: true }; function nearViewport() { var rect = wrap.getBoundingClientRect(); var vh = window.innerHeight || document.documentElement.clientHeight || 0; return rect.bottom > -300 && rect.top < vh + 300; } function watchViewport() { if (nearViewport()) { start(); return; } if ('IntersectionObserver' in window) { var io = new IntersectionObserver(function(entries) { for (var i = 0; i < entries.length; i++) { if (entries[i].isIntersecting) { io.disconnect(); start(); return; } } }, { rootMargin: '300px 0px' }); io.observe(wrap); return; } var onScroll = function() { if (!nearViewport()) { return; } window.removeEventListener('scroll', onScroll, GESTURE_OPTS); start(); }; window.addEventListener('scroll', onScroll, GESTURE_OPTS); } function arm() { if (armed) { return; } armed = true; GESTURES.forEach(function(type) { window.removeEventListener(type, arm, GESTURE_OPTS); }); watchViewport(); } GESTURES.forEach(function(type) { window.addEventListener(type, arm, GESTURE_OPTS); }); })();