2.7.0 • Published 11 days ago

@nbai/nbmap-gl v2.7.0

Weekly downloads
-
License
MIT
Repository
-
Last release
11 days ago

NBMap GL

NBMap GL is a web map SDK for JavaScript that enables interactive maps with NextBillion's vector tiles service in your web apps, basing on Maplibre.

Development

Before start, please install Node.js and yarn to install dependencies.

yarn

You can start developing with this command:

yarn dev

You can build a minified version of the SDK with this command:

yarn build

Usage

Plain HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>NBMap GL Basic Example</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      #map {
        width: 100vw;
        height: 100vh;
      }
    </style>
    <link rel="stylesheet" type="text/css" href="https://maps-gl.nextbillion.io/maps/v2/api/css"></link>
    <script src="https://maps-gl.nextbillion.io/maps/v2/api/js"></script>
  </head>
  <body>
    <div id="map"></div>
    <script>
      nextbillion.setApiKey('Your API key')
      var nbmap = new nextbillion.maps.Map({
        container: document.getElementById('map'),
        style: 'https://api.nextbillion.io/maps/streets/style.json',
        zoom: 11,
        center: { lat: 34.08572, lng: -118.324569 },
      })

      nbmap.on('load', function () {
        const marker = new nextbillion.maps.Marker().setLngLat({ lat: 34.08572, lng: -118.324569 }).addTo(nbmap.map)
      })
    </script>
  </body>
</html>

Typescript

import '@nbai/nbmap-gl/dist/nextbillion.css';
import nextbillion, { Map, Marker } from '@nbai/nbmap-gl';

nextbillion.setApiKey('Your API key');
const nbmap = new Map({
  container: 'map',
  style: 'https://api.nextbillion.io/maps/streets/style.json',
  zoom: 11,
  center: { lat: 34.08572, lng: -118.324569 },
});
nbmap.on('load', () => {
  const marker: Marker = new Marker()
    .setLngLat({ lat: 34.08572, lng: -118.324569 })
    .addTo(nbmap.map);
})
2.7.0

11 days ago

2.6.0

2 months ago

2.5.1

2 months ago

2.5.0

1 year ago

2.4.1

1 year ago

2.4.0

1 year ago

2.3.2-alpha.1

1 year ago

2.3.2-alpha.0

1 year ago

2.3.2

1 year ago

2.3.4

1 year ago

2.3.3

1 year ago

2.3.5

1 year ago

2.3.1

1 year ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

2.0.0-pre.1.1

2 years ago

2.0.0-pre.2

2 years ago

2.0.0-pre.1

2 years ago