Code Monkey home page Code Monkey logo

ngx-maplibre-gl's Introduction

ngx-maplibre-gl

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

npm version

Demo site

Can be found here (based on the generated gh-pages in this repo): https://maplibre.org/ngx-maplibre-gl/

Attribution

This is a fork of ngx-mapbox-gl and I would like to thank the maintainers there for thier amazing work to build this up. It's truely a great piece of sotware!

Components

How to start

npm install @maplibre/ngx-maplibre-gl maplibre-gl
yarn add @maplibre/ngx-maplibre-gl maplibre-gl

There might be a need to add the following configuration to tsconfig.json file

"compilerOptions": {
    ...
    "strictNullChecks": false,
    "skipLibCheck": true,
}

Load the CSS of maplibre-gl

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

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

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

@import '~maplibre-gl/dist/maplibre-gl.css';

Add this in your polyfill.ts file (Wykks/ngx-mapbox-gl#136 (comment)):

(window as any).global = window;

Then, in your app's main module (or in any other module), import the NgxMapLibreGLModule:

...
import { NgxMapLibreGLModule } from '@maplibre/ngx-maplibre-gl';

@NgModule({
  imports: [
    ...
    NgxMapLibreGLModule
  ]
})
export class AppModule {}

Display a map:

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

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

ngx-maplibre-gl's People

Contributors

aprilmay avatar babyrne avatar bergkamphun avatar bernhardrode avatar dependabot[bot] avatar dkocich avatar dmytro-gokun avatar freakybytes avatar github-actions[bot] avatar harelm avatar jdenbroeder avatar jfollas avatar mathieuzimmo avatar matkoniecz avatar mloffer avatar nimitagr avatar nosfit avatar paullryan avatar raysuelzer avatar shellydcms avatar sroettering avatar tamim-khan avatar tbo47 avatar tomladder avatar tzetter avatar ulflander avatar webberig avatar wheredoesyourmindgo avatar wipfli avatar wykks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.