Giter Club home page Giter Club logo

ngx-leaflet-fullscreen's Introduction

NGX-Leaflet-Fullscreen

This is a wrapper for the leaflet-fullscreen control to make it easy to use in Angular 8+.

This wrapper is tested against the @asymmetrik/ngx-leaflet library but it has no dependency on that library so should work without it. It does, obviously, have a dependency that leaflet is loaded.

For more detailed descriptions of how this wrapper was created : Documentation.

For detailed descriptions of how to use and worked examples : Article, Article

For an example of this working in a real site - see trackbash.

Install

Install using npm:

npm install @runette/ngx-leaflet-fullscreen

NOTE - after version 1.0.6 - this library is built using ng-packagr and an Ivy partial comppile. This should allow compatability with any version of Angular.io after >v12.0.0 (according to the Angular docs).

Note : this package currently installs a fork of leaflet-fullscreen : @runette/leaflet-fullscreen.

This is because the root repo has not been updated with several important PRs and has not been changed for 4 years.

Usage

This library needs to be imported into the application module:

/// <reference types='@runette/leaflet-fullscreen' />
import {NgxLeafletFullscreenModule} from '@runette/ngx-leaflet-fullscreen'

imports: [
    ...
    NgxLeafletFullscreenModule,
  ],

Then, the control is inserted using the following directive:

<leaflet-fullscreen-control
    [map]="..."
    [options]="..."
    ></leaflet-fullscreen-control>

Where map is an instance of a leaflet map and options is an object with valid options for the control.

Sometimes, Angular cannot find the correct typings. In this case, add the following directive as the first line of the .ts script:

/// <reference types='@runette/leaflet-fullscreen' />

Usage with NGX-Leaflet

This library integrates very easily with ngx-leaflet using the onMapReady event:

<div id='map' class="map-container" leaflet
     [leafletOptions]="options"
     (leafletMapReady)="onMapReady($event)"
     ></div>
<leaflet-fullscreen-control
    [map]="map"
    [options]="fullscreenOptions"
    ></leaflet-fullscreen-control>

by adding the following to your map component:

...
import { Map } from 'leaflet';


export class OsmMapComponent implements OnInit, OnDestroy {
  public map?: Map;
  public fullscreenOptions: FullscreenOptions = {
    position: 'topleft'
  };

  ...

  onMapReady(map: Map) {
    this.map = map;
  }

Usage - CSS

Unfortunately - I think because the leaflet map is run outside of Angular by ngx-leaflet - the normal css encapsulation does not work and you have to load the css globally.

Add the following to the styles.css

@import "@runette/leaflet-fullscreen/dist/leaflet.fullscreen.css";

Build Config

For some reason yet to be found - this library does not like being built with "buildOptimizer": true, in the build environment - which is usually the default for the production environment in angular.json.

Always build with "buildOptimizer": false,.

API Access to the Control

If you want access the control's methods directly from your typescript code - this can be done with @ViewChild

Use ViewChild to access the component, for instance

@ViewChild(FullscreenControlComponent,{static: false}) fullscreenComponent: FullscreenControlComponent;

The actual instance of the control can then be accessed directly as this.fullscreenComponent.control

For more details and worked examples, see : Article

Contributions

Contributions to this repository are very welcome.

Please fork the repository and create a new branch for your changes. The branch can be built locally using

ng build ngx-leaflet-fullscreen

in the root folder of the repo. This creates an npm package in a folder called dist. This can loaded in a test app using npm install and the FQ path to the dist folder.

When your changes are complete create a Pull Request against the master. It is IMPORTANT that you change the version number in package.json AND the tag number in .github/workflows/build.yaml to the next version before the PR.

When I have accepted and merged the PR, Github actions will automatically build the new package release and loaded it both as a GH release using the version as the tag name and publish the new version on npm.

ngx-leaflet-fullscreen's People

Contributors

hswong3i avatar runette avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

kpaterakis

ngx-leaflet-fullscreen's Issues

Module leaflet has no exported member FullscreenOptions

Hello. Im triying to install with "npm install --legacy-peer-deps @runette/ngx-leaflet-fullscreen" due to dependencies errors but i'm allways getting this error:

**Error: node_modules/@runette/ngx-leaflet-fullscreen/lib/ngx-leaflet-fullscreen.component.d.ts:2:24 - error TS2305: Module '"leaflet"' has no exported member 'FullscreenOptions'.

2 import { Map, Control, FullscreenOptions } from 'leaflet';
~~~~~~~~~~~~~~~~~

Error: node_modules/@runette/ngx-leaflet-fullscreen/lib/ngx-leaflet-fullscreen.component.d.ts:7:22 - error TS2694: Namespace '"........./node_modules/@types/leaflet/index".Control' has no exported member 'Fullscreen'.

7 control: Control.Fullscreen;**

I tried installing "npm install @runette/leaflet-fullscreen" and "npm install --save @types/leaflet.fullscreen" before ngx-leaflet-fullscreen bur error stills appearing.

Angular CLI: 13.1.2
Node: 12.21.0
Package Manager: npm 7.20.1

Thank you for your time.

Unexpected value NgxLeafletFullscreenModule. Please add a @NgModule annotation.

Hi All,

Faced the issue below please HELP ME!
image

I have do the following steps below:

