Created
May 21, 2016 15:36
-
-
Save FrontlineOscar/cd1cee3fd11c0ebb85258a52389d3820 to your computer and use it in GitHub Desktop.
GeoApp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<title>Geoapp</title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
{{content-for "head"}} | |
<link rel="stylesheet" href="assets/vendor.css"> | |
<link rel="stylesheet" href="assets/geoapp.css"> | |
{{content-for "head-footer"}} | |
</head> | |
<body> | |
{{content-for "body"}} | |
<script src="assets/vendor.js"></script> | |
<script src="assets/geoapp.js"></script> | |
{{content-for "body-footer"}} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
var google = window.google; // jshint ignore:line | |
export default Ember.Route.extend({ | |
// this is what will provide the model to your .hbs file | |
model() { | |
var prepopulatedCounties = Ember.A(); | |
prepopulatedCounties.pushObject(Ember.Object.create({ value: "1", display: "Charlotte" })); | |
prepopulatedCounties.pushObject(Ember.Object.create({ value: "1", display: "Collier" })); | |
prepopulatedCounties.pushObject(Ember.Object.create({ value: "1", display: "Hillsborough" })); | |
prepopulatedCounties.pushObject(Ember.Object.create({ value: "1", display: "Lee" })); | |
return Ember.Object.create({ | |
counties : prepopulatedCounties, | |
selectedCounty : undefined, | |
address : undefined, | |
email : undefined, | |
latitude : undefined, | |
longitude : undefined, | |
}); | |
}, | |
actions: { | |
codeAddress() { | |
var geocoder = new google.maps.Geocoder(); | |
var address = this.get('currentModel.address'); | |
alert("Address entered:" + address); | |
geocoder.geocode( {'address': address}, function(results, status) { | |
if (status === google.maps.GeocoderStatus.OK) | |
{ | |
var latitude = results[0].geometry.location.lat(); | |
var longitude = results[0].geometry.location.lng(); | |
this.set('currentModel.latitude', latitude); | |
this.set('currentModel.longitude', longitude); | |
} | |
else | |
{ | |
alert("Geocode was not successful for the following reason: " + status); | |
} | |
}); | |
}, | |
setEmail() { | |
var dataValue = this.get('currentModel.selectedCounty'); | |
if(dataValue==="1"){ | |
this.set('currentModel.email', "first@email.com"); | |
} | |
else if(dataValue==="2"){ | |
this.set('currentModel.email', "second@email.com"); | |
} | |
else if (dataValue==="3"){ | |
this.set('currentModel.email', "third@email.com"); | |
} | |
else{ | |
this.set('currentModel.email', "None Selected"); | |
} | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.8.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.5.1", | |
"ember-data": "2.5.2", | |
"ember-template-compiler": "2.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment