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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@trapar-waves/react-three-maplibre

v1.1.20

Published

A React library integrating Three.js and MapLibre for 3D map visualization

Downloads

513

Readme

@trapar-waves/react-three-maplibre

npm version npm dm License GitHub last commit GitHub Actions Workflow Status Renovate


中文 | 日本語 | Русский язык

A React-based library integrating Three.js, MapLibre, and AntV for advanced geospatial 3D visualizations.

✨ Features

  • Geospatial Visualization: Combines @antv/l7 and maplibre-gl for powerful geospatial data rendering with custom map layers.
  • 3D Rendering with React: Leverages @react-three/fiber and @react-three/drei to integrate Three.js into a React-based workflow for declarative 3D scene management.
  • Customizable UI Integration: Offers seamless integration with React (react, react-dom) for building interactive geospatial applications.
  • Utility-First Styling: Employs tailwindcss for flexible and rapid styling of components and layouts.
  • Type Safety: Uses TypeScript to ensure type safety and improve developer experience during development.
  • Fast Development Workflow: Utilizes rsbuild for optimized builds and efficient development server performance.
  • Rich Component Library: Integrates with three-stdlib and @react-three/drei for reusable Three.js utilities and components.
  • Map Interactivity: Implements react-map-gl for interactive map controls and client-side navigation in geospatial contexts.
  • AntV Enhancements: Incorporates @antv/l7-maps for additional map layering capabilities and visualization tools.

💻 Tech Stack

  • Framework/Library: React
  • UI Toolkit/Styling: Tailwind CSS
  • 3D Rendering: Three.js (@react-three/fiber, @react-three/drei)
  • Geospatial Libraries: MapLibre GL, AntV L7
  • Build Tool: Rsbuild
  • Language: TypeScript

See the package.json for a full list of dependencies.

🚀 Getting Started

Follow these instructions to get the project running locally.

Prerequisites

Ensure you have the following installed:

  • Node.js (>= 18.x recommended)
  • Package manager (npm, yarn, or pnpm)
node -v
npm -v

Installation

  1. Create a new project using the template:
pnpm create trapar-waves
  1. Navigate to your project directory and install dependencies:
cd your-project-name
pnpm install
# or
npm install
# or
yarn install

Development

Start the development server with hot reloading:

pnpm dev
# or
npm run dev
# or
yarn dev

The application will be available at http://localhost:3000 by default.

Building for Production

To create a production build:

pnpm build
# or
npm run build
# or
yarn build

Preview the production build locally:

pnpm preview
# or
npm run preview
# or
yarn preview

📦 Usage

This library is designed to be used as a template for creating geospatial 3D visualization applications. It provides a foundational setup with React, Three.js, MapLibre GL, and AntV L7.

Basic Example

Here's a simple example of how to use the components provided by this template:

// App.tsx
import type { ReactNode } from "react";
import type { MapRef } from "react-map-gl/maplibre";
import { PointLayer, Scene } from "@antv/l7";
import { MapLibre } from "@antv/l7-maps";
import { Box, Stats } from "@react-three/drei";
import { extend } from "@react-three/fiber";
import { useRef } from "react";
import Map from "react-map-gl/maplibre";
import { Canvas } from "react-three-map/maplibre";
import { LineMaterial, LineSegments2, LineSegmentsGeometry } from "three-stdlib";

extend({ LineSegmentsGeometry, LineMaterial, LineSegments2 });

declare module "@react-three/fiber" {
  interface ThreeElements {
    lineSegmentsGeometry: ThreeElements["bufferGeometry"];
    lineMaterial: ThreeElements["material"] & Partial<LineMaterial>;
    lineSegments2: ThreeElements["object3D"] & { children?: ReactNode };
  }
}

const latLon = {
  latitude: 31.215175,
  longitude: 121.417463,
};
const MAPTILER_KEY = import.meta.env.PUBLIC_MAPTILER_KEY;

function App() {
  const ref = useRef<HTMLDivElement>(null!);
  const mapRef = useRef<MapRef>(null!);
  function initL7() {
    if (mapRef.current) {
      const scene = new Scene({
        id: "map",
        map: new MapLibre({
          mapInstance: mapRef.current.getMap(),
        }),
      });
      scene.on("loaded", () => {
        fetch("/BElVQFEFvpAKzddxFZxJ.txt")
          .then(res => res.text())
          .then((data) => {
            const pointLayer = new PointLayer({
              blend: "additive",
            })
              .source(data, {
                parser: {
                  type: "csv",
                  y: "lat",
                  x: "lng",
                },
              })
              .size(0.5)
              .color("#080298");

            scene.addLayer(pointLayer);
          });
      });
    }
  }
  return (
    <div className="h-screen w-screen relative overflow-hidden" ref={ref}>
      <Map
        id="map"
        ref={mapRef}
        initialViewState={{
          ...latLon,
          zoom: 11,
          pitch: 64.88,
        }}
        mapStyle={`https://api.maptiler.com/maps/streets/style.json?key=${MAPTILER_KEY}`}
        onLoad={initL7}
      >
        <Stats className="stats" parent={ref} />

        <Canvas {...latLon}>
          <hemisphereLight
            args={["#ffffff", "#60666C"]}
            position={[1, 4.5, 3]}
          />
          <object3D scale={500}>
            <Box position={[-1.2, 1, 0]} />
            <Box position={[1.2, 1, 0]} />
          </object3D>
        </Canvas>
      </Map>
    </div>
  );
}

export default App;

This example demonstrates:

  • Creating a MapLibre GL map with react-map-gl
  • Integrating AntV L7 for geospatial data visualization
  • Using React Three Fiber and Drei for 3D rendering
  • Positioning 3D objects relative to the map using react-three-map

Environment Variables

To use map services like MapTiler, you'll need to set up environment variables. Create a .env file in your project root:

PUBLIC_MAPTILER_KEY=your_maptiler_api_key_here

Make sure to add .env to your .gitignore to keep your keys secure.

🤝 Contributing

Contributions are welcome and greatly appreciated! Please follow these steps to contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Please ensure your code follows the existing style and passes all tests.

👤 Author

🔗 Links