Full gmap height in grids

I am using the primign ronin theme and I am trying to make a fullscreen gmap regardless of screen resolution. however, if I don’t specify the height in pixels, this will not work.

for example, if I set the css height attribute for the map to 100%, it does not appear, and if I wrap the gmap with a div container with 100% height, it still doesn't work. How can I create a full-featured full-screen gmap screen?

+4
source share
1 answer

You can show responsive p: gmap full screen as follows:

Suppose it is p:gmapdefined as follows (no attribute needed style)

<p:gmap id="gmap" center="41.381542, 2.122893" zoom="13" type="hybrid" />

JavaScript ,

         <script>
            function resizeElement(elementId,width,height){
                console.log("Resizing element " + elementId + " W/H="+ width + "/" + height);

                var element = document.getElementById(elementId);

                element.style.width=width+"px";
                element.style.height=height+"px"
            }

            function resizePfGmapFullScreen() {
                var width = window.innerWidth - 20;
                var height = window.innerHeight - 20;

                resizeElement("gmap", width, height);
            }

            window.onload = function() {
                window.dispatchEvent(new Event('resize'));
            };

            window.onresize = function(event) {
                console.log("Screen is resized");

                resizePfGmapFullScreen();
            };
        </script>

, p:map , .

Primfaces 6.1.

0

Source: https://habr.com/ru/post/1610582/


All Articles