skymap
    Preparing search index...

    Class SkyMap

    SkyMap renders an interactive sky map on a canvas element.

    It calculates positions of stars, planets, the Moon, the Sun, and constellation features using astronomical formulas and renders them based on a configurable visual style.

    The target div element where the canvas will be appended.

    Observer parameters for location and time.

    • latitude: The new latitude in degrees.
    • longitude: The new longitude in degrees.
    • date: The new date/time for astronomical calculations.
    • fov: The new field of view in degrees.

    Configuration to customize colors, sizes, language, etc. Uses defaults for missing fields.

    Index

    Constructors

    • Parameters

      • container: HTMLDivElement
      • observerParams: Partial<ObserverParams> = defaultObserverParams
      • config: {
            bgColor?: string;
            constellations?: {
                boundaries?: {
                    color?: string;
                    data?: string;
                    enabled?: boolean;
                    width?: number;
                };
                lines?: {
                    color?: string;
                    data?: string;
                    enabled?: boolean;
                    labels?: {
                        color?: string;
                        data?: string;
                        enabled?: boolean;
                        fontSize?: number;
                    };
                    width?: number;
                };
            };
            fontFamily?: string;
            glow?: boolean;
            grid?: { color?: string; enabled?: boolean; width?: number };
            language?: string;
            moon?: {
                color?: string;
                enabled?: boolean;
                label?: {
                    color?: string;
                    data?: string;
                    enabled?: boolean;
                    fontSize?: number;
                };
                scale?: number;
            };
            planets?: {
                color?: string;
                enabled?: boolean;
                labels?: {
                    color?: string;
                    data?: string;
                    enabled?: boolean;
                    fontSize?: number;
                };
                scale?: number;
            };
            stars?: {
                color?: string;
                data?: string;
                enabled?: boolean;
                scale?: number;
            };
            sun?: {
                color?: string;
                enabled?: boolean;
                label?: {
                    color?: string;
                    data?: string;
                    enabled?: boolean;
                    fontSize?: number;
                };
                scale?: number;
            };
        } = ...
        • OptionalbgColor?: string

          The background color of the skymap.

          "#000000"
          
        • Optionalconstellations?: {
              boundaries?: {
                  color?: string;
                  data?: string;
                  enabled?: boolean;
                  width?: number;
              };
              lines?: {
                  color?: string;
                  data?: string;
                  enabled?: boolean;
                  labels?: {
                      color?: string;
                      data?: string;
                      enabled?: boolean;
                      fontSize?: number;
                  };
                  width?: number;
              };
          }
          • Optionalboundaries?: { color?: string; data?: string; enabled?: boolean; width?: number }
            • Optionalcolor?: string

              The color of the boundaries.

              "#aaa"
              
            • Optionaldata?: string

              URI to the JSON file containing constellations boundaries data.

              "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/constellations.boundaries.json"
              
            • Optionalenabled?: boolean

              Whether constellation boundaries are displayed.

              false
              
            • Optionalwidth?: number

              The width of the boundaries.

              1
              
          • Optionallines?: {
                color?: string;
                data?: string;
                enabled?: boolean;
                labels?: {
                    color?: string;
                    data?: string;
                    enabled?: boolean;
                    fontSize?: number;
                };
                width?: number;
            }
            • Optionalcolor?: string

              The color of the constellation lines.

              "#eaeaea"
              
            • Optionaldata?: string

              URI to the JSON file containing constellations lines data.

              "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/constellations.lines.json"
              
            • Optionalenabled?: boolean

              Whether constellation lines are displayed.

              true
              
            • Optionallabels?: { color?: string; data?: string; enabled?: boolean; fontSize?: number }
              • Optionalcolor?: string

                The color of the labels.

                "#fefefe"
                
              • Optionaldata?: string

                URI to the JSON file containing constellations labels data.

                "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/constellations.labels.json"
                
              • Optionalenabled?: boolean

                Whether labels are displayed on the constellation lines.

                true
                
              • OptionalfontSize?: number

                The font size of the labels.

                10
                
            • Optionalwidth?: number

              The width of the constellation lines.

              2
              
        • OptionalfontFamily?: string

          The font family used in the skymap. This should be a valid font name that is installed on the page and available in the CSS. For example, "Arial", "Helvetica", or any custom font loaded via @font-face. Ensure the specified font is accessible in the browser to avoid fallback to a default font.

          "Arial"
          
        • Optionalglow?: boolean

          Toggle glow effect for stars and constellations. Can cause performance issues.

          false
          
        • Optionalgrid?: { color?: string; enabled?: boolean; width?: number }
          • Optionalcolor?: string

            The color of the grid lines.

            "#555"
            
          • Optionalenabled?: boolean

            Whether the grid is enabled.

            true
            
          • Optionalwidth?: number

            The width of the grid lines.

            1
            
        • Optionallanguage?: string

          The language used for labels. Available languages by default:

          • "en": English
          • "la": Latin
          • "ar": Arabic
          • "zh": Chinese
          • "fr": French
          • "de": German
          • "el": Greek
          • "he": Hebrew
          • "hi": Hindi
          • "it": Italian
          • "ja": Japanese
          • "ru": Russian
          • "es": Spanish
          • "ko": Korean
          • "fa": Persian
          • "sym": Symbol (☾)
          "en"
          
        • Optionalmoon?: {
              color?: string;
              enabled?: boolean;
              label?: {
                  color?: string;
                  data?: string;
                  enabled?: boolean;
                  fontSize?: number;
              };
              scale?: number;
          }
          • Optionalcolor?: string

            The color of the moon.

            "#eaeaea"
            
          • Optionalenabled?: boolean

            Whether the moon is displayed.

            true
            
          • Optionallabel?: { color?: string; data?: string; enabled?: boolean; fontSize?: number }

            Moon label configuration.

            • Optionalcolor?: string

              The color of the moon label.

              "#fefefe"
              
            • Optionaldata?: string

              URI to the JSON file containing moon labels data.

              "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/moon.labels.json"
              
            • Optionalenabled?: boolean

              Whether the moon label is displayed.

              true
              
            • OptionalfontSize?: number

              The font size in px of the moon label.

              10
              
          • Optionalscale?: number

            A multiplier to scale default moon size.

            1
            
        • Optionalplanets?: {
              color?: string;
              enabled?: boolean;
              labels?: {
                  color?: string;
                  data?: string;
                  enabled?: boolean;
                  fontSize?: number;
              };
              scale?: number;
          }
          • Optionalcolor?: string

            The color of the planets. If undefined, a planet's color will be used.

            undefined
            
          • Optionalenabled?: boolean

            Whether planets are displayed.

            true
            
          • Optionallabels?: { color?: string; data?: string; enabled?: boolean; fontSize?: number }

            Labels for planets.

            • Optionalcolor?: string

              The color of the labels.

              "#fefefe"
              
            • Optionaldata?: string

              URI to the JSON file containing planets labels data.

              "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/planets.labels.json"
              
            • Optionalenabled?: boolean

              Whether planet labels are displayed.

              true
              
            • OptionalfontSize?: number

              The font size in px of the planet's labels.

              12
              
          • Optionalscale?: number

            A multiplier to scale default planet's size.

            1
            
        • Optionalstars?: { color?: string; data?: string; enabled?: boolean; scale?: number }
          • Optionalcolor?: string

            The color of the stars. If undefined, a default will be used.

            undefined
            
          • Optionaldata?: string

            URI to the JSON file containing star data.

            "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/stars.6.json"
            
          • Optionalenabled?: boolean

            Whether stars are displayed.

            true
            
          • Optionalscale?: number

            A multiplier to scale default star's size.

            1
            
        • Optionalsun?: {
              color?: string;
              enabled?: boolean;
              label?: {
                  color?: string;
                  data?: string;
                  enabled?: boolean;
                  fontSize?: number;
              };
              scale?: number;
          }
          • Optionalcolor?: string

            The color of the sun.

            "#ffe484"
            
          • Optionalenabled?: boolean

            Whether the sun is displayed.

            true
            
          • Optionallabel?: { color?: string; data?: string; enabled?: boolean; fontSize?: number }

            Sun label configuration.

            • Optionalcolor?: string

              The color of the sun label.

              "#fefefe"
              
            • Optionaldata?: string

              URI to the JSON file containing sun labels data.

              "https://raw.githubusercontent.com/skewb1k/skymap/refs/heads/main/data/sun.labels.json"
              
            • Optionalenabled?: boolean

              Whether the sun label is displayed.

              true
              
            • OptionalfontSize?: number

              The font size in px of the sun label.

              16
              
          • Optionalscale?: number

            A multiplier to scale default sun size.

            1
            

      Returns SkyMap

    Properties

    cfg: Config

    Reactive configuration object for styling and display options.

    Methods

    • Clones this SkyMap instance, creating a new instance with the same configuration for another container.

      Parameters

      • container: HTMLDivElement

        The target div element where the skymap will be appended.

      Returns SkyMap

      The SkyMap instance.

    • Resizes the canvas while maintaining proper device pixel ratio (DPR) scaling.

      Parameters

      • size: number

        The size in pixels for both width and height to create a square canvas.

      Returns this

      The SkyMap instance.

    • Updates the sky map's date/time.

      Parameters

      • date: Date

        The new date/time for astronomical calculations.

      Returns this

      The SkyMap instance for chaining.

    • Animates the change of date/time over a specified duration.

      Parameters

      • date: Date

        The new date/time for astronomical calculations.

      • duration: number

        Duration of the animation in milliseconds.

      Returns this

      The SkyMap instance for chaining.

    • Updates the field of view (FOV).

      Parameters

      • fov: number

        The new field of view in degrees.

      Returns this

      The SkyMap instance for chaining.

    • Updates the observer's latitude.

      Parameters

      • latitude: number

        The new latitude in degrees.

      Returns this

      The SkyMap instance for chaining.

    • Updates both the observer's latitude and longitude.

      Parameters

      • latitude: number

        The new latitude in degrees.

      • longitude: number

        The new longitude in degrees.

      Returns this

      The SkyMap instance.

    • Animates the change of location (latitude and longitude) over a specified duration.

      Parameters

      • latitude: number

        The new latitude in degrees.

      • longitude: number

        The new longitude in degrees.

      • duration: number

        Duration of the animation in milliseconds.

      Returns this

      The SkyMap instance for chaining.

    • Updates the observer's longitude.

      Parameters

      • longitude: number

        The new longitude in degrees.

      Returns this

      The SkyMap instance for chaining.

    • Replaces the current observer parameters with the given ones.

      Parameters

      • observerParams: ObserverParams

        An object containing the new observer parameters:

        • latitude: The new latitude in degrees.
        • longitude: The new longitude in degrees.
        • date: The new date/time for astronomical calculations.
        • fov: The new field of view in degrees.

      Returns Promise<void>