<commit_before>/**
 * Created by alex on 6/6/16.
 */

import {
  Component, OnInit, Input, Output, EventEmitter, AfterViewInit
} from '@angular/core';
import { Observable } from 'rxjs/Observable';

const AGS_MAP = require('esri/Map');
const AGS_MAP_VIEW = require('esri/views/MapView');
const AGS_GRAPH_LAYER = require('esri/layers/GraphicsLayer');
const AGS_LOCATE_WID = require('esri/widgets/Locate');

const MAP_CLASS = 'bdfy-map';

@Component({
  selector: 'bdfy-map',
  providers: [],
  template: `<div id="{{ mapId }}" class="${MAP_CLASS}"></div>`
})
export class MapComponent<Pins> implements OnInit, AfterViewInit {
  static mapCount = 0;

  @Input() basemap = 'streets';
  @Input() maxZoom = 20;
  @Input() minZoom = 2;
  @Input() locatePosition = 'top-left';
  @Input() pins: Observable<Pins>;
  @Output() pinSelected = new EventEmitter<Pins>();
  @Output() positionChanged = new EventEmitter();

  mapId: string;
  map: __esri.Map;
  view: __esri.MapView;
  graphicsLayer: __esri.GraphicsLayer;
  locateBtn: __esri.Locate;

  constructor() {
    this.mapId = MAP_CLASS + (MapComponent.mapCount++).toString();
  }

  ngOnInit(): any {
  }

  ngAfterViewInit(): any {
    this.initMap();
    this.initView();
    this.initGraphicsLayer();
    this.initLocateBtn();
  }

  mapDidInit() {
    this.locateBtn.locate();
  }

  initMap() {
    this.map = new AGS_MAP({
      basemap: this.basemap
    });
  }

  initView() {
    this.view = new AGS_MAP_VIEW({
      container: this.mapId,
      map: this.map,
      constraints: {
        maxZoom: this.maxZoom,
        minZoom: this.minZoom,
        rotationEnabled: false
      }
    });

    this.view.then(() => this.mapDidInit());
  }

  initGraphicsLayer() {
    this.graphicsLayer = new AGS_GRAPH_LAYER();
    this.map.add(this.graphicsLayer);
  }

  initLocateBtn() {
    this.locateBtn = new AGS_LOCATE_WID({
      view: this.view,
      graphicsLayer: this.graphicsLayer
    });
    this.locateBtn.startup();
    this.view.ui.add(this.locateBtn, {
      position: this.locatePosition,
      index: 0
    });
  }
}<commit_msg>Add search box to map component<commit_after>/**
 * Created by alex on 6/6/16.
 */

import {
  Component, OnInit, Input, Output, EventEmitter, AfterViewInit
} from '@angular/core';
import { Observable } from 'rxjs/Observable';

const AGS_MAP = require('esri/Map');
const AGS_MAP_VIEW = require('esri/views/MapView');
const AGS_GRAPH_LAYER = require('esri/layers/GraphicsLayer');
const AGS_LOCATE_WID = require('esri/widgets/Locate');
const AGS_SEARCH_WID = require('esri/widgets/Search');

const MAP_CLASS = 'bdfy-map';

@Component({
  selector: 'bdfy-map',
  providers: [],
  template: `<div id="{{ mapId }}" class="${MAP_CLASS}"></div>`
})
export class MapComponent<Pins> implements OnInit, AfterViewInit {
  static mapCount = 0;

  @Input() basemap = 'streets';
  @Input() maxZoom = 20;
  @Input() minZoom = 2;
  @Input() locateEnabled = true;
  @Input() locatePosition = 'top-left';
  @Input() searchEnabled = true;
  @Input() searchPosition = 'top-left';
  @Input() pins: Observable<Pins>;
  @Output() pinSelected = new EventEmitter<Pins>();
  @Output() positionChanged = new EventEmitter();

  mapId: string;
  map: __esri.Map;
  view: __esri.MapView;
  graphicsLayer: __esri.GraphicsLayer;
  locateBtn: __esri.Locate;
  searchBox: __esri.Search;

  constructor() {
    this.mapId = MAP_CLASS + (MapComponent.mapCount++).toString();
  }

  ngOnInit(): any {
  }

  ngAfterViewInit(): any {
    this.initMap();
    this.initView();
    this.initGraphicsLayer();
    if (this.locateEnabled) this.initLocateBtn();
    if (this.searchEnabled) this.initSearchBox();
  }

  viewDidInit() {
    if (this.locateEnabled) this.locateBtn.locate();
  }

  initMap() {
    this.map = new AGS_MAP({
      basemap: this.basemap
    });
  }

  initView() {
    this.view = new AGS_MAP_VIEW({
      container: this.mapId,
      map: this.map,
      constraints: {
        maxZoom: this.maxZoom,
        minZoom: this.minZoom,
        rotationEnabled: false
      }
    });

    this.view.then(() => this.viewDidInit());
  }

  initGraphicsLayer() {
    this.graphicsLayer = new AGS_GRAPH_LAYER();
    this.map.add(this.graphicsLayer);
  }

  initLocateBtn() {
    this.locateBtn = new AGS_LOCATE_WID({
      view: this.view,
      graphicsLayer: this.graphicsLayer
    });
    this.locateBtn.startup();
    this.view.ui.add(this.locateBtn, {
      position: this.locatePosition,
      index: 1
    });
  }

  initSearchBox() {
    this.searchBox = new AGS_SEARCH_WID({
      view: this.view
    });
    this.view.ui.add(this.searchBox, {
      position: this.searchPosition,
      index: 0
    });
  }
}
{'fraction_non_alphanumeric': 0.15274513992736594, 'fraction_numerical': 0.004058961760307627, 'mean_word_length': 3.3513011152416357, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6512461', 'n_tokens_mistral': 1680, 'n_tokens_neox': 1643, 'n_words': 319}