Skip to content

Commit

Permalink
making lib angular 6 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticrash committed Jun 15, 2018
1 parent 95ff4a8 commit 246d1ad
Show file tree
Hide file tree
Showing 11 changed files with 2,599 additions and 2,361 deletions.
4,625 changes: 2,440 additions & 2,185 deletions package-lock.json

Large diffs are not rendered by default.

47 changes: 23 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx.leaflet.components",
"version": "1.4.2",
"version": "2.0.0",
"description": "an angular.io component collection for leaflet",
"main": "./bundles/src/ngx.leaflet.components.umd.js",
"jsnext:main": "./esm5/src/ngx.leaflet.components.js",
Expand Down Expand Up @@ -42,30 +42,29 @@
"url": "https://github.com/elasticrash/ngx.leaflet.component/issues"
},
"peerDependencies": {
"tslib": "^1.7.1",
"@angular/core": ">=4.0.0",
"@angular/http": ">=4.0.0",
"@angular/common": ">=4.0.0",
"rxjs": ">=5.0.0",
"tslib": "1.9.2",
"@angular/core": ">=6.0.0",
"@angular/http": ">=6.0.0",
"@angular/common": ">=6.0.0",
"rxjs": ">=6.0.0",
"leaflet": ">=1.0.0",
"typescript": ">=2.4.2"
"typescript": ">=2.7.2"
},
"homepage": "https://github.com/elasticrash/ngx.leaflet.component#readme",
"devDependencies": {
"@angular/common": "5.0.2",
"@angular/compiler": "5.0.2",
"@angular/compiler-cli": "5.0.2",
"@angular/core": "5.0.2",
"@angular/http": "5.0.2",
"@angular/platform-browser": "5.0.2",
"@angular/platform-browser-dynamic": "5.0.2",
"@compodoc/compodoc": "^1.0.0-beta.1",
"@types/geojson": "^1.0.2",
"@types/jasmine": "^2.5.53",
"@types/leaflet": "^1.2.0",
"@types/node": "^8.0.28",
"@angular/common": "6.0.5",
"@angular/compiler": "6.0.5",
"@angular/compiler-cli": "6.0.5",
"@angular/core": "6.0.5",
"@angular/http": "6.0.5",
"@angular/platform-browser": "6.0.5",
"@angular/platform-browser-dynamic": "6.0.5",
"@compodoc/compodoc": "1.1.3",
"@types/geojson": "7946.0.3",
"@types/jasmine": "2.8.8",
"@types/leaflet": "1.2.7",
"angular2-template-loader": "https://github.com/elasticrash/angular2-template-loader.git",
"awesome-typescript-loader": "^3.2.3",
"awesome-typescript-loader": "5.0.0",
"chalk": "2.3.0",
"codelyzer": "4.0.0",
"core-js": "^2.5.0",
Expand Down Expand Up @@ -101,17 +100,17 @@
"rollup-plugin-license": "0.5.0",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-sourcemaps": "0.4.2",
"rxjs": "5.5.2",
"rxjs": "6.2.1",
"shelljs": "0.7.8",
"source-map-loader": "0.2.3",
"source-map-support": "^0.4.15",
"ts-loader": "3.1.1",
"ts-node": "1.2.1",
"tslint": "^5.8.0",
"tslint": "^5.10.0",
"typedoc": "^0.8.0",
"typescript": "2.4.2",
"typescript": "2.7.2",
"uglify-js": "3.1.6",
"webpack": "^3.8.1",
"zone.js": "^0.8.18"
"zone.js": "^0.8.26"
}
}
51 changes: 26 additions & 25 deletions src/circle/circle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, Optional, ElementRef, ViewChild } from '@angular/core';
import { Component, Input, Optional, ElementRef, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import { LeafletElement } from '../map/map';
import { LeafletGroup } from '../group/group';
import { MapService } from '../services/map.service';
Expand All @@ -9,64 +9,65 @@ import { path } from '../models/path';
import { Ipath } from '../interfaces/path';
import * as L from 'leaflet';


@Component({
selector: 'circle-element',
template: `<div #ngel><ng-content></ng-content></div>`,
styles: ['']
})

export class CircleElement extends CoordinateHandler {
@Input() lat: number = 52.6;
@Input() lon: number = -1.1;
@Input() radius: number = 20;
@Input() mouseover: string | undefined = undefined;
@Input() onclick: string | undefined = undefined;
@Input() Options: any = new path(null);
@ViewChild('ngel') ngEl: ElementRef;
export class CircleElement extends CoordinateHandler implements OnInit, AfterViewInit {
@Input() public lat: number = 52.6;
@Input() public lon: number = -1.1;
@Input() public radius: number = 20;
@Input() public mouseover: string | undefined = undefined;
@Input() public onclick: string | undefined = undefined;
@Input() public Options: any = new path(null);
@ViewChild('ngel') public ngEl: ElementRef;

public circle: any = null;

constructor(
private mapService: MapService,
private popupService: PopupService,
@Optional() private groupService?: GroupService,
@Optional() private LeafletElement?: LeafletElement,
@Optional() private LeafletGroup?: LeafletGroup) {
@Optional() private groupService?: GroupService,
@Optional() private leafletElement?: LeafletElement,
@Optional() private leafletGroup?: LeafletGroup) {
super();
}

ngOnInit() {
public ngOnInit() {
super.assignCartesianPointToLeafletsLatLngSchema();

//check if any of the two optional injections exist
// check if any of the two optional injections exist
if (this.LeafletElement || this.LeafletGroup) {
let inheritedOptions: any = new path(this.Options);
let map = this.mapService.getMap();
const inheritedOptions: any = new path(this.Options);
const map = this.mapService.getMap();

super.transformPointCoordinates(this.LeafletElement.crs);
super.transformPointCoordinates(this.leafletElement.crs);

this.circle = L.circle([this.lat, this.lon], this.radius, inheritedOptions);

if (this.LeafletGroup) {
this.groupService.addOLayersToGroup(this.circle, map, this.mapService, this.LeafletGroup);
this.groupService.addOLayersToGroup(this.circle, map, this.mapService, this.leafletGroup);
} else {
this.circle.addTo(map);
}
} else {
console.warn("This circle-element will not be rendered \n the expected parent node of circle-element should be either leaf-element or leaflet-group");
// tslint:disable-next-line:no-console
console.warn(`This circle-element will not be rendered
the expected parent node of circle-element should be either leaf-element or leaflet-group`);
}
}

ngAfterViewInit() {
public ngAfterViewInit() {
if (this.LeafletElement || this.LeafletGroup) {
var textInput = undefined;
let textInput;
if (this.ngEl.nativeElement.childNodes.length > 0) {
var textNode = this.ngEl.nativeElement.childNodes[0];
const textNode = this.ngEl.nativeElement.childNodes[0];
textInput = textNode.nodeValue;
}

//add popup methods on element only if any of the tests are not undefined
// add popup methods on element only if any of the tests are not undefined
if (this.mouseover !== undefined || this.onclick !== undefined || textInput !== undefined) {
this.popupService.enablePopup(this.mouseover, this.onclick, this.circle, textInput);
}
Expand Down
51 changes: 26 additions & 25 deletions src/circlemarker/circlemarker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, Optional, ElementRef, ViewChild } from '@angular/core';
import { Component, Input, Optional, ElementRef, ViewChild, AfterViewInit, OnInit } from '@angular/core';
import { LeafletElement } from '../map/map';
import { LeafletGroup } from '../group/group';
import { MapService } from '../services/map.service';
Expand All @@ -9,60 +9,61 @@ import { path } from '../models/path';
import { Ipath } from '../interfaces/path';
import * as L from 'leaflet';


@Component({
selector: 'circle-marker-element',
template: `<div #ngel><ng-content></ng-content></div>`,
styles: ['']
})

export class CircleMarkerElement extends CoordinateHandler {
@Input() lat: number = 52.6;
@Input() lon: number = -1.1;
@Input() mouseover: string | undefined = undefined;
@Input() onclick: string | undefined = undefined;
@Input() Options: any = new path(null);
@ViewChild('ngel') ngEl: ElementRef;
export class CircleMarkerElement extends CoordinateHandler implements OnInit, AfterViewInit {
@Input() public lat: number = 52.6;
@Input() public lon: number = -1.1;
@Input() public mouseover: string | undefined = undefined;
@Input() public onclick: string | undefined = undefined;
@Input() public Options: any = new path(null);
@ViewChild('ngel') public ngEl: ElementRef;
public circle: any = null;

constructor(
private mapService: MapService,
private popupService: PopupService,
@Optional() private groupService?: GroupService,
@Optional() private LeafletElement?: LeafletElement,
@Optional() private LeafletGroup?: LeafletGroup) {
@Optional() private groupService?: GroupService,
@Optional() private leafletElement?: LeafletElement,
@Optional() private leafletGroup?: LeafletGroup) {
super();
}

ngOnInit() {
public ngOnInit() {
super.assignCartesianPointToLeafletsLatLngSchema();
//check if any of the two optional injections exist
if (this.LeafletElement || this.LeafletGroup) {
let inheritedOptions: any = new path(this.Options);
let map = this.mapService.getMap();
// check if any of the two optional injections exist
if (this.leafletElement || this.leafletGroup) {
const inheritedOptions: any = new path(this.Options);
const map = this.mapService.getMap();

let elementPosition: any = super.transformPointCoordinates(this.LeafletElement.crs);
const elementPosition: any = super.transformPointCoordinates(this.leafletElement.crs);

this.circle = L.circleMarker([this.lat, this.lon], inheritedOptions);

if (this.LeafletGroup) {
this.groupService.addOLayersToGroup(this.circle, map, this.mapService, this.LeafletGroup);
if (this.leafletGroup) {
this.groupService.addOLayersToGroup(this.circle, map, this.mapService, this.leafletGroup);
} else {
this.circle.addTo(map);
}
} else {
console.warn("This circle-element will not be rendered \n the expected parent node of circle-element should be either leaf-element or leaflet-group");
// tslint:disable-next-line:no-console
console.warn(`This circle-element will not be rendered
the expected parent node of circle-element should be either leaf-element or leaflet-group`);
}
}

ngAfterViewInit() {
var textInput = undefined;
public ngAfterViewInit() {
let textInput;
if (this.ngEl.nativeElement.childNodes.length > 0) {
var textNode = this.ngEl.nativeElement.childNodes[0];
const textNode = this.ngEl.nativeElement.childNodes[0];
textInput = textNode.nodeValue;
}

//add popup methods on element only if any of the tests are not undefined
// add popup methods on element only if any of the tests are not undefined
if (this.mouseover !== undefined || this.onclick !== undefined || textInput !== undefined) {
this.popupService.enablePopup(this.mouseover, this.onclick, this.circle, textInput);
}
Expand Down
37 changes: 20 additions & 17 deletions src/geojson/geojson.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, Optional } from '@angular/core';
import { Component, OnInit, DoCheck, Optional } from '@angular/core';
import { LeafletElement } from '../map/map';
import { LeafletGroup } from '../group/group';
import { MapService } from '../services/map.service';
Expand All @@ -16,7 +16,7 @@ import * as L from 'leaflet';
styles: ['']
})

export class GeoJsonElement extends GeoJSONCoordinateHandler {
export class GeoJsonElement extends GeoJSONCoordinateHandler implements OnInit, DoCheck {
public originalObject: any = Object.assign({}, this.geojson);
public globalId: string = this.guidService.newGuid();

Expand All @@ -25,38 +25,41 @@ export class GeoJsonElement extends GeoJSONCoordinateHandler {
private popupService: PopupService,
private guidService: GuidService,
private helperService: HelperService,
@Optional() private groupService?: GroupService,
@Optional() private LeafletElement?: LeafletElement,
@Optional() private LeafletGroup?: LeafletGroup) {
@Optional() private groupService?: GroupService,
@Optional() private leafletElement?: LeafletElement,
@Optional() private leafletGroup?: LeafletGroup) {
super();
}

ngOnInit() {
//check if any of the two optional injections exist
if (this.LeafletElement || this.LeafletGroup) {
//polyline shouldn't have a fill
let map = this.mapService.getMap();
public ngOnInit() {
// check if any of the two optional injections exist
if (this.leafletElement || this.leafletGroup) {
// polyline shouldn't have a fill
const map = this.mapService.getMap();

if (this.geojson) {
super.transformJSONCoordinates(this.geojson, this.LeafletElement.crs);
super.transformJSONCoordinates(this.geojson, this.leafletElement.crs);

let gjson = L.geoJSON(this.geojson);
const gjson = L.geoJSON(this.geojson);

if (this.LeafletGroup) {
this.groupService.addOLayersToGroup(gjson, map, this.mapService, this.LeafletGroup, false, this.globalId);
if (this.leafletGroup) {
this.groupService.addOLayersToGroup(gjson, map, this.mapService, this.leafletGroup, false, this.globalId);
} else {
gjson.addTo(map);
}
} else {
// tslint:disable-next-line:no-console
console.warn("geojson object seems to be undefined");
}
} else {
console.warn("This polyline-element will not be rendered \n the expected parent node of polyline-element should be either leaf-element or leaflet-group");
// tslint:disable-next-line:no-console
console.warn(`This polyline-element will not be rendered
the expected parent node of polyline-element should be either leaf-element or leaflet-group`);
}

}

ngDoCheck() {
let map = this.mapService.getMap();
public ngDoCheck() {
const map = this.mapService.getMap();
}
}
2 changes: 1 addition & 1 deletion src/geojson/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './geojson';
export * from './geojson';
14 changes: 2 additions & 12 deletions src/group/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,21 @@ import { Component, Input } from '@angular/core';
import { MapService } from '../services/map.service';
import { GroupService } from '../services/group.service';
import { GuidService } from '../services/globalId.service';
import * as L from 'leaflet';


@Component({
selector: 'leaflet-group',
template: ``,
styles: [''],
providers: [GroupService]
providers: [GroupService]
})

export class LeafletGroup {
@Input() name: string = '';
@Input() public name: string = '';
public globalId: string = this.guidService.newGuid();

constructor(
private mapService: MapService,
private groupService: GroupService,
private guidService: GuidService) {
}

ngOnInit() {
}

ngAfterViewInit() {
}


}
Loading

0 comments on commit 246d1ad

Please sign in to comment.