Software Archive
Read-only legacy content
17061 Discussions

google maps iframe

nicolas_r_
Beginner
304 Views

hi i have some problems with google maps embed on Iframe i use like 10 on my app on the preview they work fine also in the emulator but when i build the apk and try on my phone sometimes they din't apear and there is just a blank space others they are not well centered some advised to fix that?

<style>
                    .wrapper {
                        position: relative;
                        padding-bottom: 165%; // This is the aspect ratio
                        height: 0;
                        overflow: hidden;
                    }
                    .wrapper iframe {
                        position: absolute;
                        top: 0;
                        left: 0;
                        width: 100% !important;
                        height: 93% !important;
                    }
                </style>

                <div id="mapa_2" class="upage-content vertical-col left hidden">

                    <div class="wrapper">

                        <iframe src="http://mapbuildr.com/frame/hc0v2v" frameborder="0"></iframe>
                    </div>
                </div>

0 Kudos
2 Replies
Rakshith_K_Intel
Employee
304 Views

Some old android devices dont initialize height and width immediately, try loading map after Cordova deviceready event is fired, here is sample code I tested, this loads the iframe src after deviceready event is fired:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <style>
        .wrapper {
            position: relative;
            padding-bottom: 165%; // This is the aspect ratio
            height: 0;
            overflow: hidden;
        }
        .wrapper iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100% !important;
            height: 93% !important;
        }
    </style>
    <script src="cordova.js"></script>
    <script>
        document.addEventListener("deviceready", function(){
            document.getElementById("map").src = "http://mapbuildr.com/frame/hc0v2v"; 
        }, false);
    </script>    
</head>
<body>
    <div id="mapa_2" class="upage-content vertical-col left hidden">
        <div class="wrapper">
            <iframe id="map" src="" frameborder="0"></iframe>
        </div>
    </div>
</body>
</html>

 

0 Kudos
nicolas_r_
Beginner
304 Views

ty so much at least in emulate works fine now i have to edit for other maps on the apk and try on my phone =)

0 Kudos
Reply