Map
Display your map.
Simple Demo
Plain HTML
You can find the live Demo on CodeSandbox here.
1<!DOCTYPE html>2<html lang="en">3<head>4<meta name="viewport" content="initial-scale=1.0" />5<meta charset="UTF-8" />6<title>Basic Map</title>7<link8href="https://maps-gl.nextbillion.io/maps/v2/api/css"9rel="stylesheet"10/>11<style>12* {13margin: 0;14padding: 0;15}16#map {17width: 100vw;18height: 100vh;19}20</style>21</head>22<body>23<div id="map"></div>24<script src="https://maps-gl.nextbillion.io/maps/v2/api/js"></script>25<script>26(function () {27// You need to replace the apiKey with yours28nextbillion.setApiKey("your-api-key");29var nbmap = new nextbillion.maps.Map({30container: document.getElementById("map"),31style: "https://api.nextbillion.io/maps/streets/style.json",32zoom: 11,33center: { lat: 34.08572, lng: -118.324569 }34});3536nbmap.on("load", function () {37// do something after map loaded38});39})();40</script>41</body>42</html>
React
You can find the live Demo on CodeSandbox here.
1import React, { useEffect } from 'react'2import '@nbai/nbmap-gl/dist/nextbillion.css'3import nextbillion, { NBMap } from '@nbai/nbmap-gl'45const SampleMapDemo = () => {6useEffect(() => {7// You need to replace the apiKey with yours8nextbillion.setApiKey('your-api-key')9const nbmap = new NBMap({10container: 'map',11style: 'https://api.nextbillion.io/maps/streets/style.json',12zoom: 11,13center: { lat: 34.08572, lng: -118.324569 }14})15})1617return (18<div className="app">19<div20style={{21width: '100%',22height: '100%',23position: 'fixed',24top: '0',25left: '0'26}}27id="map"></div>28</div>29)30}31export default SampleMapDemo