1.0.9 β€’ Published 8 months ago

@rezw4n/maplibre-google-streetview v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

MapLibre Google Street View

A MapLibre GL JS plugin that adds Google Street View functionality with a draggable pegman control, similar to Google Maps. chrome_TdOBF8ex2S

Features

  • πŸšΆβ€β™‚οΈ Draggable pegman control that shows Street View coverage
  • 🌐 Street View opens in an overlay with close button
  • πŸ”Ž Clicking on the pegman button toggles Street View coverage layer
  • πŸ“± Fully responsive design
  • πŸ› οΈ Customizable options

Installation

npm

npm install @rezw4n/maplibre-google-streetview

CDN

<link href="https://cdn.jsdelivr.net/npm/@rezw4n/maplibre-google-streetview@latest/dist/maplibre-google-streetview.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/@rezw4n/maplibre-google-streetview@latest/dist/maplibre-google-streetview.js"></script>

Requirements

  • MapLibre GL JS (v2.0.0 or higher)
  • A Google Maps API key with the following APIs enabled:
    • Street View Static API
    • Maps Embed API

Usage

Basic Usage

import MapLibreGL from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
import MaplibreGoogleStreetView from 'maplibre-google-streetview';
import 'maplibre-google-streetview/dist/maplibre-google-streetview.css';

// Initialize MapLibre map
const map = new MapLibreGL.Map({
  container: 'map',
  style: 'https://demotiles.maplibre.org/style.json', // or your own style
  center: [-74.0066, 40.7135], // New York City
  zoom: 15
});

// Add navigation control
map.addControl(new MapLibreGL.NavigationControl());

// Initialize Street View plugin
const streetViewPlugin = new MaplibreGoogleStreetView({
  map: map,
  apiKey: 'YOUR_GOOGLE_MAPS_API_KEY'
});

Options

OptionTypeDefaultDescription
mapObject(required)MapLibre GL JS map instance
apiKeyString(required)Google Maps API key
showPegmanButtonBooleantrueWhether to show the pegman button

Methods

remove()

Removes the Street View plugin from the map and cleans up all event listeners and DOM elements.

streetViewPlugin.remove();

How It Works

  1. Click the pegman button or start dragging it to show Street View coverage (blue lines).
  2. Drag the pegman to a location with Street View coverage.
  3. Drop the pegman to open Street View at that location.
  4. Click the X button to close Street View and return to the map.

Browser Support

This plugin works with all modern browsers that support MapLibre GL JS.

Local Development

  1. Clone the repository
  2. Install dependencies: npm install
  3. Start development server: npm run dev
  4. Build: npm run build

License

MIT

Credits

  • Street View coverage tiles are provided by Google Maps
  • Street View functionality uses Google Maps Embed API
1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago