Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to float a div over Google Maps and keep it in fullscreen?

I would like to put a div on a Google map, even when the map is in full screen.

I could already place the div in front of the map when it is not in full screen, but what I need is that the div is shown in both circumstances.

The div that i need to put over google map in fullscreen is: .cont-items-monitor

Here is my html code:

<div class="gx-card-body">
    <div class="cont-items-monitor overlay" style="display: none">
        <ul>
            <li>Seat León JMG-8823</li>
            <li>Seat Ibiza JMG-8823</li>
            <li>VW Vento JMG-8823</li>
            <li>Nissan Versa JMG-8823</li>
            <li>Nissan March JMG-8823</li>
            <li>Lincoln Navigator JMG-8823</li>
            <li>Seat León JMG-8823</li>
            <li>Seat Ibiza JMG-8823</li>
            <li>VW Vento JMG-8823</li>
            <li>Nissan Versa JMG-8823</li>
            <li>Nissan March JMG-8823</li>
            <li>Lincoln Navigator JMG-8823</li>
            <li>Seat León JMG-8823</li>
            <li>Seat Ibiza JMG-8823</li>
            <li>VW Vento JMG-8823</li>
            <li>Nissan Versa JMG-8823</li>
            <li>Nissan March JMG-8823</li>
            <li>Lincoln Navigator JMG-8823</li>
            <li>Seat León JMG-8823</li>
            <li>Seat Ibiza JMG-8823</li>
            <li>VW Vento JMG-8823</li>
            <li>Nissan Versa JMG-8823</li>
            <li>Nissan March JMG-8823</li>
            <li>Lincoln Navigator JMG-8823</li>
            <li>Seat León JMG-8823</li>
            <li>Seat Ibiza JMG-8823</li>
            <li>VW Vento JMG-8823</li>
            <li>Nissan Versa JMG-8823</li>
            <li>Nissan March JMG-8823</li>
            <li>Lincoln Navigator JMG-8823</li>
        </ul>
    </div>

    <div id="google-map"></div>
</div>

My css code:

.cont-items-monitor {
position: absolute;
top: 60px;
left: 0;
bottom: 30px;
z-index: 1;
background-color: white;
overflow-x: scroll;
padding: 10px 15px 10px 0;
}
like image 746
Carlos Rodríguez Avatar asked Apr 12 '19 17:04

Carlos Rodríguez


1 Answers

I finally could solve it. What I had to do was put the div that I want to be superimposed on the first div that is generated when the Google map is initialized.

My html code is the same, the only thing I did was move it with jquery after all the elements of the website are loaded.

My html code super explained and verified: (Imagine that the following code is inside the basic structure of an html page)

<div class="gx-card-body">
                                    <!-- <div class="cont-fab">
                                        <a href="javascript:void(0)" class="gx-fab-btn gx-btn-primary">
                                            <i class="zmdi zmdi-account-add zmdi-hc-fw zmdi-hc-lg"></i>
                                        </a>
                                    </div> -->
                                    <div class="cont-items-monitor overlay" style="display: none">
                                        <ul>
                                            <li>Seat León JMG-8823</li>
                                            <li>Seat Ibiza JMG-8823</li>
                                            <li>VW Vento JMG-8823</li>
                                            <li>Nissan Versa JMG-8823</li>
                                            <li>Nissan March JMG-8823</li>
                                            <li>Lincoln Navigator JMG-8823</li>
                                            <li>Seat León JMG-8823</li>
                                            <li>Seat Ibiza JMG-8823</li>
                                            <li>VW Vento JMG-8823</li>
                                            <li>Nissan Versa JMG-8823</li>
                                            <li>Nissan March JMG-8823</li>
                                            <li>Lincoln Navigator JMG-8823</li>
                                            <li>Seat León JMG-8823</li>
                                            <li>Seat Ibiza JMG-8823</li>
                                            <li>VW Vento JMG-8823</li>
                                            <li>Nissan Versa JMG-8823</li>
                                            <li>Nissan March JMG-8823</li>
                                            <li>Lincoln Navigator JMG-8823</li>
                                            <li>Seat León JMG-8823</li>
                                            <li>Seat Ibiza JMG-8823</li>
                                            <li>VW Vento JMG-8823</li>
                                            <li>Nissan Versa JMG-8823</li>
                                            <li>Nissan March JMG-8823</li>
                                            <li>Lincoln Navigator JMG-8823</li>
                                            <li>Seat León JMG-8823</li>
                                            <li>Seat Ibiza JMG-8823</li>
                                            <li>VW Vento JMG-8823</li>
                                            <li>Nissan Versa JMG-8823</li>
                                            <li>Nissan March JMG-8823</li>
                                            <li>Lincoln Navigator JMG-8823</li>
                                        </ul>
                                    </div>

                                    <div id="google-map"></div>
                                </div>

My JS code (jQuery):

$(document).ready(function () {
    $('.cont-items-monitor').appendTo($('#google-map').find('div')[0]);
});

I hope it serves someone else

like image 196
Carlos Rodríguez Avatar answered Nov 15 '22 07:11

Carlos Rodríguez