mirror of
https://github.com/Ekokumppanit/Lentolaskuri.git
synced 2026-01-26 11:13:58 +00:00
42 lines
919 B
JavaScript
42 lines
919 B
JavaScript
'use strict';
|
|
|
|
define([
|
|
'backbone',
|
|
'libs/maps'
|
|
], function (Backbone, Maps) {
|
|
|
|
var MapView = Backbone.View.extend({
|
|
el: '#gmap',
|
|
initialize: function () {
|
|
this.collection.on('sort', this.render, this);
|
|
this.collection.on('remove', this.render, this);
|
|
this.collection.on('add', this.add, this);
|
|
|
|
this.map = new Maps.Map(this.el);
|
|
|
|
this.route = new Maps.Line({
|
|
geodesic: true,
|
|
map: this.map,
|
|
strokeColor: '#000'
|
|
});
|
|
|
|
this.bounds = new Maps.Bounds(this.map);
|
|
},
|
|
render: function () {
|
|
this.route.clear();
|
|
this.bounds.clear();
|
|
this.collection.forEach(this.route.add);
|
|
this.collection.forEach(this.bounds.add);
|
|
this.bounds.use();
|
|
},
|
|
add: function (model, collection, options) {
|
|
this.route.add(model);
|
|
this.bounds.add(model);
|
|
this.bounds.use();
|
|
}
|
|
});
|
|
|
|
return MapView;
|
|
|
|
});
|