  1. My node=v12.20.2 and angular cli= version image
  2. npm install @runette/ngx-leaflet-fullscreen and npm install @runette/leaflet-fullscreen
  3. My package json {
    "name": "",
    "version": "0.0.0",
    "scripts": {
    "ng": "ng",
    "start": "ng serve --live-reload false",
    "build": "ng build --prod",
    "deploy": "npm run build && npm run c8y-deploy",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
    "@agm/core": "^1.1.0",
    "@agm/drawing": "^3.0.0-beta.0",
    "@agm/js-marker-clusterer": "^1.1.0",
    "@angular/animations": "~8.2.0",
    "@angular/cdk": "^8.2.3",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/elements": "^14.0.3",
    "@angular/forms": "~8.2.0",
    "@angular/google-maps": "^11.0.0",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@angular/upgrade": "~2.4.0",
    "@asymmetrik/ngx-leaflet": "^6.0.1",
    "@c8y/client": "^1007.0.34",
    "@juggle/resize-observer": "^3.3.1",
    "@luxedo/heatmap": "^1.2.1",
    "@ngx-translate/core": "^12.1.2",
    "@ngx-translate/http-loader": "^4.0.0",
    "@runette/leaflet-fullscreen": "^1.0.6",
    "@runette/ngx-leaflet-fullscreen": "^1.0.6",
    "@runette/ngx-leaflet-loading": "^1.0.4",
    "@types/google-maps": "^3.2.2",
    "@types/leaflet": "^1.5.8",
    "agm-direction": "^0.8.9",
    "agm-overlays": "^2.0.0",
    "angular-dplayer": "^1.0.8",
    "angular-ng-autocomplete": "^2.0.5",
    "bootstrap": "^4.6.0",
    "chart.js": "^3.3.2",
    "core-js": "^3.10.1",
    "echarts": "^5.1.2",
    "eva-icons": "^1.1.3",
    "file-saver": "^2.0.5",
    "flv.js": "^1.6.2",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "heatmap.js": "^2.0.5",
    "intl-tel-input": "^17.0.13",
    "jquery": "^3.6.0",
    "js-marker-clusterer": "^1.0.0",
    "leaflet": "^1.6.0",
    "leaflet-geosearch": "^3.6.1",
    "leaflet-loading": "^0.1.24",
    "moment": "^2.29.1",
    "ng-circle-progress": "^1.6.0",
    "ng-multiselect-dropdown": "^0.3.4",
    "ng-table-virtual-scroll": "^1.3.8",
    "ng-zorro-antd": "^8.3.2",
    "ng2-search-filter": "^0.5.1",
    "ng2-tel-input": "^2.3.0",
    "ngx-chips": "^2.1.0",
    "ngx-echarts": "^5.2.2",
    "ngx-slimscroll": "^12.2.0",
    "ngx-spinner": "^8.1.0",
    "ngx-toastr": "^11.3.3",
    "resize-observer-polyfill": "^1.5.1",
    "rxjs": "~6.4.0",
    "saturn-datepicker": "^8.0.5",
    "tslib": "^1.10.0",
    "xlsx": "^0.18.5",
    "zone.js": "~0.9.1"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.8",
    "@angular/cli": "~8.2.0",
    "@angular/compiler-cli": "~8.2.0",
    "@angular/language-service": "~8.2.0",
    "@c8y/cli": "1006.6.4",
    "@types/googlemaps": "^3.43.3",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "autoprefixer": "^7.1.1",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "node-sass": "^4.14.1",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.5.3"
    }
    }

image

PLEASE LET ME KNOW WHERE AM I WRONG

Errors

I am using this library for one of the angular application, and getting the following errors:

image

How to localize control titles?

Hi,

it seams to me this should do the trick:

  public fullscreenOptions = {
    title: {
      'false': 'Vollbildansicht einschalten',
      'true':  'Vollbildansicht ausschalten',
    }
  };

  <leaflet-fullscreen-control
    [map]="map"
    [options]="fullscreenOptions"
  ></leaflet-fullscreen-control>

but no success, still 'View Fullscreen', what I'm doing wrong?

Incorrect Peer Dependency Warning

Hi,

While running the npm install or yarn receive the warning about wrong peer dependency.

warning " > @runette/[email protected]" has incorrect peer dependency "@angular/common@^8.2.14".
warning " > @runette/[email protected]" has incorrect peer dependency "@angular/core@^8.2.14".

I checked the package.json in this project and that have

"peerDependencies": {
    "@angular/common": "^8.2.14",
    "@angular/core": "^8.2.14"
  }

Should this updated to Angular 12 ? As I have verified that it works with that version ...

Leaflet.fullScreen makes other plugins fail

Hi @runette ,

Im working on Angular 11^ and when i load the application in my map.module.ts

import {NgxLeafletFullscreenModule} from '@runette/ngx-leaflet-fullscreen'

imports: [
    ...
    NgxLeafletFullscreenModule,
  ],

my other plugins stop working, in console just appear

L.realtime is not a function
L.easyprint is not a function

Im working with leaflet.realtime and leaflet.easyPrint and both of them stop working with just charge the module in the imports modules. When i delete the import of leaflet fullscreen, plugins works normally.

any thougths?

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.