File

services/group.service.ts

Constructor

constructor(guidService: GuidService)

Methods

Public addOLayersToGroup
addOLayersToGroup(overlay: any, map: any, mapService: any, group: any, replace: boolean, gId: String)
Returns: void
Public getObservableGroup
getObservableGroup()
Returns: void
Public getGroup
getGroup()
Returns: void
Public getLayerGroup
getLayerGroup()
Returns: void
Public getLayerNumber
getLayerNumber()
Returns: void

Properties

Private group
group: any
Private layerGroup
layerGroup: any[]
Private layerGroupNumber
layerGroupNumber: number
Default value: 0
Private layerId
layerId: any[]
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Rx';
import { GuidService } from '../services/globalId.service';
import * as L from 'leaflet';


@Injectable()
export class GroupService {
    private layerGroup: Array<any> = [];
    private layerId: Array<any> = [];
    private layerGroupNumber: number = 0;
    private group: any = {};

    constructor(private guidService: GuidService) { }

    public addOLayersToGroup(overlay, map, mapService, group, replace = false, gId?: String) {
        if (!gId) {
            gId = this.guidService.newGuid();
        }
        if (this.layerId.indexOf(gId) === -1) {
            this.layerId.push(gId);
        }
        if (Object.keys(this.group).length !== 0) {
            if (replace) {
                map.removeLayer(this.group);
                if (this.layerId.indexOf(gId) !== -1) {
                    this.layerGroup[this.layerId.indexOf(gId)] = overlay;
                } else {
                    this.layerGroup.push(overlay);
                }
                this.group = L.layerGroup(this.getLayerGroup());
                this.group.addTo(map);
            } else {
                this.layerGroup.push(overlay);
                this.group.addLayer(overlay);
            }
        }
        if (!replace) {
            this.layerGroup.push(overlay);
            this.group = L.layerGroup(this.getLayerGroup());
            this.group.addTo(map);
        }

        mapService.addOverlay(this.getGroup(), group.name, group.globalId);
    }

    public getObservableGroup() {
        return Observable.create(observer => {
            var group = this.getGroup();
            observer.next(group);
            observer.complete();
        });
    }

    public getGroup() {
        return this.group;
    }

    public getLayerGroup() {
        return this.layerGroup;
    }

    public getLayerNumber() {
        return this.layerGroupNumber;
    }
}

results matching ""

    No results matching ""