Skip to content
Projets

Wykks/ngx-mapbox-gl

Voir sur GitHub

À propos

Liaison Angular pour mapbox-gl-js

Développement web et applicatif

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

ngx-mapbox-gl

npm version

Angular wrapper for mapbox-gl-js. It exposes a bunch of components meant to be simple to use with Angular.

v1.X : Angular 5 & 6 (rxjs 5)

v2.X : Angular 6 & 7 (rxjs 6)

v3.X : Angular 7.2

v4.X : Angular 8 - 10 (rxjs >= 6.5)

v5.X - 6.X : Angular 9 - 11 (rxjs >= 6.5)

v7.X : Angular 12 (rxjs >= 6.6)

v8.X : Angular 13

v9.X : Angular 14

v10.X : Angular 16 - 17

v11.X : Angular 18

v12.X : Angular 19, Mapbox-gl >= 3.5

v13.X : Angular 20, Mapbox-gl >= 3.5

v14.X : Angular 21 & 22, Mapbox-gl >= 3.5

Include the following components:

(Documentation here: https://wykks.github.io/ngx-mapbox-gl/doc)

How to start

npm install ngx-mapbox-gl mapbox-gl
yarn add ngx-mapbox-gl mapbox-gl

Load the CSS of mapbox-gl

For example, with angular-cli add this in angular.json:

"styles": [
        ...
        "mapbox-gl/dist/mapbox-gl.css"
      ],

Or in the global CSS file (called styles.css for example in angular-cli):

@import 'mapbox-gl/dist/mapbox-gl.css';

Then, you can configure the access token this way: NOTE: This is optional, you can also set the access tokenper map (accessToken input of mgl-map)

...
import { ApplicationConfig } from '@angular/core';
import { provideMapboxGL } from 'ngx-mapbox-gl';

export const appConfig: ApplicationConfig = {
    providers: [
      provideMapboxGL({
          accessToken: 'TOKEN'
      }),
      [...]
    ]
}

How to get a Mapbox token: https://www.mapbox.com/help/how-access-tokens-work/

Note: mapbox-gl cannot work without a token anymore. If you want to keep using their services then make a free account, generate a new token for your application and use it inside your project.

Display a map:

import { Component } from '@angular/core';

@Component({
  template: `<mgl-map [style]="'mapbox://styles/mapbox/streets-v12'" [zoom]="9" [center]="[-74.5, 40]" />`,
  styles: [
    `
      mgl-map {
        height: 100%;
        width: 100%;
      }
    `,
  ],
})
export class DisplayMapComponent {}

Explorer des projets similaires

Chargement…