npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nora-soderlund/google-maps-solar-api

v1.1.2

Published

A TypeScript implementation of Google Maps Solar API endpoints.

Downloads

812

Readme

google-maps-solar-api

This is a TypeScript package for calling the new Solar API endpoints, including full types for all query inputs and body responses.

Get started

npm install @nora-soderlund/google-maps-solar-api

Getting building insights from a coordinate

import { findClosestBuildingInsights } from "@nora-soderlund/google-maps-solar-api";

const buildingInsights = await findClosestBuildingInsights("API_KEY", {
  location: {
    latitude: 57.70936,
    longitude: 11.97345
  }
});

Getting data layers from a coordinate

import { getDataLayers } from "@nora-soderlund/google-maps-solar-api";

const dataLayers = await getDataLayers("API_KEY", {
  location: coordinate,
  radiusMeters: 100,
  view: "IMAGERY_AND_ANNUAL_FLUX_LAYERS"
});

Using a proxy URL instead of API key

You can use your own Solar API proxy to implement this package in your clients and apply rate limiting or session authentication on your end.

Simply pass a URL object instead of a string in replacement of the API key. Only the host will be used, the protocol must be HTTPS.

import { findClosestBuildingInsights } from "@nora-soderlund/google-maps-solar-api";

const proxyUrl = new URL("https://my-solar-api-proxy.com");

const buildingInsights = await findClosestBuildingInsights(proxyUrl, {
  location: {
    latitude: 57.70936,
    longitude: 11.97345
  }
});

Subsequent request will be sent to e.g. https://my-solar-api-proxy.com/v1/buildingInsights:findClosest?....

Implementation examples

See my developer blog article for an example of using the Solar API data layers with a dynamic Google Maps instance:

https://nora-soderlund.com/articles/integrating-the-new-solar-api-in-google-maps

Another example of visualizing potential solar panel placements in dynamic maps:

https://nora-soderlund.com/articles/visualizing-potential-solar-panel-placements-in-google-maps

References

Building Insights

findClosestBuildingInsights

findClosestBuildingInsights(apiKeyOrProxyUrl: string | URL, query: FindClosestBuildingInsightsParameters): Promise<BuildingInsights>

Returns a BuildingInsights object or throws a generic Error if the request failed.

See buildingInsights.findClosest on the Solar API reference.


Data Layers

getDataLayers

getDataLayers(apiKeyOrProxyUrl: string | URL, query: GetDataLayersParameters): Promise<DataLayers>

Returns a DataLayers object or throws a generic Error if the request failed.

See dataLayers.get on the Solar API reference.


getGeoTiff(apiKeyOrProxyUrl: string | URL, url: string): Promise<ArrayBuffer>

Returns a raw ArrayBuffer object of the GeoTIFF file or throws a generic Error if the request failed.

See geoTiff.get on the Solar API reference.


Helpers

getDataLayersForBounds

getDataLayersForBounds(bounds: LatLngBox, pixelSizeMeters: number, paddingMeters: number = 0): DataLayerBounds

Used for getting a connected area coverage. Does not perform any asynchronous requests. Returns a DataLayerBounds object.


DataLayerBounds

dataLayerView: DataLayerView;

The highest supported data layer view, for radius meters over 175m, the DataLayerView in the request must not include monthly flux or hourly shade.

tiles
tiles: LatLng[];

The tiles that make up the generated bounds, use with radiusMetersPerTile

radiusMetersPerTile
radiusMetersPerTile: number;

The radius in meters for each tile.

bounds
bounds: LatLngBox;

The generated bounds for the new tiles.

horizontalTiles
horizontalTiles: number;
verticalTiles
verticalTiles: number;

The horizontal and vertical tiles count.