Skip to content

Commit b92e7ab

Browse files
BSolonenkoAKalinich-Luxoft
authored andcommitted
Following changes done :
1. Click anywhere on the map: (current behavior, no change) 1.1 If there is no active mark on the map, place a pin/marker on the map to show the current selected location. 1.2 If there is an active mark on the map, move the current marker to the new location. (Remove the current pin and place one on new location) 2. Button “Waypoints”: (changes) 2.1 If the waypoint list is not empty, it shall toggle the state of showing a list of waypoints and hide the list. 2.2 If the list is empty, shall show an error message or show an empty list or get disabled. 3. Button “Add WayPoint”: (changes) 3.1 If there is a selected location (active mark), add the location to the waypoints list and show the waypoint list so that the user knows it (also send onWayPointChange Notification if needed). 3.2 If there is no active mark on the map, show a message ask user to place a mark on the map first before click the button. 4. Button “Clear”: clear all marks on the map. (new button) 5. Button “Start Animation”/”Stop Animation”: start/stop animation. (current behavior, no change) 6. Button “Navigate”: 6.1 If there is a selected location, set it as the destination (new last waypoint). Calculate and show the route. 6.2 If there is no selected location, (changes) and 6.2.1 If the waypoint is not empty, set the last waypoint as destination, calculate and show the route. 6.2.2 If the waypoint is empty, show a message ask user to set a destination. 7. “Places” button. – not used. 8. Need to change the inscription "Please select a WayPoint" to "Please select a place on the map".
1 parent 20b40c6 commit b92e7ab

File tree

3 files changed

+59
-31
lines changed

3 files changed

+59
-31
lines changed

