Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Puedes crear tus propios cálculos con TypeScript. El código que se encuentra en la parte inferior de esta página te ayuda a determinar si a largo plazo es más económico instalar paneles solares o seguir pagando la factura de electricidad como está.
Aquí tienes un desglose detallado de cómo el código determina los costos de los paneles solares.
Parte 1: Necesidades y configuración del sistema
Primero, define tu consumo y tus facturas de electricidad actuales:
¿Cuánta electricidad usas cada mes? (monthlyKwhEnergyConsumption)
¿Cuánto cuesta la electricidad? (energyCostPerKwh)
A continuación, ingresa tus planes para el sistema solar:
¿Cuántos paneles? (panelsCount)
¿Qué tan potentes son los paneles? (panelCapacityWatts)
¿Cuánto cuesta la instalación? (installationCostPerWatt)
¿Hay descuentos en el sistema? (solarIncentives)
Parte 2: Cálculos
En función de los valores ingresados, el código calcula lo siguiente:
yearlyProductionAcKwh: Es la electricidad anual total que pueden generar tus paneles solares.
totalCostWithSolar: El costo de la electricidad durante muchos años con paneles solares.
totalCostWithoutSolar: El costo de la electricidad durante muchos años sin paneles solares.
Parte 3: Resultados
El código también te indica lo siguiente:
savings: Es la diferencia entre el costo con y sin paneles solares.
breakEvenYear: Indica cuántos años faltan para que el costo de los paneles solares sea igual al ahorro en electricidad.
Ejemplo de código
// 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,["Última actualización: 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"]]