This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

mapmetrics-gl
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Mapmetrics Logo

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-gl
import mapmetricsgl from "mapmetrics-gl"; 
import "mapmetrics-gl/dist/mapmetrics-gl.css"; 

export function App() {
    const mapContainerRef = useRef(null);
    const mapInstanceRef = useRef(null); // ✅ Store the map instance const
    accessToken = ``; 
    useEffect(() => { 
        if (!mapContainerRef.current) return; 
        // ✅Create map instance and store it in ref 
        const map = (mapInstanceRef.current = new mapmetricsgl.Map({ 
            container: mapContainerRef.current, 
            style: `https://gateway.mapmetrics.org/styles/dark.json?token=${accessToken}`, 
            zoom: 11, 
            center: [2.349902, 48.852966], 
            minZoom: 1, 
            maxZoom: 15, 
        }));
        map.touchZoomRotate.enable({ around: "center" }); 
        map.touchPitch.enable({ around: "center" }); })
    }
    return (<div ref={mapContainerRef} style={{ width: '100%', height:"100vh" }} />)

Enjoy the map!


Documentation

Full documentation for this library is available here.

Check out the features through examples

Readme

Keywords

none

Package Sidebar

Install

npm i mapmetrics-gl

Weekly Downloads

0

Version

0.1.1

License

BSD-3-Clause

Unpacked Size

42.2 MB

Total Files

637

Last publish

Collaborators

  • mapmetrics-gl
  • hmudasar