import { Component, Input, Injectable, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { Feature } from 'ol';
import { Store } from '@ngrx/store';
import * as mapReducers from '../../reducers/map.reducer';
import { commonReducers, ItemTypeService, IItem, Item, ItemService, FolderService, IListItem} from '@farmmaps/common';
import * as mapActions from '../../actions/map.actions';
import { Router, ActivatedRoute, ParamMap, Event } from '@angular/router';
import { ForItemType } from '../for-item/for-itemtype.decorator';
import { AbstractSelectedItemComponent } from '../selected-item/selected-item.component';
import { Observable } from 'rxjs';


@ForItemType("vnd.farmmaps.itemtype.shape.processed")
@Injectable()
@Component({
  selector: 'fm-map-selected-item-shape',
  templateUrl: './selected-item-shape.component.html',
  styleUrls: ['./selected-item-shape.component.scss']
})
export class SelectedItemShapeComponent extends AbstractSelectedItemComponent {

  constructor(store: Store<mapReducers.State | commonReducers.State>, itemTypeService: ItemTypeService, location: Location, router: Router, private itemService$: ItemService,private folderService$: FolderService) {
    super(store, itemTypeService,location,router);
  }
  public selectedLayer: number = 0;
  
  onLayerChanged(layerIndex: number) {
    this.store.dispatch(new mapActions.SetLayerIndex(layerIndex));
  }
  
  layer(layers:any,layerIndex:number) {
    return layers.find(l => l.index == layerIndex);
  }
}
