0.4.8 • Published 5 months ago

@mapmetrics/mapmetrics-gl v0.4.8

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
5 months ago

Mapmetrics GL JS

The Maps API allows you to retrieve vector tiles generated by the MapMetrics. You can use some libraries like Leaflet or MapMetrics GL for JavaScript, Android or iOS to add a map to your website.

Getting Started

Using CDN

Include the JavaScript and CSS files in the <head> of your HTML file.

<link
    href="https://gateway.mapmetrics.org/assets/css/mapmetrics-gl.css"
    rel="stylesheet"
/>
<script src="https://gateway.mapmetrics.org/assets/js/mapmetrics-gl.js"></script>

Include the following code in the <body> of your HTML file.

<div id="map" style="width: 400px; height: 300px;"></div>
<script>
    var map = new mapmetricsgl.Map({
        container: "map",
        style: `https://gateway.mapmetrics.org/styles/dark.json?token=${accessToken}`, // stylesheet location
        center: [-74.5, 40], // starting position [lng, lat]
        zoom: 9, // starting zoom
    });
</script>

Using NPM Library

Install npm library

npm i @mapmetrics/mapmetrics-gl
import React, { useEffect, useRef } from "react";
import mapmetricsgl from "@mapmetrics/mapmetrics-gl";
import "@mapmetrics/mapmetrics-gl/dist/mapmetrics-gl.css";

const App = () => {
  const mapContainerRef = useRef<HTMLDivElement>(null);
  const mapRef = useRef<mapmetricsgl.Map | null>(null);

  const accessToken = ``;
  useEffect(() => {
    if (!mapContainerRef.current || mapRef.current) return;

    const map = new mapmetricsgl.Map({
      container: mapContainerRef.current,
      style: `https://gateway.mapmetrics.org/styles/dark.json?token=${accessToken}`,
      center: [2.349902, 48.852966],
      zoom: 11,
      minZoom: 1,
      maxZoom: 24,
      attributionControl: false,
      cooperativeGestures: true,
    });

    mapRef.current = map;

    return () => {
      map.remove();
      mapRef.current = null;
    };
  }, []);

  return (
    <div
      id="map"
      ref={mapContainerRef}
      style={{ height: "100vh", width: "100%" }}
    ></div>
  );
};

export default App;

Enjoy the map!

Documentation

Full documentation for this library is available here.

Check out the features through examples

0.4.8

5 months ago

0.4.6

5 months ago

0.4.5

5 months ago

0.4.4

5 months ago

0.4.3

5 months ago

0.4.2

5 months ago

0.4.1

5 months ago

0.4.0

5 months ago

0.3.9

5 months ago

0.3.8

5 months ago

0.3.7

5 months ago

0.3.6

5 months ago

0.3.5

5 months ago

0.3.4

5 months ago

0.3.3

5 months ago

0.3.2

5 months ago

0.3.1

5 months ago

0.3.0

5 months ago

0.2.12

5 months ago

0.2.11

6 months ago

0.2.10

6 months ago

0.2.9

6 months ago

0.2.8

6 months ago

0.2.7

6 months ago

0.2.6

6 months ago

0.2.5

6 months ago

0.2.4

6 months ago

0.2.3

6 months ago

0.2.2

6 months ago

0.2.1

6 months ago

0.2.0

6 months ago

0.1.9

6 months ago

0.1.8

6 months ago

0.1.7

6 months ago

0.1.6

6 months ago

0.1.5

7 months ago

0.1.4

7 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago