Google maps not showing on Ionic when the plugin is used










0















I want to display maps in my application but Google map isn't showing up. I have made my application on Ionic and I have used the Cordova Google Maps plugin. Here is the link to my code. Please help me.










share|improve this question




























    0















    I want to display maps in my application but Google map isn't showing up. I have made my application on Ionic and I have used the Cordova Google Maps plugin. Here is the link to my code. Please help me.










    share|improve this question


























      0












      0








      0








      I want to display maps in my application but Google map isn't showing up. I have made my application on Ionic and I have used the Cordova Google Maps plugin. Here is the link to my code. Please help me.










      share|improve this question
















      I want to display maps in my application but Google map isn't showing up. I have made my application on Ionic and I have used the Cordova Google Maps plugin. Here is the link to my code. Please help me.







      google-maps ionic-framework






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '17 at 11:04









      Dev4World

      2,25231532




      2,25231532










      asked Nov 13 '17 at 10:59









      ShreyaShreya

      239413




      239413






















          4 Answers
          4






          active

          oldest

          votes


















          1














          Try to add this in config.xml plugins list:



          <plugin name="cordova-plugin-googlemaps" spec="~2.0.6">
          <variable name="API_KEY_FOR_ANDROID" value="Your_key" />
          </plugin>





          share|improve this answer























          • This has already been added.

            – Shreya
            Nov 13 '17 at 11:32











          • I had not seen it in your repo so..

            – Husain
            Nov 13 '17 at 11:35






          • 1





            also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

            – Husain
            Nov 13 '17 at 11:36












          • Thank u so much. Adding iframe made it work. Thanks a million times.

            – Shreya
            Nov 13 '17 at 11:40











          • Hey it worked yesterday but today it stopped working again

            – Shreya
            Nov 14 '17 at 5:35


















          0














          Have you registered in Google Maps and added API KEY do your app?






          share|improve this answer























          • Yes I have done that

            – Shreya
            Nov 13 '17 at 11:03











          • any error in console? Does the directive added anything to page?

            – FrontMonkey
            Nov 13 '17 at 11:05











          • When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

            – Shreya
            Nov 13 '17 at 11:07












          • Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

            – FrontMonkey
            Nov 13 '17 at 11:11












          • I deployed it on my phone as well and still I get a blank screen.

            – Shreya
            Nov 13 '17 at 11:15


















          0














          Here is the code that worked :



          import Component from '@angular/core';


          import NavController from 'ionic-angular';
          import GoogleMap, GoogleMaps, LatLng, CameraPosition, GoogleMapsEvent from '@ionic-native/google-maps';

          @Component(
          selector: 'page-home',
          templateUrl: 'home.html'
          )
          export class HomePage

          constructor(public navCtrl: NavController, public googleMaps: GoogleMaps)



          ngAfterViewInit()
          this.loadMap();


          loadMap()
          let element = document.getElementById('map');
          let map: GoogleMap = this.googleMaps.create(element, );
          let latlng = new LatLng(40.7128, -74.0059);


          map.one(GoogleMapsEvent.MAP_READY).then(() =>
          let position: CameraPosition =
          target: latlng,
          zoom: 10,
          tilt: 30

          map.moveCamera(position);
          )





          And in your HTML file



          <div #map id="map" style="height:100%;"></div>


          This is the tutorial : http://tphangout.com/ionic-2-google-maps/






          share|improve this answer






























            0














            1.open project directory and run this in cmd



             ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="api key" -variable API_KEY_FOR_IOS="api key here"


            2.add this in specific map page



            declare var google;


            3.In the same class



             ionViewDidLoad() 
            if (this.global.checkNetwork() == true)
            this.initializeMap();

            else
            this.showAlert("Internet is not available");



            initializeMap()

            let locationOptions = timeout: 20000, enableHighAccuracy: true ;

            navigator.geolocation.getCurrentPosition(

            (position) =>

            let options =
            center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
            zoom: 16,
            mapTypeId: google.maps.MapTypeId.ROADMAP


            this.map = new google.maps.Map(document.getElementById("map_canvas"), options);
            ,

            (error) =>
            console.log(error);
            , locationOptions
            );



            4.in home.html



             <ion-content>
            <!-- <button ion-button (click)="presentModal()">presentModal</button> -->
            <div id="map_canvas"></div>
            </ion-content>


            5.in home.scss



            page-home 
            #map_canvas
            width: 100%;
            height: 100%;




            1. include in your src/index.html file (above the cordova.js file):

            that is it






            share|improve this answer

























            • <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

              – Tlzdeveloper786
              Nov 15 '18 at 16:21











            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47262734%2fgoogle-maps-not-showing-on-ionic-when-the-plugin-is-used%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Try to add this in config.xml plugins list:



            <plugin name="cordova-plugin-googlemaps" spec="~2.0.6">
            <variable name="API_KEY_FOR_ANDROID" value="Your_key" />
            </plugin>





            share|improve this answer























            • This has already been added.

              – Shreya
              Nov 13 '17 at 11:32











            • I had not seen it in your repo so..

              – Husain
              Nov 13 '17 at 11:35






            • 1





              also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

              – Husain
              Nov 13 '17 at 11:36












            • Thank u so much. Adding iframe made it work. Thanks a million times.

              – Shreya
              Nov 13 '17 at 11:40











            • Hey it worked yesterday but today it stopped working again

              – Shreya
              Nov 14 '17 at 5:35















            1














            Try to add this in config.xml plugins list:



            <plugin name="cordova-plugin-googlemaps" spec="~2.0.6">
            <variable name="API_KEY_FOR_ANDROID" value="Your_key" />
            </plugin>





            share|improve this answer























            • This has already been added.

              – Shreya
              Nov 13 '17 at 11:32











            • I had not seen it in your repo so..

              – Husain
              Nov 13 '17 at 11:35






            • 1





              also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

              – Husain
              Nov 13 '17 at 11:36












            • Thank u so much. Adding iframe made it work. Thanks a million times.

              – Shreya
              Nov 13 '17 at 11:40











            • Hey it worked yesterday but today it stopped working again

              – Shreya
              Nov 14 '17 at 5:35













            1












            1








            1







            Try to add this in config.xml plugins list:



            <plugin name="cordova-plugin-googlemaps" spec="~2.0.6">
            <variable name="API_KEY_FOR_ANDROID" value="Your_key" />
            </plugin>





            share|improve this answer













            Try to add this in config.xml plugins list:



            <plugin name="cordova-plugin-googlemaps" spec="~2.0.6">
            <variable name="API_KEY_FOR_ANDROID" value="Your_key" />
            </plugin>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '17 at 11:28









            HusainHusain

            324112




            324112












            • This has already been added.

              – Shreya
              Nov 13 '17 at 11:32











            • I had not seen it in your repo so..

              – Husain
              Nov 13 '17 at 11:35






            • 1





              also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

              – Husain
              Nov 13 '17 at 11:36












            • Thank u so much. Adding iframe made it work. Thanks a million times.

              – Shreya
              Nov 13 '17 at 11:40











            • Hey it worked yesterday but today it stopped working again

              – Shreya
              Nov 14 '17 at 5:35

















            • This has already been added.

              – Shreya
              Nov 13 '17 at 11:32











            • I had not seen it in your repo so..

              – Husain
              Nov 13 '17 at 11:35






            • 1





              also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

              – Husain
              Nov 13 '17 at 11:36












            • Thank u so much. Adding iframe made it work. Thanks a million times.

              – Shreya
              Nov 13 '17 at 11:40











            • Hey it worked yesterday but today it stopped working again

              – Shreya
              Nov 14 '17 at 5:35
















            This has already been added.

            – Shreya
            Nov 13 '17 at 11:32





            This has already been added.

            – Shreya
            Nov 13 '17 at 11:32













            I had not seen it in your repo so..

            – Husain
            Nov 13 '17 at 11:35





            I had not seen it in your repo so..

            – Husain
            Nov 13 '17 at 11:35




            1




            1





            also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

            – Husain
            Nov 13 '17 at 11:36






            also u can use <iframe> tag , and inside it open directly the google map.because i can also face issue then i had write the same .

            – Husain
            Nov 13 '17 at 11:36














            Thank u so much. Adding iframe made it work. Thanks a million times.

            – Shreya
            Nov 13 '17 at 11:40





            Thank u so much. Adding iframe made it work. Thanks a million times.

            – Shreya
            Nov 13 '17 at 11:40













            Hey it worked yesterday but today it stopped working again

            – Shreya
            Nov 14 '17 at 5:35





            Hey it worked yesterday but today it stopped working again

            – Shreya
            Nov 14 '17 at 5:35













            0














            Have you registered in Google Maps and added API KEY do your app?






            share|improve this answer























            • Yes I have done that

              – Shreya
              Nov 13 '17 at 11:03











            • any error in console? Does the directive added anything to page?

              – FrontMonkey
              Nov 13 '17 at 11:05











            • When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

              – Shreya
              Nov 13 '17 at 11:07












            • Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

              – FrontMonkey
              Nov 13 '17 at 11:11












            • I deployed it on my phone as well and still I get a blank screen.

              – Shreya
              Nov 13 '17 at 11:15















            0














            Have you registered in Google Maps and added API KEY do your app?






            share|improve this answer























            • Yes I have done that

              – Shreya
              Nov 13 '17 at 11:03











            • any error in console? Does the directive added anything to page?

              – FrontMonkey
              Nov 13 '17 at 11:05











            • When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

              – Shreya
              Nov 13 '17 at 11:07












            • Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

              – FrontMonkey
              Nov 13 '17 at 11:11












            • I deployed it on my phone as well and still I get a blank screen.

              – Shreya
              Nov 13 '17 at 11:15













            0












            0








            0







            Have you registered in Google Maps and added API KEY do your app?






            share|improve this answer













            Have you registered in Google Maps and added API KEY do your app?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '17 at 11:02









            FrontMonkeyFrontMonkey

            24117




            24117












            • Yes I have done that

              – Shreya
              Nov 13 '17 at 11:03











            • any error in console? Does the directive added anything to page?

              – FrontMonkey
              Nov 13 '17 at 11:05











            • When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

              – Shreya
              Nov 13 '17 at 11:07












            • Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

              – FrontMonkey
              Nov 13 '17 at 11:11












            • I deployed it on my phone as well and still I get a blank screen.

              – Shreya
              Nov 13 '17 at 11:15

















            • Yes I have done that

              – Shreya
              Nov 13 '17 at 11:03











            • any error in console? Does the directive added anything to page?

              – FrontMonkey
              Nov 13 '17 at 11:05











            • When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

              – Shreya
              Nov 13 '17 at 11:07












            • Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

              – FrontMonkey
              Nov 13 '17 at 11:11












            • I deployed it on my phone as well and still I get a blank screen.

              – Shreya
              Nov 13 '17 at 11:15
















            Yes I have done that

            – Shreya
            Nov 13 '17 at 11:03





            Yes I have done that

            – Shreya
            Nov 13 '17 at 11:03













            any error in console? Does the directive added anything to page?

            – FrontMonkey
            Nov 13 '17 at 11:05





            any error in console? Does the directive added anything to page?

            – FrontMonkey
            Nov 13 '17 at 11:05













            When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

            – Shreya
            Nov 13 '17 at 11:07






            When I run using ionic lab I get the following error: GET google-analytics.com/analytics.js (anonymous) @ ionic-lab:124 (anonymous) @ ionic-lab:125 otherwise no error

            – Shreya
            Nov 13 '17 at 11:07














            Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

            – FrontMonkey
            Nov 13 '17 at 11:11






            Are you deploying app to phone or use it or desktop? It may not work on desktop - try to deploy it to phone

            – FrontMonkey
            Nov 13 '17 at 11:11














            I deployed it on my phone as well and still I get a blank screen.

            – Shreya
            Nov 13 '17 at 11:15





            I deployed it on my phone as well and still I get a blank screen.

            – Shreya
            Nov 13 '17 at 11:15











            0














            Here is the code that worked :



            import Component from '@angular/core';


            import NavController from 'ionic-angular';
            import GoogleMap, GoogleMaps, LatLng, CameraPosition, GoogleMapsEvent from '@ionic-native/google-maps';

            @Component(
            selector: 'page-home',
            templateUrl: 'home.html'
            )
            export class HomePage

            constructor(public navCtrl: NavController, public googleMaps: GoogleMaps)



            ngAfterViewInit()
            this.loadMap();


            loadMap()
            let element = document.getElementById('map');
            let map: GoogleMap = this.googleMaps.create(element, );
            let latlng = new LatLng(40.7128, -74.0059);


            map.one(GoogleMapsEvent.MAP_READY).then(() =>
            let position: CameraPosition =
            target: latlng,
            zoom: 10,
            tilt: 30

            map.moveCamera(position);
            )





            And in your HTML file



            <div #map id="map" style="height:100%;"></div>


            This is the tutorial : http://tphangout.com/ionic-2-google-maps/






            share|improve this answer



























              0














              Here is the code that worked :



              import Component from '@angular/core';


              import NavController from 'ionic-angular';
              import GoogleMap, GoogleMaps, LatLng, CameraPosition, GoogleMapsEvent from '@ionic-native/google-maps';

              @Component(
              selector: 'page-home',
              templateUrl: 'home.html'
              )
              export class HomePage

              constructor(public navCtrl: NavController, public googleMaps: GoogleMaps)



              ngAfterViewInit()
              this.loadMap();


              loadMap()
              let element = document.getElementById('map');
              let map: GoogleMap = this.googleMaps.create(element, );
              let latlng = new LatLng(40.7128, -74.0059);


              map.one(GoogleMapsEvent.MAP_READY).then(() =>
              let position: CameraPosition =
              target: latlng,
              zoom: 10,
              tilt: 30

              map.moveCamera(position);
              )





              And in your HTML file



              <div #map id="map" style="height:100%;"></div>


              This is the tutorial : http://tphangout.com/ionic-2-google-maps/






              share|improve this answer

























                0












                0








                0







                Here is the code that worked :



                import Component from '@angular/core';


                import NavController from 'ionic-angular';
                import GoogleMap, GoogleMaps, LatLng, CameraPosition, GoogleMapsEvent from '@ionic-native/google-maps';

                @Component(
                selector: 'page-home',
                templateUrl: 'home.html'
                )
                export class HomePage

                constructor(public navCtrl: NavController, public googleMaps: GoogleMaps)



                ngAfterViewInit()
                this.loadMap();


                loadMap()
                let element = document.getElementById('map');
                let map: GoogleMap = this.googleMaps.create(element, );
                let latlng = new LatLng(40.7128, -74.0059);


                map.one(GoogleMapsEvent.MAP_READY).then(() =>
                let position: CameraPosition =
                target: latlng,
                zoom: 10,
                tilt: 30

                map.moveCamera(position);
                )





                And in your HTML file



                <div #map id="map" style="height:100%;"></div>


                This is the tutorial : http://tphangout.com/ionic-2-google-maps/






                share|improve this answer













                Here is the code that worked :



                import Component from '@angular/core';


                import NavController from 'ionic-angular';
                import GoogleMap, GoogleMaps, LatLng, CameraPosition, GoogleMapsEvent from '@ionic-native/google-maps';

                @Component(
                selector: 'page-home',
                templateUrl: 'home.html'
                )
                export class HomePage

                constructor(public navCtrl: NavController, public googleMaps: GoogleMaps)



                ngAfterViewInit()
                this.loadMap();


                loadMap()
                let element = document.getElementById('map');
                let map: GoogleMap = this.googleMaps.create(element, );
                let latlng = new LatLng(40.7128, -74.0059);


                map.one(GoogleMapsEvent.MAP_READY).then(() =>
                let position: CameraPosition =
                target: latlng,
                zoom: 10,
                tilt: 30

                map.moveCamera(position);
                )





                And in your HTML file



                <div #map id="map" style="height:100%;"></div>


                This is the tutorial : http://tphangout.com/ionic-2-google-maps/







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Feb 9 '18 at 5:04









                ShreyaShreya

                239413




                239413





















                    0














                    1.open project directory and run this in cmd



                     ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="api key" -variable API_KEY_FOR_IOS="api key here"


                    2.add this in specific map page



                    declare var google;


                    3.In the same class



                     ionViewDidLoad() 
                    if (this.global.checkNetwork() == true)
                    this.initializeMap();

                    else
                    this.showAlert("Internet is not available");



                    initializeMap()

                    let locationOptions = timeout: 20000, enableHighAccuracy: true ;

                    navigator.geolocation.getCurrentPosition(

                    (position) =>

                    let options =
                    center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
                    zoom: 16,
                    mapTypeId: google.maps.MapTypeId.ROADMAP


                    this.map = new google.maps.Map(document.getElementById("map_canvas"), options);
                    ,

                    (error) =>
                    console.log(error);
                    , locationOptions
                    );



                    4.in home.html



                     <ion-content>
                    <!-- <button ion-button (click)="presentModal()">presentModal</button> -->
                    <div id="map_canvas"></div>
                    </ion-content>


                    5.in home.scss



                    page-home 
                    #map_canvas
                    width: 100%;
                    height: 100%;




                    1. include in your src/index.html file (above the cordova.js file):

                    that is it






                    share|improve this answer

























                    • <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

                      – Tlzdeveloper786
                      Nov 15 '18 at 16:21
















                    0














                    1.open project directory and run this in cmd



                     ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="api key" -variable API_KEY_FOR_IOS="api key here"


                    2.add this in specific map page



                    declare var google;


                    3.In the same class



                     ionViewDidLoad() 
                    if (this.global.checkNetwork() == true)
                    this.initializeMap();

                    else
                    this.showAlert("Internet is not available");



                    initializeMap()

                    let locationOptions = timeout: 20000, enableHighAccuracy: true ;

                    navigator.geolocation.getCurrentPosition(

                    (position) =>

                    let options =
                    center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
                    zoom: 16,
                    mapTypeId: google.maps.MapTypeId.ROADMAP


                    this.map = new google.maps.Map(document.getElementById("map_canvas"), options);
                    ,

                    (error) =>
                    console.log(error);
                    , locationOptions
                    );



                    4.in home.html



                     <ion-content>
                    <!-- <button ion-button (click)="presentModal()">presentModal</button> -->
                    <div id="map_canvas"></div>
                    </ion-content>


                    5.in home.scss



                    page-home 
                    #map_canvas
                    width: 100%;
                    height: 100%;




                    1. include in your src/index.html file (above the cordova.js file):

                    that is it






                    share|improve this answer

























                    • <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

                      – Tlzdeveloper786
                      Nov 15 '18 at 16:21














                    0












                    0








                    0







                    1.open project directory and run this in cmd



                     ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="api key" -variable API_KEY_FOR_IOS="api key here"


                    2.add this in specific map page



                    declare var google;


                    3.In the same class



                     ionViewDidLoad() 
                    if (this.global.checkNetwork() == true)
                    this.initializeMap();

                    else
                    this.showAlert("Internet is not available");



                    initializeMap()

                    let locationOptions = timeout: 20000, enableHighAccuracy: true ;

                    navigator.geolocation.getCurrentPosition(

                    (position) =>

                    let options =
                    center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
                    zoom: 16,
                    mapTypeId: google.maps.MapTypeId.ROADMAP


                    this.map = new google.maps.Map(document.getElementById("map_canvas"), options);
                    ,

                    (error) =>
                    console.log(error);
                    , locationOptions
                    );



                    4.in home.html



                     <ion-content>
                    <!-- <button ion-button (click)="presentModal()">presentModal</button> -->
                    <div id="map_canvas"></div>
                    </ion-content>


                    5.in home.scss



                    page-home 
                    #map_canvas
                    width: 100%;
                    height: 100%;




                    1. include in your src/index.html file (above the cordova.js file):

                    that is it






                    share|improve this answer















                    1.open project directory and run this in cmd



                     ionic cordova plugin add cordova-plugin-googlemaps --variable API_KEY_FOR_ANDROID="api key" -variable API_KEY_FOR_IOS="api key here"


                    2.add this in specific map page



                    declare var google;


                    3.In the same class



                     ionViewDidLoad() 
                    if (this.global.checkNetwork() == true)
                    this.initializeMap();

                    else
                    this.showAlert("Internet is not available");



                    initializeMap()

                    let locationOptions = timeout: 20000, enableHighAccuracy: true ;

                    navigator.geolocation.getCurrentPosition(

                    (position) =>

                    let options =
                    center: new google.maps.LatLng(position.coords.latitude, position.coords.longitude),
                    zoom: 16,
                    mapTypeId: google.maps.MapTypeId.ROADMAP


                    this.map = new google.maps.Map(document.getElementById("map_canvas"), options);
                    ,

                    (error) =>
                    console.log(error);
                    , locationOptions
                    );



                    4.in home.html



                     <ion-content>
                    <!-- <button ion-button (click)="presentModal()">presentModal</button> -->
                    <div id="map_canvas"></div>
                    </ion-content>


                    5.in home.scss



                    page-home 
                    #map_canvas
                    width: 100%;
                    height: 100%;




                    1. include in your src/index.html file (above the cordova.js file):

                    that is it







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 15 '18 at 16:37









                    Barry

                    2,87071738




                    2,87071738










                    answered Nov 15 '18 at 16:09









                    Tlzdeveloper786Tlzdeveloper786

                    13




                    13












                    • <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

                      – Tlzdeveloper786
                      Nov 15 '18 at 16:21


















                    • <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

                      – Tlzdeveloper786
                      Nov 15 '18 at 16:21

















                    <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

                    – Tlzdeveloper786
                    Nov 15 '18 at 16:21






                    <script async defer src="maps.googleapis.com/maps/api/js?key=key here" type="text/javascript"></script> <!-- cordova.js required for cordova apps --> <script src="cordova.js"></script>

                    – Tlzdeveloper786
                    Nov 15 '18 at 16:21


















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f47262734%2fgoogle-maps-not-showing-on-ionic-when-the-plugin-is-used%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3