New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

openlayers-serializer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openlayers-serializer

A utility library for **[OpenLayers](https://openlayers.org/)** that allows you to **serialize and deserialize map objects**. Easily transfer map state, layers, views, and features between frontend and backend, or save and restore map configurations.

latest
npmnpm
Version
0.1.14
Version published
Maintainers
1
Created
Source

openlayers-serializer

A utility library for OpenLayers that allows you to serialize and deserialize map objects. Easily transfer map state, layers, views, and features between frontend and backend, or save and restore map configurations.

✨ Features

  • 🔄 Serialization: Convert ol.Map, ol.View, ol.layer.*, ol.source.*, and ol.Feature into JSON
  • 📦 Deserialization: Rebuild OpenLayers objects from JSON
  • 🎯 Supports Map, View, Layers, Sources, and Features
  • 💾 Perfect for saving map configurations or data exchange

📦 Installation

npm install openlayers-serializer
# or
yarn add openlayers-serializer

🚀 Usage Example

import { serializeMap, deserializeMap } from "openlayers-serializer";
import Map from "ol/Map";
import View from "ol/View";
import TileLayer from "ol/layer/Tile";
import OSM from "ol/source/OSM";

// Create a map
const map = new Map({
  view: new View({
    center: [0, 0],
    zoom: 2,
  }),
  layers: [
    new TileLayer({
      source: new OSM(),
    }),
  ],
});

// Serialize map to JSON
const json = serializeMap(map);
console.log("Serialized:", json);

// Restore map from JSON
const restoredMap = deserializeMap(json);
console.log("Restored:", restoredMap);

📚 API Overview

serializeMap(map: Map): object

Convert an OpenLayers Map instance into JSON.

deserializeMap(json: object): Map

Rebuild an OpenLayers Map instance from JSON.

Supported Objects

CategorySupported Types
Mapol/Map
Viewol/View
Layersol/layer/Tile, ol/layer/Vector
Sourcesol/source/OSM, ol/source/Vector
Featuresol/Feature (with geometry)

(You can extend this table as support grows.)

🛠️ Development

Clone the repo and install dependencies:

git clone https://github.com/yourname/openlayers-serializer.git
cd openlayers-serializer
npm install

Run tests:

npm test

📚 License

MIT License © 2025 rgbcmy

This project uses OpenLayers which is licensed under the BSD 2-Clause License.

Support / Donate

Your support helps keep this project maintained and improved:

Donate via Stripe

FAQs

Package last updated on 13 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts