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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@icgcat/toggle3d

v0.0.2

Published

A Svelte Toggle 3D component for Maplibre

Readme

License Version X

3D Terrain Toggle Component

version 0.0.1

This Svelte component provides a button to toggle between 2D and 3D terrain visualization on a MapLibre-based map. The component dynamically adjusts terrain sources based on the map's location and zoom level.


Installation

Install the component via npm:

npm install @icgcat/toggle3d

Features

  • 3D Terrain Visualization: Enable and disable 3D terrain on a MapLibre map.
  • Dynamic Terrain Source: Switches between two terrain sources based on location and zoom.
    • ICGC Terrain: Used for areas within Catalonia.
    • MapZen Terrain: Used for other regions.
  • Customizable Options: Set pitch angle, terrain exaggeration, and button position.
  • Smooth Transitions: Includes animation when toggling terrain.

Props

The component accepts the following properties:

| Property | Default | Description | |-----------------------|---------------|-----------------------------------------------------------------------------| | map | null | Required. The MapLibre map instance. | | pitch | 60 | The pitch angle (in degrees) for 3D visualization. | | terrainExaggeration | 1.5 | Exaggeration factor for the terrain. | | position | "bottomright" | Button position: topleft, topright, bottomleft, bottomright. |


Usage Example

Svelte

<script>
    import Toggle3d from "@icgcat/toggle3d";
    import maplibre from "maplibre-gl";

    let map;

    // Initialize the map
    onMount(() => {
        map = new maplibre.Map({
            container: "map",
            style: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
            center: [2.1734, 41.3851], // Barcelona
            zoom: 9,
        });
    });
</script>

<div id="map" style="width: 100%; height: 400px;"></div>
<Toggle3d {map} pitch={45} terrainExaggeration={2} position="topright" />

Terrain Sources

The component uses the following terrain sources:

  • ICGC Terrain: urlTerrainIcgc (specific to Catalonia).
  • MapZen Terrain: urlTerrainMapZen (global fallback).

API Methods

toggle()

Toggles between 2D and 3D terrain.

  • Behavior:
    • Activates 3D terrain with dynamic source selection.
    • Restores 2D map when toggled off.

Styling

The button is styled by default but can be customized using the following CSS classes:

| Class | Description | |---------------|-----------------------| | .topleft | Positions button at top-left corner. | | .topright | Positions button at top-right corner. | | .bottomleft | Positions button at bottom-left corner. | | .bottomright| Positions button at bottom-right corner. |

Default button styles:

button {
    padding: 6px;
    font-size: 14px;
    background-color: #c4c4c4;
    color: black;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    z-index: 9999;
}

button:hover {
    background-color: #949393;
}

License

This project is licensed under the MIT License.