Skip to content

Commit 244adf5

Browse files
Martin Broersebroerse
authored andcommitted
Make examples 3.4 compatible
1 parent e27d047 commit 244adf5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ It corresponds to _PositionOptions object in HMTL5 Geolocation API_. Learn more
9393
#### Setup geolocation service
9494
In order to use geolocation inside of your _Ember.Route_ you should directly inject it to the one:
9595
```js
96-
export default Ember.Route.extend({
97-
geolocation: Ember.inject.service()
96+
import Route from '@ember/routing/route';
97+
import { inject as service } from '@ember/service';
98+
99+
export default Route.extend({
100+
geolocation: service()
98101
});
99102
```
100103
@@ -103,12 +106,13 @@ You need to implement a custom action which will call the geolocation service.
103106
In your route:
104107
```js
105108
// app/routes/geolocator.js
109+
import Route from '@ember/routing/route';
106110

107-
export default Ember.Route.extend({
111+
export default Route.extend({
108112

109113
actions: {
110114
getUserLocation: function() {
111-
this.get('geolocation').getLocation().then(function(geoObject) {
115+
this.get('geolocation').getLocation().then((geoObject) => {
112116
var currentLocation = this.get('geolocation').get('currentLocation');
113117
this.controllerFor('geolocator').set('userLocation', currentLocation);
114118
});
@@ -120,8 +124,9 @@ export default Ember.Route.extend({
120124
In your controller:
121125
```js
122126
// app/controllers/geolocator.js
127+
import Controller from '@ember/controller';
123128

124-
export default Ember.Controller.extend({
129+
export default Controller.extend({
125130
userLocation: null
126131
});
127132
```
@@ -130,7 +135,7 @@ In your template:
130135
```js
131136
// app/templates/geolocator.hbs
132137

133-
<button type="button" {{action 'getUserLocation'}}>Geolocate me!</button>
138+
<button type="button" {{action "getUserLocation"}}>Geolocate me!</button>
134139
{{#if userLocation}}
135140
{{userLocation}}
136141
{{/if}}

0 commit comments

Comments
 (0)