@@ -37,21 +37,6 @@ SDL.NavigationController = Em.Object.create(
3737 * Model binding
3838 */
3939 modelBinding : 'SDL.NavigationModel' ,
40- /**
41- * POI list switcher method
42- */
43- showPoiList : function ( ) {
44- if ( ! this . model . poi && this . model . LocationDetails . length == 0 ) {
45- SDL . PopUp . create ( ) . appendTo ( 'body' ) . popupActivate (
46- 'List is empty. Please navigate to some new places!'
47- ) ;
48- return ;
49- }
50- if ( this . model . poi == false && this . model . wp ) {
51- this . model . toggleProperty ( 'wp' ) ;
52- }
53- this . model . toggleProperty ( 'poi' ) ;
54- } ,
5540 /**
5641 * WP list switcher method
5742 */
@@ -62,9 +47,6 @@ SDL.NavigationController = Em.Object.create(
6247 ) ;
6348 return ;
6449 }
65- if ( this . model . wp == false && this . model . poi ) {
66- this . model . toggleProperty ( 'poi' ) ;
67- }
6850 this . model . toggleProperty ( 'wp' ) ;
6951 } ,
7052 /**
@@ -76,6 +58,8 @@ SDL.NavigationController = Em.Object.create(
7658 SDL . NavigationController . startAnimation ( ) ;
7759 }
7860
61+ SDL . NavigationController . clearRoutes ( ) ;
62+
7963 SDL . NavigationController . addPOIMarker (
8064 request . params . latitudeDegrees ,
8165 request . params . longitudeDegrees
@@ -193,10 +177,13 @@ SDL.NavigationController = Em.Object.create(
193177 SDL . NavigationController . startAnimation ( ) ;
194178 }
195179
180+ SDL . NavigationController . clearRoutes ( ) ;
181+
196182 SDL . NavigationController . addPOIMarker (
197183 request . params . latitudeDegrees ,
198184 request . params . longitudeDegrees
199185 ) ;
186+
200187 SDL . NavigationController . setRoutes ( ) ;
201188
202189 FFW . Navigation . sendNavigationResult (
@@ -217,8 +204,8 @@ SDL.NavigationController = Em.Object.create(
217204 var dt =
218205 SDL . NavigationController . convertDateTimeStructure ( request . params . timeStamp ) ;
219206
220- var locations = SDL . deepCopy ( SDL . NavigationModel . LocationDetails ) ;
221- var insertInd = SDL . NavigationController . getInsertLocationIndex ( locations , dt ) ;
207+ var waypoints = SDL . deepCopy ( SDL . NavigationModel . WayPointDetails )
208+ var insertInd = SDL . NavigationController . getInsertLocationIndex ( waypoints , dt ) ;
222209 var timeStampStuct = SDL . NavigationController . convertDateObject ( dt ) ;
223210 var location = {
224211 coordinate : {
@@ -235,11 +222,25 @@ SDL.NavigationController = Em.Object.create(
235222 } ;
236223
237224 if ( insertInd >= 0 ) {
238- locations . splice ( insertInd , 0 , location ) ;
225+ waypoints . splice ( insertInd , 0 , location ) ;
239226 } else {
240- locations . push ( location ) ;
227+ waypoints . push ( location ) ;
228+ }
229+ SDL . NavigationModel . set ( 'WayPointDetails' , waypoints ) ;
230+
231+ var latlng = new google . maps . LatLng (
232+ request . params . latitudeDegrees , request . params . longitudeDegrees
233+ ) ;
234+ var marker = new google . maps . Marker ( {
235+ position : latlng ,
236+ map : SDL . NavigationController . map
237+ } ) ;
238+ SDL . NavigationModel . WayPointMarkers . push ( marker ) ;
239+
240+ if ( SDL . NavigationController . isRouteSet ) {
241+ SDL . NavigationController . set ( 'isRouteSet' , false ) ;
242+ SDL . NavigationController . setRoutes ( ) ;
241243 }
242- SDL . NavigationModel . set ( 'LocationDetails' , locations ) ;
243244 }
244245
245246 FFW . Navigation . sendNavigationResult (
@@ -277,46 +278,6 @@ SDL.NavigationController = Em.Object.create(
277278 }
278279 return - 1 ;
279280 } ,
280- /**
281- * Navigation view List Button action handler
282- * Opens selected WayPoint structure
283- *
284- * @param {Object } element
285- */
286- openDestPoint : function ( element ) {
287- var itemID = element . itemID ;
288- this . model . set (
289- 'currentWayPointData' ,
290- JSON . stringify ( SDL . NavigationModel . LocationDetails [ itemID ] , null , 2 )
291- ) ;
292- SDL . NavigationView . codeEditor . activate (
293- function ( data , isDeleted ) {
294- if ( isDeleted ) {
295- var location = SDL . NavigationModel . LocationDetails [ itemID ] ;
296- SDL . NavigationModel . LocationDetails . removeObject ( location ) ;
297- if ( SDL . NavigationModel . LocationDetails . length == 0 ) {
298- SDL . NavigationModel . set ( 'poi' , false ) ;
299- }
300- } else {
301- var locations = SDL . deepCopy ( SDL . NavigationModel . LocationDetails ) ;
302- var old_coords = locations [ itemID ] . coordinate ;
303- var new_location = JSON . parse ( data ) ;
304- locations . splice ( itemID , 1 ) ;
305- var dt =
306- SDL . NavigationController . convertDateTimeStructure ( new_location . timeStamp ) ;
307- var insertInd =
308- SDL . NavigationController . getInsertLocationIndex ( locations , dt ) ;
309-
310- if ( insertInd >= 0 ) {
311- locations . splice ( insertInd , 0 , new_location ) ;
312- } else {
313- locations . push ( new_location ) ;
314- }
315- SDL . NavigationModel . set ( 'LocationDetails' , locations ) ;
316- }
317- }
318- ) ;
319- } ,
320281 /**
321282 * Navigation view List Button action handler
322283 * Selects current WayPoint
@@ -644,8 +605,8 @@ SDL.NavigationController = Em.Object.create(
644605 }
645606 } ,
646607 getLocationByCoord : function ( lat , lng ) {
647- for ( var i = 0 ; i < this . model . LocationDetails . length ; ++ i ) {
648- var point = this . model . LocationDetails [ i ] ;
608+ for ( var i = 0 ; i < this . model . WayPointDetails . length ; ++ i ) {
609+ var point = this . model . WayPointDetails [ i ] ;
649610 if ( point . coordinate . latitudeDegrees == lat &&
650611 point . coordinate . longitudeDegrees == lng ) {
651612 return {
@@ -702,94 +663,13 @@ SDL.NavigationController = Em.Object.create(
702663 ) ;
703664 data . push ( wp ) ;
704665 SDL . NavigationModel . set ( "WayPointDetails" , data ) ;
705-
706666 this . model . set ( "wp" , true ) ;
667+
668+ SDL . NavigationModel . selectedLocationMarker . setMap ( null ) ;
707669 if ( SDL . NavigationController . isRouteSet ) {
670+ SDL . NavigationController . set ( 'isRouteSet' , false ) ;
708671 SDL . NavigationController . setRoutes ( ) ;
709672 }
710- else {
711- SDL . NavigationModel . selectedLocationMarker . setMap ( null ) ;
712- FFW . Navigation . onWayPointChange ( SDL . NavigationModel . WayPointDetails ) ;
713- }
714- } ,
715- addWaypointLocation : function ( latlng ) {
716- var res = SDL . NavigationController . getLocationByCoord (
717- latlng . lat ( ) , latlng . lng ( )
718- ) ;
719-
720- if ( res . index >= 0 ) {
721- return ;
722- }
723-
724- var dt = new Date ( ) ;
725- var location = {
726- coordinate : {
727- latitudeDegrees : latlng . lat ( ) ,
728- longitudeDegrees : latlng . lng ( )
729- } ,
730- locationName : 'Unknown Location' ,
731- addressLines : [ ] ,
732- locationDescription : '' ,
733- phoneNumber : '' ,
734- locationImage : {
735- value : '' ,
736- imageType : 'DYNAMIC'
737- } ,
738- searchAddress : {
739- countryName : '' ,
740- countryCode : '' ,
741- postalCode : '' ,
742- administrativeArea : '' ,
743- subAdministrativeArea : '' ,
744- locality : '' ,
745- subLocality : '' ,
746- thoroughfare : '' ,
747- subThoroughfare : ''
748- } ,
749- timeStamp : SDL . NavigationController . convertDateObject ( dt )
750- } ;
751-
752- var locations = SDL . deepCopy ( SDL . NavigationModel . LocationDetails ) ;
753- var insertInd = SDL . NavigationController . getInsertLocationIndex ( locations , dt ) ;
754- if ( insertInd >= 0 ) {
755- locations . splice ( insertInd , 0 , location ) ;
756- } else {
757- locations . push ( location ) ;
758- }
759- SDL . NavigationModel . set ( 'LocationDetails' , locations ) ;
760-
761- geocoder = new google . maps . Geocoder ( ) ;
762- geocoder . geocode ( { 'location' : latlng } , function ( results , status ) {
763- if ( status === 'OK' ) {
764- var res = SDL . NavigationController . getLocationByCoord (
765- latlng . lat ( ) , latlng . lng ( )
766- ) ;
767- if ( res . index < 0 ) {
768- return ;
769- }
770- if ( results [ 0 ] ) {
771- res . location . addressLines = [ results [ 0 ] . formatted_address ] ;
772- }
773- if ( results [ 1 ] ) {
774- res . location . locationName = results [ 1 ] . formatted_address ;
775- }
776-
777- for ( i = 0 ; i < results . length ; ++ i ) {
778- var item = results [ i ] ;
779- for ( j = 0 ; j < item . address_components . length ; ++ j ) {
780- SDL . NavigationController . setLocationInfoFromItem (
781- item . address_components [ j ] , res . location
782- ) ;
783- }
784- }
785-
786- var locations = SDL . deepCopy ( SDL . NavigationModel . LocationDetails ) ;
787- locations [ res . index ] = res . location ;
788- SDL . NavigationModel . set ( 'LocationDetails' , locations ) ;
789- } else {
790- Em . Logger . error ( 'Navigation: Geocoder failed due to: ' + status ) ;
791- }
792- } ) ;
793673 } ,
794674 waypointSelected : function ( ) {
795675 var data = SDL . NavigationView . codeEditor . content ;
@@ -959,12 +839,12 @@ SDL.NavigationController = Em.Object.create(
959839 if ( SDL . NavigationController . isRouteSet == false &&
960840 SDL . NavigationModel . selectedLocationMarker . getMap ( ) == null ) {
961841 var markerCounts = SDL . NavigationModel . WayPointMarkers . length ;
962- if ( markerCounts == 0 ) {
842+ if ( markerCounts == 0 ) {
963843 SDL . PopUp . create ( ) . appendTo ( 'body' ) . popupActivate (
964844 'Error: Destination point is not set. Please select the destination point'
965845 ) ;
966846 return false ;
967- } else {
847+ } else {
968848 var marker = SDL . NavigationModel . WayPointMarkers . pop ( ) ;
969849 SDL . NavigationModel . selectedLocationMarker . setMap ( this . map ) ;
970850 SDL . NavigationModel . selectedLocationMarker . setPosition ( marker . getPosition ( ) ) ;
@@ -983,10 +863,6 @@ SDL.NavigationController = Em.Object.create(
983863 return ;
984864 }
985865
986- SDL . NavigationController . addWaypointLocation (
987- SDL . NavigationModel . selectedLocationMarker . getPosition ( )
988- ) ;
989-
990866 if ( SDL . NavigationController . polyline ) {
991867 SDL . NavigationController . polyline . setMap ( null ) ;
992868 }
@@ -1105,9 +981,6 @@ SDL.NavigationController = Em.Object.create(
1105981 SDL . NavigationController . clearRoutes ( ) ;
1106982 return ;
1107983 }
1108- if ( this . model . poi ) {
1109- this . model . toggleProperty ( 'poi' ) ;
1110- }
1111984 if ( this . model . wp ) {
1112985 this . model . toggleProperty ( 'wp' ) ;
1113986 }
0 commit comments