GithubHelp home page GithubHelp logo

fazpu / leaflet-ng2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yagajs/leaflet-ng2

0.0 1.0 0.0 803 KB

Angular 2++ integration of Leaflet

Home Page: https://leaflet-ng2.yagajs.org

License: ISC License

HTML 0.55% JavaScript 0.15% TypeScript 99.30%

leaflet-ng2's Introduction

YAGA - leaflet-ng2

Build Status Coverage Status

YAGA leaflet-ng2 is a granular implementation of the popular Leaflet framework into the model view view controller (MVVC) of Angular2 and it is fully compatible with the newest version of Angular 4. It provides a directive for every Leaflet class that belongs to the user interface by inheriting the original Leaflet class and enhancing it with the decorators of Angular and glue-code. With this approach the directives are still extensible and it is possible to write the structure of an app in a descriptive way in a well known markup language, HTML5. This is why you mainly need HTML skills for creating a template based geo-app with leaflet-ng2.

It is easy to enhance this library with one’s own Angular modules, because of its modular structure. It is even possible to use the already existing Leaflet plugins on top, because the implementation also detects changes that were made in Leaflet and bind them to Angular’s data model.

The YAGA Development-Team gives a great importance to tests, test-coverage, documentation, examples and getting started templates.

Note: This is just a release candidate!

How to use

First you have to install this library from npm:

npm install --save @yaga/leaflet-ng2

This module works like a normal Angular 2 module. You should do something like that:

import { YagaModule, OSM_TILE_LAYER_URL }   from '@yaga/leaflet-ng2';
import { Component, NgModule, PlatformRef } from '@angular/core';
import { BrowserModule }                    from '@angular/platform-browser';
import { platformBrowserDynamic }           from '@angular/platform-browser-dynamic';

const platform: PlatformRef = platformBrowserDynamic();

@Component({
    selector: 'app',
    template: `<yaga-map><yaga-tile-layer [(url)]="tileLayerUrl"></yaga-tile-layer></yaga-map>`
})
export class AppComponent {
    // Your logic here, like:
    public tileLayerUrl: string = OSM_TILE_LAYER_URL;
}

@NgModule({
    bootstrap:    [ AppComponent ],
    declarations: [ AppComponent ],
    imports:      [ BrowserModule, YagaModule ]
})
export class AppModule { }

document.addEventListener('DOMContentLoaded', () => {
    platform.bootstrapModule(AppModule);
});

Do not forget to import the leaflet css!

After that you should be able to use the following directives or components:

  • yaga-map This must be the root component!
  • yaga-attribution-control
  • yaga-circle
  • yaga-circle-marker
  • yaga-div-icon
  • yaga-geojson
  • yaga-icon
  • yaga-image-overlay
  • yaga-marker
  • yaga-polygon
  • yaga-polyline
  • yaga-popup
  • yaga-rectangle
  • yaga-scale-control
  • yaga-tile-layer
  • yaga-tooltip
  • yaga-zoom-control

Structure of the leaflet-ng2 directives

For further information look at the api documentation or the examples.

Use in combination with a CLI

For developing we recommend to use a command-line-interface like angular-cli for web-applications or ionic for smartdevice-like apps.

You can also check out our ionic-starter templates on our GitHub account

Start a project with Angular CLI

You have to perform the followings steps to start a project with the angular-cli:

# Install the angular-cli to your system
npm install -g angular-cli
# Create a app with the angular-cli
ng new my-yaga-app
# Switch into the created project directory
cd my-yaga-app
# Install @yaga/leaflet-ng2 as project dependency
npm install --save @yaga/leaflet-ng2

Import the YAGA module into your app in app.module.ts:

// other imports...
import { YagaModule } from '@yaga/leaflet-ng2';

// ...

@NgModule({
  imports: [
    // other...
    YagaModule,
  ],
  // some other properties...
)
export class AppModule { }

Start a project with Ionic CLI

You have to perform the followings steps to start a project with the ionic-cli:

# Install the ionic-cli to your system
npm install -g ionic
# Create a app with the ionic-cli (select a template unteractive)
ionic start my-yaga-app
# Switch into the created project directory
cd my-yaga-app
# Install @yaga/leaflet-ng2 as project dependency
npm install --save @yaga/leaflet-ng2

Import the YAGA module into your app in app.module.ts:

// other imports...
import { YagaModule } from '@yaga/leaflet-ng2';

// ...

@NgModule({
  imports: [
    // other...
    YagaModule,
  ],
  // some other properties...
)
export class AppModule { }

Scripts Tasks

Scripts registered in package.json:

  • init: Install all stuff needed for development (Typings, libs etc.)
  • clean: Remove the stuff from init-task
  • reinit: Call clean and init
  • transpile: Transpile TypeScript Code to JavaScript
  • lint: Use the linter for TypeScript Code
  • test: Run software- and coverage-tests in node.
  • browser-test: Build the tests for the browser.
  • build-examples: Build the examples.
  • doc: Build the API documentation.

License

This library is released under the ISC License.

Links

leaflet-ng2's People

Contributors

atd-schubert avatar landru29 avatar marcjansen avatar openstevemap 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.