@@ -18,6 +18,32 @@ import "../js/shared/strings";
1818
1919window . strings = new buildfire . services . Strings ( "en-us" , stringsConfig ) ;
2020
21+ const initGoogleMapsSDK = ( ) => {
22+ const { apiKeys } = buildfire . getContext ( ) ;
23+ const { googleMapKey } = apiKeys ;
24+ const script = document . createElement ( 'script' ) ;
25+ script . type = 'text/javascript' ;
26+ script . src = `https://maps.googleapis.com/maps/api/js?key=${
27+ googleMapKey
28+ } &sensor=false`;
29+ script . onload = ( ) => {
30+ console . info ( "Successfully loaded Google's Maps SDK." ) ;
31+ } ;
32+ script . onerror = ( ) => {
33+ buildfire . dialog . alert ( {
34+ title : 'Error' ,
35+ message : 'Failed to load Google Maps API.' ,
36+ } ) ;
37+ } ;
38+ window . gm_authFailure = ( ) => {
39+ buildfire . dialog . alert ( {
40+ title : 'Error' ,
41+ message : 'Failed to load Google Maps API.' ,
42+ } ) ;
43+ } ;
44+ document . head . appendChild ( script ) ;
45+ } ;
46+
2147window . app = {
2248 goBack : null ,
2349 settings : {
@@ -115,7 +141,7 @@ window.app = {
115141 window . app . loadPage ( 0 , 50 , ( err , places ) => {
116142 window . listView . setItems ( places ) ;
117143 window . app . state . places = places ;
118- } ) ;
144+ } ) ;
119145 } ,
120146 loadPage : ( page , pageSize , callback ) => {
121147 let places = [ ] ;
@@ -194,7 +220,7 @@ window.app = {
194220 latitude : window . app . state . location . lat ,
195221 longitude : window . app . state . location . lng ,
196222 } ;
197-
223+
198224 let destination = {
199225 latitude : address . lat ,
200226 longitude : address . lng
@@ -223,6 +249,7 @@ window.app = {
223249 } ,
224250 init : ( placesCallback , positionCallback ) => {
225251
252+ initGoogleMapsSDK ( ) ;
226253 let userLocation = JSON . parse ( localStorage . getItem ( "user_location" ) ) ;
227254 buildfire . datastore . get (
228255 window . app . settings . placesTag ,
0 commit comments