<commit_before>/* global Microsoft */
import Ember from 'ember';
import config from '../config/environment';

export default Ember.Component.extend({
  classNames: ['bing-map'],
  lat: 0,
  lng: 0,
  zoom: 10,
  mapTypeId: 'r', // r:road, a:aerial
  markers: null,

  polygonLocation: null,

  init() {
    this._super();
    if(!config.bingAPI) {
      throw('Missing BING API KEY');
    }
    this.api = Microsoft.Maps;
    this.map = null;
  },

  didInsertElement() {
    this.createMap();
  },

  willDestroyElement() {
    this.removeMap();
  },

  center: Ember.computed('lat', 'lng', function() {
    let latitude = this.get('lat');
    let longitude = this.get('lng');
    let location = new Microsoft.Maps.Location(latitude, longitude);
    return location;
  }),

  mapOptions: Ember.computed('center', 'zoom', 'mapTypeId', function() {
    let opts = this.getProperties('center', 'zoom', 'mapTypeId');
    opts.credentials = config.bingAPI;
    return opts;
  }),

  createMap: function() {
    let el = this.$()[0];
    let opts = this.get('mapOptions');

    let getMarker = this.get('getMarker');
    let polygon = this.createPolygon;
    this.map = new Microsoft.Maps.Map(el, opts);

    if(getMarker){
      getMarker.forEach((location) => {
        let marker = new Microsoft.Maps.Pushpin(location);
        this.map.entities.push(marker); //add marker to map
      }); 
    }

    if(polygon){
      this.map.entities.push(polygon);
    }

  },

  removeMap: function() {<commit_msg>get createPolygon correctly<commit_after>/* global Microsoft */
import Ember from 'ember';
import config from '../config/environment';

export default Ember.Component.extend({
  classNames: ['bing-map'],
  lat: 0,
  lng: 0,
  zoom: 10,
  mapTypeId: 'r', // r:road, a:aerial
  markers: null,

  polygonLocation: null,

  init() {
    this._super();
    if(!config.bingAPI) {
      throw('Missing BING API KEY');
    }
    this.api = Microsoft.Maps;
    this.map = null;
  },

  didInsertElement() {
    this.createMap();
  },

  willDestroyElement() {
    this.removeMap();
  },

  center: Ember.computed('lat', 'lng', function() {
    let latitude = this.get('lat');
    let longitude = this.get('lng');
    let location = new Microsoft.Maps.Location(latitude, longitude);
    return location;
  }),

  mapOptions: Ember.computed('center', 'zoom', 'mapTypeId', function() {
    let opts = this.getProperties('center', 'zoom', 'mapTypeId');
    opts.credentials = config.bingAPI;
    return opts;
  }),

  createMap: function() {
    let el = this.$()[0];
    let opts = this.get('mapOptions');

    let getMarker = this.get('getMarker');
    let polygon = this.get('createPolygon');
    this.map = new Microsoft.Maps.Map(el, opts);

    if(getMarker){
      getMarker.forEach((location) => {
        let marker = new Microsoft.Maps.Pushpin(location);
        this.map.entities.push(marker); //add marker to map
      }); 
    }

    if(polygon){
      this.map.entities.push(polygon);
    }

  },

  removeMap: function() {
{'fraction_non_alphanumeric': 0.16396694214876034, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 3.029294274300932, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4980031', 'n_tokens_mistral': 1023, 'n_tokens_neox': 984, 'n_words': 220}