app/controller/NavigationController.js

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ SDL.NavigationController = Em.Object.create(
5858
showWpList: function() {
5959
if (!this.model.wp && this.model.WayPointDetails.length == 0) {
6060
SDL.PopUp.create().appendTo('body').popupActivate(
61-
'List is empty. Please setup navigation route!'
61+
'List is empty. Please add a new WayPoints!'
6262
);
6363
return;
6464
}
@@ -690,16 +690,27 @@ SDL.NavigationController = Em.Object.create(
690690
if (SDL.NavigationModel.selectedLocationMarker == null ||
691691
SDL.NavigationModel.selectedLocationMarker.getMap() == null) {
692692
SDL.PopUp.create().appendTo('body').popupActivate(
693-
'Error: Please, select WayPoint'
693+
'Error: Please, select a place on the map'
694694
);
695695
return;
696696
}
697-
var marker = new google.maps.Marker({
698-
position: SDL.NavigationModel.selectedLocationMarker.getPosition(),
699-
map: SDL.NavigationController.map
700-
});
701-
SDL.NavigationModel.WayPointMarkers.push(marker);
702-
SDL.NavigationModel.selectedLocationMarker.setMap(null);
697+
698+
var data = SDL.deepCopy(SDL.NavigationModel.WayPointDetails);
699+
var wp = SDL.NavigationController.addWayPointItem(
700+
SDL.NavigationModel.selectedLocationMarker.getPosition(),
701+
"WayPoint " + (data.length + 1), ''
702+
);
703+
data.push(wp);
704+
SDL.NavigationModel.set("WayPointDetails",data);
705+
706+
this.model.set("wp", true);
707+
if(SDL.NavigationController.isRouteSet){
708+
SDL.NavigationController.setRoutes();
709+
}
710+
else{
711+
SDL.NavigationModel.selectedLocationMarker.setMap(null);
712+
FFW.Navigation.onWayPointChange(SDL.NavigationModel.WayPointDetails);
713+
}
703714
},
704715
addWaypointLocation: function(latlng) {
705716
var res = SDL.NavigationController.getLocationByCoord(
@@ -938,23 +949,37 @@ SDL.NavigationController = Em.Object.create(
938949
SDL.NavigationModel.toggleProperty('wp');
939950
}
940951
},
941-
setRoutes: function() {
952+
checkRoutes: function(){
942953
if (SDL.NavigationModel.selectedLocationMarker == null) {
943954
SDL.PopUp.create().appendTo('body').popupActivate(
944-
'Navigation error: Destination point is not set'
955+
'Error: Destination point is not set'
945956
);
946-
return;
957+
return false;
947958
}
948959
if (SDL.NavigationController.isRouteSet == false &&
949960
SDL.NavigationModel.selectedLocationMarker.getMap() == null) {
950-
SDL.PopUp.create().appendTo('body').popupActivate(
951-
'Navigation error: Destination point is not selected'
952-
);
953-
return;
961+
var markerCounts = SDL.NavigationModel.WayPointMarkers.length;
962+
if(markerCounts == 0){
963+
SDL.PopUp.create().appendTo('body').popupActivate(
964+
'Error: Destination point is not set. Please select the destination point'
965+
);
966+
return false;
967+
}else{
968+
var marker = SDL.NavigationModel.WayPointMarkers.pop();
969+
SDL.NavigationModel.selectedLocationMarker.setMap(this.map);
970+
SDL.NavigationModel.selectedLocationMarker.setPosition(marker.getPosition());
971+
marker.setMap(null);
972+
}
954973
}
955974
if (SDL.NavigationController.isRouteSet &&
956975
SDL.NavigationModel.selectedLocationMarker.getMap() == null) {
957976
SDL.NavigationController.clearRoutes();
977+
return false;
978+
}
979+
return true;
980+
},
981+
setRoutes: function() {
982+
if(!SDL.NavigationController.checkRoutes() ){
958983
return;
959984
}
960985

app/view/navigationView.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ SDL.NavigationView = Em.ContainerView.create(
4242
'POIList',
4343
'WPList',
4444
'codeEditor',
45-
'POIButton',
45+
'clearButton',
4646
'WPButton',
4747
'AddWP',
4848
'map',
@@ -133,19 +133,22 @@ SDL.NavigationView = Em.ContainerView.create(
133133
)
134134
}
135135
),
136-
POIButton: SDL.Button.extend(
136+
clearButton: SDL.Button.extend(
137137
{
138-
classNameBindings: 'SDL.FuncSwitcher.rev::is-disabled',
139-
elementId: 'POIButton',
140-
disabledBinding: Em.Binding.oneWay(
141-
'SDL.NavigationController.isAnimateStarted'
142-
),
143-
classNames: 'POIButton button',
144-
text: 'Places',
145-
action: 'showPoiList',
146-
target: 'SDL.NavigationController'
147-
}
148-
),
138+
isButtonDisabled: function() {
139+
return SDL.NavigationModel.WayPointDetails.length == 0 ||
140+
SDL.NavigationController.isAnimateStarted;
141+
}.property('SDL.NavigationModel.WayPointDetails',
142+
'SDL.NavigationController.isAnimateStarted'),
143+
classNameBindings: 'SDL.FuncSwitcher.rev::is-disabled',
144+
elementId: 'clearButton',
145+
disabledBinding: 'isButtonDisabled',
146+
classNames: 'clearButton button',
147+
text: 'Clear',
148+
action: 'clearRoutes',
149+
target: 'SDL.NavigationController'
150+
}
151+
),
149152
WPButton: SDL.Button.extend(
150153
{
151154
isButtonDisabled: function() {
@@ -165,7 +168,7 @@ SDL.NavigationView = Em.ContainerView.create(
165168
AddWP: SDL.Button.extend(
166169
{
167170
classNameBindings: 'SDL.FuncSwitcher.rev::is-disabled',
168-
disabledBinding: 'SDL.NavigationController.isRouteSet',
171+
disabledBinding: 'SDL.NavigationController.isAnimateStarted',
169172
elementId: 'AddWP',
170173
classNames: 'AddWP button',
171174
text: 'Add waypoint',

css/navigation.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
position: absolute;
4949
}
5050

51-
.POIButton {
51+
.navigationButton {
5252
z-index: 1;
5353
top: 335px;
5454
left: 20px;
@@ -72,7 +72,7 @@
7272
text-align: center;
7373
}
7474

75-
.navigationButton {
75+
.clearButton {
7676
z-index: 1;
7777
bottom: 60px;
7878
left: 20px;

0 commit comments

Comments
 (0)