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

olreactmap

v0.1.0

Published

A powerful, React-based mapping library wrapping OpenLayers, designed for building professional GIS applications with ease.

Readme

OpenMap Library

A powerful, React-based mapping library wrapping OpenLayers, designed for building professional GIS applications with ease.

Features

  • React-First: Fully declarative component API for managing maps and layers.
  • Advanced Layer Management:
    • Support for Vector (GeoJSON/WFS), Raster (WMS/XYZ), and WebGL layers.
    • Interactive Layer Panel: Toggle visibility, adjust opacity, and reorder layers.
    • Style Controls: Real-time attribute styling (Fill, Stroke, Width) for vector layers.
    • Layer Info: View detailed metadata, feature counts, and projection info.
  • Interactive Tools:
    • Drawing: Draw points, lines, and polygons.
    • Measuring: Measure distances and areas with dynamic tooltips.
    • Feature Selection: Inspect feature properties with a built-in Popup.
  • Professional UI:
    • Collapsible Sidebar: Smoothly animated sidebar for layer management.
    • Map Widgets: ScaleLine, MousePosition, Zoom controls, and Fullscreen toggle.
    • Toasts & Tooltips: Integrated feedback for user actions.
  • Performance Optimized:
    • Smart re-rendering logic to prevent unnecessary map updates.
    • WebGL support for rendering large datasets.
    • Marker clustering for high-density point data.

Installation

npm install openmap
# or
yarn add openmap

Note: This is a private library. Ensure you have access to the repository or registry.

Basic Usage

Wrap your application in the <OpenMap> provider. This context handles map state, tool interactions, and layer management automatically.

import React, { useMemo } from 'react';
import { 
  OpenMap, 
  VectorLayer, 
  ImageLayer, 
  MapWidgets, 
  Sidebar,
  BottomToolbar,
  MapPopup,
  useFeatureClick // Import the hook
} from 'openmap';
import 'openmap/em/index.css'; 

// Create a component that consumes the MapContext
const MapContent = () => {
  // Memoize params to prevent unnecessary layer re-initializations
  const wmsParams = useMemo(() => ({ "Layers": "tiger:poi" }), []);

  // Hook for handling feature clicks
  useFeatureClick({
    onClick: (feature) => {
        console.log("Clicked feature:", feature);
    }
  });

  return (
    <>
        {/* Layout & UI */}
        <Sidebar />
        <MapWidgets />
        <MapPopup />

        {/* Raster Layer (WMS) */}
        <ImageLayer 
            name="Tiger POI" 
            sourceUrl="http://localhost:8080/geoserver/tiger/wms" 
            params={wmsParams} 
        />

        {/* Vector Layer (GeoJSON) */}
        <VectorLayer 
            name="Landmarks" 
            geoJsonUrl="http://localhost:8080/geoserver/tiger/ows?..." 
            visible={true} 
            zIndex={1}
        />

        {/* Interaction Tools */}
        <BottomToolbar 
            onDrawComplete={(geojson) => {
                console.log("Drawn GeoJSON:", geojson);
            }}
            onMeasureComplete={(measure) => {
                console.log("Measurement:", measure);
            }}
            onSelectedFeature={(feature) => {
                console.log("Selected Feature:", feature);
            }}
            onModifiedFeature={(geojson) => {
                console.log("Modified Feature:", geojson);
            }}
        />
    </>
  );
};

// Wrap with the OpenMap provider
const App = () => {
  return (
    <OpenMap>
      <MapContent />
    </OpenMap>
  );
};

export default App;

Core Components

<OpenMap>

The root provider component. It initializes the OpenLayers map, creates the MapContext, and manages global state like the active tool.

Layers

  • <VectorLayer />: Renders vector data. Supports fitBounds to auto-zoom to content.
  • <ImageLayer />: Renders WMS or static images.
  • <WebGLVectorLayer />: Optimized rendering for large datasets.
  • <Marker />: Places individual markers.
  • <MarkerCluster />: Clusters high-density markers.

UI Components

  • <Sidebar />: The main control center. Contains the Layer Panel with:
    • Visibility Toggles: Show/hide layers.
    • Style Editor: Change colors and stroke widths on the fly.
    • Info View: See projection, resolution, and feature counts.
  • <MapWidgets />: Adds standard GIS controls (Zoom, Scale, Mouse Position).
  • <MapPopup />: Shows feature attributes on click. Automatically disables itself when drawing/measuring tools are active.
  • <BottomToolbar />: Provides specific GIS tools (Draw Point/Line/Polygon, Measure Distance/Area).

Optimization Best Practices

  1. Stable Props: The library uses React.memo heavily. Ensure you memoize objects passed as props (like params for ImageLayer or coordinates for Marker) using useMemo to prevent map flickering or resets.

    // ✅ Good
    const params = useMemo(() => ({ layers: 'topp:states' }), []);
    <ImageLayer params={params} ... />
        
    // ❌ Bad (causes re-render on every update)
    <ImageLayer params={{ layers: 'topp:states' }} ... />
  2. Global Tool State: Tool state is managed globally via MapContext. You don't need to pass activeTool props down manually anymore—components like MapPopup simply read the context.

License

MIT