From 8a371354063cd0be084c432dd249502c4e42b9df Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 28 Jan 2020 22:05:38 +0000 Subject: [PATCH] Update README.md --- README.md | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e0214bf..02014dc 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,17 @@ This is a wrapper for the [leaflet.loading control](https://github.com/ebrelsfor This wrapper is tested against the [@asymmetrik/ngx-leaflet](https://github.com/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 an example of this working - see [trackbash](https://trackbash.co.uk). +For more detailed descriptions of how this wrapper was created : [Documentation](https://runette.gitbook.io/alcm/). + +For detailed descriptions of how to use and worked examples : [Article](https://medium.com/runic-software/quick-guide-to-leaflet-controls-in-angular-io-1b35d0807bdb), [Article](https://medium.com/runic-software/advanced-interactive-maps-in-angular-with-leaflet-68baafa03f72) + +For an example of this working in a real site - see [trackbash](https://trackbash.co.uk). # Install Install using npm: ``` -npm install leaflet-loading npm install @runette/ngx-leaflet-loading ``` @@ -77,13 +80,10 @@ export class OsmMapComponent implements OnInit, OnDestroy { 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 angular.json +Add the following to the styles.css -``` -"styles": [ - ... - "./node_modules/leaflet-loading/src/Control.Loading.css", - ], +```CSS +@import "leaflet-loading/src/Control.Loading.css"; ``` # Build Config @@ -91,3 +91,17 @@ Add the following to the angular.json 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 + +```ts +@ViewChild(NgxLoadingControlComponent,{static: false}) loadingComponent: NgxLoadingControlComponent; +``` + +The actual instance of the control can then be accessed directly as `this.loadingComponent.loading` + +For more details and worked examples, see : [Article](https://medium.com/runic-software/advanced-interactive-maps-in-angular-with-leaflet-68baafa03f72)