/
route.js
63 lines (56 loc) · 1.71 KB
/
route.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* globals google: true */
import Ember from 'ember';
export default Ember.Route.extend({
setupController: function(controller) {
controller.setProperties({
lat: 32.75494243654723,
lng: -86.8359375,
zoom: 4,
markers: Ember.A([
{
id: 'jdlkfajs22df',
lat: 32.75494243654723,
lng: -86.8359375,
animation: google.maps.Animation.DROP,
infoWindow: { content: '<p>They\'re Remarkable!</p>', visible: true },
draggable: true,
dragstart: function() {
controller.set('isMarkerDragging', true);
},
dragend: function() {
controller.set('isMarkerDragging', false);
},
mouseup: function(e, marker) {
const lat = marker.position.lat();
const lng = marker.position.lng();
// Recenter map
controller.setProperties({
lat: lat,
lng: lng
});
},
drag: function(e) {
controller.set('markers.[].0.lat', e.latLng.lat());
controller.set('markers.[].0.lng', e.latLng.lng());
}
}
]),
isMarkerDragging: false,
isCustomIcon: false,
marker: Ember.computed.oneWay('markers.[].0')
});
},
actions: {
toggleCustomMarker: function() {
const marker = Ember.copy(this.controller.get('markers.[].0'));
if(this.controller.get('isCustomIcon') === false) {
marker.icon = 'beachflag.png';
} else {
delete marker.icon;
}
this.controller.set('isCustomIcon', !!(marker.icon));
this.controller.markers.removeAt(0);
this.controller.markers.pushObject(marker);
}
}
});