File

geojson/geojson.ts

Extends

GeoJSONCoordinateHandler

Metadata

moduleId module.id.toString()
selector geojson-element
styleUrls geojson.css
templateUrl geojson.html

Constructor

constructor(mapService: MapService, groupService: GroupService, popupService: PopupService, guidService: GuidService, helperService: HelperService, LeafletElement: LeafletElement, LeafletGroup: LeafletGroup)

Methods

ngOnInit
ngOnInit()
Returns: void
ngDoCheck
ngDoCheck()
Returns: void

Properties

globalId
globalId: string
originalObject
originalObject: any
import { Component, Input, Injector, Optional } from '@angular/core';
import { LeafletElement } from '../map/map';
import { LeafletGroup } from '../group/group';
import { MapService } from '../services/map.service';
import { GroupService } from '../services/group.service';
import { PopupService } from '../services/popup.service';
import { GuidService } from '../services/globalId.service';
import { HelperService } from '../services/helper.service';
import { GeoJSONCoordinateHandler } from '../helpers/geoJsonReader';

import * as L from 'leaflet';

@Component({
  moduleId: module.id.toString(),
  selector: 'geojson-element',
  templateUrl: 'geojson.html',
  styleUrls: ['geojson.css']
})

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

  constructor(
    private mapService: MapService,
    private groupService: GroupService,
    private popupService: PopupService,
    private guidService: GuidService,
    private helperService: HelperService,
    @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();

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

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

        if (this.LeafletGroup) {
          this.groupService.addOLayersToGroup(gjson, map, this.mapService, this.LeafletGroup, false, this.globalId);
        } else {
          gjson.addTo(map);
        }
      } else {
        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");
    }

  }

  ngDoCheck() {
    let map = this.mapService.getMap();
  }
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""