[missions] add button to fit the mission onto the map and to open the mission creator

This commit is contained in:
fkloft 2015-04-13 22:38:52 +02:00
parent 2933f596e9
commit 212b980683

View File

@ -146,6 +146,11 @@ window.plugin.missions = {
}, },
collapseCallback: this.collapseFix, collapseCallback: this.collapseFix,
expandCallback: this.collapseFix expandCallback: this.collapseFix
}).dialog('option', 'buttons', {
'Zoom to mission': function() {
me.zoomToMission(mission);
},
'OK': function() { $(this).dialog('close'); },
}); });
}, },
@ -155,7 +160,10 @@ window.plugin.missions = {
height: 'auto', height: 'auto',
width: '400px', width: '400px',
collapseCallback: this.collapseFix, collapseCallback: this.collapseFix,
expandCallback: this.collapseFix expandCallback: this.collapseFix,
}).dialog('option', 'buttons', {
'Create new mission': function() { open('//mission-author-dot-betaspike.appspot.com'); },
'OK': function() { $(this).dialog('close'); },
}); });
}, },
@ -165,6 +173,16 @@ window.plugin.missions = {
} }
}, },
zoomToMission: function(mission) {
var latlngs = mission.waypoints.filter(function(waypoint) {
return !!waypoint.portal;
}).map(function(waypoint) {
return [waypoint.portal.latE6/1E6, waypoint.portal.lngE6/1E6];
});
map.fitBounds(L.latLngBounds(latlngs), {maxZoom: 17});
},
loadMissionsInBounds: function(bounds, callback, errorcallback) { loadMissionsInBounds: function(bounds, callback, errorcallback) {
var me = this; var me = this;
window.postAjax('getTopMissionsInBounds', { window.postAjax('getTopMissionsInBounds', {