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

@gl-zcc/ol-image-map

v0.1.2

Published

OpenLayers image map component for flat floorplan annotations with Vue, React and vanilla adapters.

Readme

OL Image Map

基于 OpenLayers 的平面图片地图组件。适合在户型图、楼层图、园区图、工厂平面图等图片底图上做区域标注和位置标注。

在线 Demo

OL Image Map 示例界面

特性

  • 使用普通图片作为底图。
  • 内部统一使用 OpenLayers 坐标,原点在图片左下角。
  • 支持点位标注和区域标注。
  • 支持选择、绘制、编辑、删除。
  • 支持导入、导出 JSON。
  • 核心能力与框架无关。
  • 提供 Vue、React、原生 JavaScript 三种接入方式。

安装

npm install @gl-zcc/ol-image-map ol

Vue 项目需要安装 Vue,React 项目需要安装 React 和 ReactDOM。

样式文件:

import '@gl-zcc/ol-image-map/style.css';

核心用法

import { OlImageMapCore } from '@gl-zcc/ol-image-map';

const imageMap = new OlImageMapCore(document.querySelector('#map')!, {
  imageUrl: '/floor-plan.png',
  imageWidth: 451,
  imageHeight: 451,
  annotations: []
});

imageMap.setMode('draw-region');

imageMap.on('change', annotations => {
  // 在这里统一保存到后端或本地文件
  console.log(annotations);
});

Vue 用法

<script setup lang="ts">
import { ref } from 'vue';
import { OlImageMapVue } from '@gl-zcc/ol-image-map';
import '@gl-zcc/ol-image-map/style.css';

const annotations = ref([]);
const mode = ref('select');
</script>

<template>
  <OlImageMapVue
    image-url="/floor-plan.png"
    :image-width="451"
    :image-height="451"
    :annotations="annotations"
    :mode="mode"
    @change="annotations = $event"
  />
</template>

React 用法

import { useState } from 'react';
import { OlImageMapReact } from '@gl-zcc/ol-image-map';
import '@gl-zcc/ol-image-map/style.css';

export function Demo() {
  const [annotations, setAnnotations] = useState([]);

  return (
    <OlImageMapReact
      imageUrl="/floor-plan.png"
      imageWidth={451}
      imageHeight={451}
      annotations={annotations}
      mode="select"
      onChange={setAnnotations}
    />
  );
}

原生 JavaScript 用法

import { createOlImageMap } from '@gl-zcc/ol-image-map';
import '@gl-zcc/ol-image-map/style.css';

const imageMap = createOlImageMap('#map', {
  imageUrl: '/floor-plan.png',
  imageWidth: 451,
  imageHeight: 451,
  annotations: []
});

标注数据格式

type ImageMapAnnotation = ImageMapPointAnnotation | ImageMapRegionAnnotation;

interface ImageMapPointAnnotation {
  id: string;
  type: 'point';
  name: string;
  category?: string;
  status?: 'normal' | 'warning' | 'disabled';
  coordinate: [number, number];
}

interface ImageMapRegionAnnotation {
  id: string;
  type: 'region';
  name: string;
  category?: string;
  status?: 'normal' | 'warning' | 'disabled';
  coordinates: [number, number][];
}

保存方式

组件不会直接请求后端。业务系统可以监听 change 事件,或在保存按钮中调用 exportConfig(),再统一保存。

const payload = imageMap.exportConfig();
await fetch('/api/image-map', {
  method: 'POST',
  body: JSON.stringify(payload)
});