Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Możesz tworzyć własne obliczenia za pomocą TypeScript. Kod na dole tej strony pomoże Ci określić, czy taniej jest zainstalować panele słoneczne czy dalej płacić za prąd według dotychczasowych zasad.
Oto ogólny opis sposobu, w jaki kod określa koszty paneli słonecznych.
Część 1. Wymagania systemowe i konfiguracja
Najpierw określ bieżące zużycie energii elektrycznej i rachunki:
Ile energii elektrycznej zużywasz co miesiąc? (monthlyKwhEnergyConsumption)
Ile kosztuje prąd? (energyCostPerKwh)
Następnie podaj plany dotyczące układu słonecznego:
Ile paneli? (panelsCount)
Jaka jest moc paneli? (panelCapacityWatts)
Ile kosztuje instalacja? (installationCostPerWatt)
Czy są jakieś rabaty na system? (solarIncentives)
Część 2. Obliczenia
Na podstawie podanych wartości kod oblicza:
yearlyProductionAcKwh: łączna roczna ilość energii elektrycznej, jaką mogą wygenerować panele słoneczne.
totalCostWithSolar: koszt energii elektrycznej w ciągu wielu lat z wykorzystaniem paneli słonecznych.
totalCostWithoutSolar: koszt energii elektrycznej przez wiele lat bez paneli słonecznych.
Część 3. Wyniki
Kod zawiera też te informacje:
savings: różnica między kosztami z panelami słonecznymi i bez nich.
breakEvenYear: ile lat zajmie wyrównanie kosztów paneli słonecznych do oszczędności na energii elektrycznej.
Przykładowy kod
// Solar configuration, from buildingInsights.solarPotential.solarPanelConfigsletpanelsCount=20;letyearlyEnergyDcKwh=12000;// Basic settingsletmonthlyAverageEnergyBill:number=300;letenergyCostPerKwh=0.31;letpanelCapacityWatts=400;letsolarIncentives:number=7000;letinstallationCostPerWatt:number=4.0;letinstallationLifeSpan:number=20;// Advanced settingsletdcToAcDerate=0.85;letefficiencyDepreciationFactor=0.995;letcostIncreaseFactor=1.022;letdiscountRate=1.04;// Solar installationletinstallationSizeKw:number=(panelsCount*panelCapacityWatts)/1000;letinstallationCostTotal:number=installationCostPerWatt*installationSizeKw*1000;// Energy consumptionletmonthlyKwhEnergyConsumption:number=monthlyAverageEnergyBill/energyCostPerKwh;letyearlyKwhEnergyConsumption:number=monthlyKwhEnergyConsumption*12;// Energy produced for installation life spanletinitialAcKwhPerYear:number=yearlyEnergyDcKwh*dcToAcDerate;letyearlyProductionAcKwh:number[]=[...Array(installationLifeSpan).keys()].map((year)=>initialAcKwhPerYear*efficiencyDepreciationFactor**year,);// Cost with solar for installation life spanletyearlyUtilityBillEstimates:number[]=yearlyProductionAcKwh.map((yearlyKwhEnergyProduced,year)=>{constbillEnergyKwh=yearlyKwhEnergyConsumption-yearlyKwhEnergyProduced;constbillEstimate=(billEnergyKwh*energyCostPerKwh*costIncreaseFactor**year)/discountRate**year;returnMath.max(billEstimate,0);// bill cannot be negative},);letremainingLifetimeUtilityBill:number=yearlyUtilityBillEstimates.reduce((x,y)=>x+y,0);lettotalCostWithSolar:number=installationCostTotal+remainingLifetimeUtilityBill-solarIncentives;console.log(`Cost with solar: $${totalCostWithSolar.toFixed(2)}`);// Cost without solar for installation life spanletyearlyCostWithoutSolar:number[]=[...Array(installationLifeSpan).keys()].map((year)=>(monthlyAverageEnergyBill*12*costIncreaseFactor**year)/discountRate**year,);lettotalCostWithoutSolar:number=yearlyCostWithoutSolar.reduce((x,y)=>x+y,0);console.log(`Cost without solar: $${totalCostWithoutSolar.toFixed(2)}`);// Savings with solar for installation life spanletsavings:number=totalCostWithoutSolar-totalCostWithSolar;console.log(`Savings: $${savings.toFixed(2)} in ${installationLifeSpan} years`);
[null,null,["Ostatnia aktualizacja: 2025-03-09 UTC."],[[["\u003cp\u003eThis webpage provides TypeScript code to calculate and compare the long-term costs of using solar panels versus continuing with your current electricity bill.\u003c/p\u003e\n"],["\u003cp\u003eThe code considers factors such as electricity consumption, solar panel system specifications, installation costs, incentives, and energy cost inflation to project expenses over time.\u003c/p\u003e\n"],["\u003cp\u003eBy comparing the total cost with and without solar, you can determine the potential savings and the break-even point for your solar panel investment.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code requires inputting your specific energy usage, solar panel system details, and financial parameters to generate personalized results.\u003c/p\u003e\n"]]],["The provided TypeScript code calculates the long-term cost-effectiveness of installing solar panels. It takes inputs like monthly energy consumption, electricity cost, panel count, panel capacity, installation cost, and incentives. The code then computes the annual electricity generation from solar panels, the total electricity cost with and without solar over a set lifespan, the difference in savings between both options, and the break-even year where the savings match the investment cost.\n"],null,["# Calculate costs and savings in TypeScript\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google\n| Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. [Learn more](/maps/comms/eea/faq). In addition, certain content from the Solar API will no longer be returned. [Learn more](/maps/comms/eea/solar).\n\nYou can create your own calculations using TypeScript. The code at the bottom of\nthis page helps you determine whether it's cheaper in the long run to install\nsolar panels or continue paying your electricity bill as is.\n\nHere's a high-level breakdown of how the code determines solar panel costs.\n\nPart 1: System needs and setup\n------------------------------\n\nFirst, define your current electricity usage and bills:\n\n- How much electricity do you use each month? (`monthlyKwhEnergyConsumption`)\n- How much does that electricity cost? (`energyCostPerKwh`)\n\nNext, enter your solar system plans:\n\n- How many panels? (`panelsCount`)\n- How powerful are the panels? (`panelCapacityWatts`)\n- How much does installation cost? (`installationCostPerWatt`)\n- Any discounts on the system? (`solarIncentives`)\n\nPart 2: Calculations\n--------------------\n\nBased on the inputted values, the code calculates:\n\n- `yearlyProductionAcKwh`: The total annual electricity your solar panels can generate.\n- `totalCostWithSolar`: The cost of electricity over many years **with** solar panels.\n- `totalCostWithoutSolar`: The cost of electricity over many years **without** solar panels.\n\nPart 3: Results\n---------------\n\nThe code also tells you the following:\n\n- `savings`: The difference between the cost with and without solar panels.\n- `breakEvenYear`: How many years until the cost of solar panels equals the savings on electricity.\n\nExample code\n------------\n\n\n```typescript\n// Solar configuration, from buildingInsights.solarPotential.solarPanelConfigs\nlet panelsCount = 20;\nlet yearlyEnergyDcKwh = 12000;\n\n// Basic settings\nlet monthlyAverageEnergyBill: number = 300;\nlet energyCostPerKwh = 0.31;\nlet panelCapacityWatts = 400;\nlet solarIncentives: number = 7000;\nlet installationCostPerWatt: number = 4.0;\nlet installationLifeSpan: number = 20;\n\n// Advanced settings\nlet dcToAcDerate = 0.85;\nlet efficiencyDepreciationFactor = 0.995;\nlet costIncreaseFactor = 1.022;\nlet discountRate = 1.04;\n\n// Solar installation\nlet installationSizeKw: number = (panelsCount * panelCapacityWatts) / 1000;\nlet installationCostTotal: number = installationCostPerWatt * installationSizeKw * 1000;\n\n// Energy consumption\nlet monthlyKwhEnergyConsumption: number = monthlyAverageEnergyBill / energyCostPerKwh;\nlet yearlyKwhEnergyConsumption: number = monthlyKwhEnergyConsumption * 12;\n\n// Energy produced for installation life span\nlet initialAcKwhPerYear: number = yearlyEnergyDcKwh * dcToAcDerate;\nlet yearlyProductionAcKwh: number[] = [...Array(installationLifeSpan).keys()].map(\n (year) =\u003e initialAcKwhPerYear * efficiencyDepreciationFactor ** year,\n);\n\n// Cost with solar for installation life span\nlet yearlyUtilityBillEstimates: number[] = yearlyProductionAcKwh.map(\n (yearlyKwhEnergyProduced, year) =\u003e {\n const billEnergyKwh = yearlyKwhEnergyConsumption - yearlyKwhEnergyProduced;\n const billEstimate =\n (billEnergyKwh * energyCostPerKwh * costIncreaseFactor ** year) / discountRate ** year;\n return Math.max(billEstimate, 0); // bill cannot be negative\n },\n);\nlet remainingLifetimeUtilityBill: number = yearlyUtilityBillEstimates.reduce((x, y) =\u003e x + y, 0);\nlet totalCostWithSolar: number =\n installationCostTotal + remainingLifetimeUtilityBill - solarIncentives;\nconsole.log(`Cost with solar: $${totalCostWithSolar.toFixed(2)}`);\n\n// Cost without solar for installation life span\nlet yearlyCostWithoutSolar: number[] = [...Array(installationLifeSpan).keys()].map(\n (year) =\u003e (monthlyAverageEnergyBill * 12 * costIncreaseFactor ** year) / discountRate ** year,\n);\nlet totalCostWithoutSolar: number = yearlyCostWithoutSolar.reduce((x, y) =\u003e x + y, 0);\nconsole.log(`Cost without solar: $${totalCostWithoutSolar.toFixed(2)}`);\n\n// Savings with solar for installation life span\nlet savings: number = totalCostWithoutSolar - totalCostWithSolar;\nconsole.log(`Savings: $${savings.toFixed(2)} in ${installationLifeSpan} years`);https://github.com/googlemaps-samples/js-solar-potential/blob/1892b99f1a8e4d7254c8b4426cfe9c8d492108b2/src/routes/sections/SolarPotentialSection.svelte#L53-L108\n```\n| **Note:** Read the [guide](/maps/documentation/javascript/using-typescript) on using TypeScript and Google Maps.\n\n\u003cbr /\u003e"]]