1- import * as types from " ../constants/action_types" ;
2- import utils from " ../utils" ;
1+ import * as types from ' ../constants/action_types' ;
2+ import utils from ' ../utils' ;
33const request = new XMLHttpRequest ( ) ;
44
55function originPoint ( coordinates ) {
66 return dispatch => {
77 const origin = utils . createPoint ( coordinates , {
8- id : " origin" ,
9- " marker-symbol" : "A"
8+ id : ' origin' ,
9+ ' marker-symbol' : 'A'
1010 } ) ;
1111
1212 dispatch ( { type : types . ORIGIN , origin } ) ;
13- dispatch ( eventEmit ( " origin" , { feature : origin } ) ) ;
13+ dispatch ( eventEmit ( ' origin' , { feature : origin } ) ) ;
1414 } ;
1515}
1616
1717function destinationPoint ( coordinates ) {
1818 return dispatch => {
1919 const destination = utils . createPoint ( coordinates , {
20- id : " destination" ,
21- " marker-symbol" : "B"
20+ id : ' destination' ,
21+ ' marker-symbol' : 'B'
2222 } ) ;
2323
2424 dispatch ( { type : types . DESTINATION , destination } ) ;
25- dispatch ( eventEmit ( " destination" , { feature : destination } ) ) ;
25+ dispatch ( eventEmit ( ' destination' , { feature : destination } ) ) ;
2626 } ;
2727}
2828
@@ -32,7 +32,7 @@ function setDirections(directions) {
3232 type : types . DIRECTIONS ,
3333 directions
3434 } ) ;
35- dispatch ( eventEmit ( " route" , { route : directions } ) ) ;
35+ dispatch ( eventEmit ( ' route' , { route : directions } ) ) ;
3636 } ;
3737}
3838
@@ -69,20 +69,20 @@ function fetchDirections() {
6969
7070 // Request params
7171 var options = [ ] ;
72- options . push ( " geometries=polyline" ) ;
73- if ( alternatives ) options . push ( " alternatives=true" ) ;
74- if ( congestion ) options . push ( " annotations=congestion" ) ;
75- options . push ( " steps=true" ) ;
76- if ( overview !== " simplified" || overview !== " full" ) {
77- options . push ( " overview=simplified" ) ;
72+ options . push ( ' geometries=polyline' ) ;
73+ if ( alternatives ) options . push ( ' alternatives=true' ) ;
74+ if ( congestion ) options . push ( ' annotations=congestion' ) ;
75+ options . push ( ' steps=true' ) ;
76+ if ( overview !== ' simplified' || overview !== ' full' ) {
77+ options . push ( ' overview=simplified' ) ;
7878 } else {
7979 options . push ( `overview=${ overview } ` ) ;
8080 }
81- if ( accessToken ) options . push ( " access_token=" + accessToken ) ;
81+ if ( accessToken ) options . push ( ' access_token=' + accessToken ) ;
8282 request . abort ( ) ;
8383 request . open (
84- " GET" ,
85- `${ api } ${ profile } /${ query } .json?${ options . join ( "&" ) } ` ,
84+ ' GET' ,
85+ `${ api } ${ profile } /${ query } .json?${ options . join ( '&' ) } ` ,
8686 true
8787 ) ;
8888
@@ -127,23 +127,23 @@ function buildDirectionsQuery(state) {
127127 const { origin, destination, waypoints } = state ( ) ;
128128
129129 let query = [ ] ;
130- query . push ( origin . geometry . coordinates . join ( "," ) ) ;
131- query . push ( ";" ) ;
130+ query . push ( origin . geometry . coordinates . join ( ',' ) ) ;
131+ query . push ( ';' ) ;
132132
133133 // Add any waypoints.
134134 if ( waypoints . length ) {
135135 waypoints . forEach ( waypoint => {
136- query . push ( waypoint . geometry . coordinates . join ( "," ) ) ;
137- query . push ( ";" ) ;
136+ query . push ( waypoint . geometry . coordinates . join ( ',' ) ) ;
137+ query . push ( ';' ) ;
138138 } ) ;
139139 }
140140
141- query . push ( destination . geometry . coordinates . join ( "," ) ) ;
142- return encodeURIComponent ( query . join ( "" ) ) ;
141+ query . push ( destination . geometry . coordinates . join ( ',' ) ) ;
142+ return encodeURIComponent ( query . join ( '' ) ) ;
143143}
144144
145145function normalizeWaypoint ( waypoint ) {
146- const properties = { id : " waypoint" } ;
146+ const properties = { id : ' waypoint' } ;
147147 return Object . assign ( waypoint , {
148148 properties : waypoint . properties
149149 ? Object . assign ( waypoint . properties , properties )
@@ -154,10 +154,10 @@ function normalizeWaypoint(waypoint) {
154154function setError ( error ) {
155155 return dispatch => {
156156 dispatch ( {
157- type : " ERROR" ,
157+ type : ' ERROR' ,
158158 error
159159 } ) ;
160- if ( error ) dispatch ( eventEmit ( " error" , { error : error } ) ) ;
160+ if ( error ) dispatch ( eventEmit ( ' error' , { error : error } ) ) ;
161161 } ;
162162}
163163
@@ -194,7 +194,7 @@ export function clearOrigin() {
194194 dispatch ( {
195195 type : types . ORIGIN_CLEAR
196196 } ) ;
197- dispatch ( eventEmit ( " clear" , { type : " origin" } ) ) ;
197+ dispatch ( eventEmit ( ' clear' , { type : ' origin' } ) ) ;
198198 dispatch ( setError ( null ) ) ;
199199 } ;
200200}
@@ -204,7 +204,7 @@ export function clearDestination() {
204204 dispatch ( {
205205 type : types . DESTINATION_CLEAR
206206 } ) ;
207- dispatch ( eventEmit ( " clear" , { type : " destination" } ) ) ;
207+ dispatch ( eventEmit ( ' clear' , { type : ' destination' } ) ) ;
208208 dispatch ( setError ( null ) ) ;
209209 } ;
210210}
@@ -219,7 +219,7 @@ export function setOptions(options) {
219219export function hoverMarker ( coordinates ) {
220220 return dispatch => {
221221 const feature = coordinates
222- ? utils . createPoint ( coordinates , { id : " hover" } )
222+ ? utils . createPoint ( coordinates , { id : ' hover' } )
223223 : { } ;
224224 dispatch ( setHoverMarker ( feature ) ) ;
225225 } ;
@@ -252,7 +252,7 @@ export function setProfile(profile) {
252252 return ( dispatch , getState ) => {
253253 const { origin, destination } = getState ( ) ;
254254 dispatch ( { type : types . DIRECTIONS_PROFILE , profile } ) ;
255- dispatch ( eventEmit ( " profile" , { profile } ) ) ;
255+ dispatch ( eventEmit ( ' profile' , { profile } ) ) ;
256256 if ( origin . geometry && destination . geometry ) dispatch ( fetchDirections ( ) ) ;
257257 } ;
258258}
@@ -279,7 +279,7 @@ export function setOriginFromCoordinates(coords) {
279279 if ( ! utils . validCoords ( coords ) )
280280 coords = [ utils . wrap ( coords [ 0 ] ) , utils . wrap ( coords [ 1 ] ) ] ;
281281 if ( isNaN ( coords [ 0 ] ) && isNaN ( coords [ 1 ] ) )
282- return dispatch ( setError ( new Error ( " Coordinates are not valid" ) ) ) ;
282+ return dispatch ( setError ( new Error ( ' Coordinates are not valid' ) ) ) ;
283283 dispatch ( queryOriginCoordinates ( coords ) ) ;
284284 dispatch ( createOrigin ( coords ) ) ;
285285 } ;
@@ -295,7 +295,7 @@ export function setDestinationFromCoordinates(coords) {
295295 if ( ! utils . validCoords ( coords ) )
296296 coords = [ utils . wrap ( coords [ 0 ] ) , utils . wrap ( coords [ 1 ] ) ] ;
297297 if ( isNaN ( coords [ 0 ] ) && isNaN ( coords [ 1 ] ) )
298- return dispatch ( setError ( new Error ( " Coordinates are not valid" ) ) ) ;
298+ return dispatch ( setError ( new Error ( ' Coordinates are not valid' ) ) ) ;
299299 dispatch ( createDestination ( coords ) ) ;
300300 dispatch ( queryDestinationCoordinates ( coords ) ) ;
301301 } ;
0 commit comments