Skip to content

Instantly share code, notes, and snippets.

/application.js Secret

Created Dec 4, 2017
Embed
What would you like to do?
import Ember from 'ember';
import { A } from "@ember/array"
const { computed } = Ember;
export default Ember.Controller.extend({
mongoData: {},
randomVariable: 111,
locArray : [],
addressQuery: 'SF, Lafayette Park',
addressQueryInput: computed.reads('addressQuery'),
routeColor: 'red',
showingAllPolylineCoords: true,
customOptions: computed(function() {
if (google) {
return { mapTypeId: google.maps.MapTypeId.TERRAIN };
}
}),
actions: {
refresh() {
this.set('randomVariable', Math.floor(Math.random() * 1000));
}
pullMongoDBData() {
this.getCityCoords_(['Paris', 'Lille', 'Lyon', 'Bordeaux', 'Brest'], this);
}
},
getCityCoords_ : (cityName, this_) => {
console.log('input : ' + cityName)
cityName.forEach( (city) => {
Ember.$.get('https://maps.googleapis.com/maps/api/geocode/json?address=' + city + '&key=XXXXXX', (result) => {
let myLocation = result.results[0].geometry.location;
this_.locArray.push(myLocation);
});
});
console.log('this.locArray : ' + (this_.get('locArray')));
this.set('locArray', (this_get('locArray')));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment