When viewing Google maps in full screen mode, the image suddenly vanishes

I have a map with a logo positioned in the lower right corner near the controls. However, when I switch to full screen mode, the logo disappears. I can see the div (aggdata-info) in Firebug, but the image/logo is not visible. Any suggestions on how to fix this?

initMap : function() {
var me = this;

me.map.mapOptions = {
zoom : 4,
center : {
lat: 37.6,
lng: -95.665
},
mapTypeControlOptions : {
mapTypeIds : [
//'map_style',
google.maps.MapTypeId.ROADMAP,
google.maps.MapTypeId.TERRAIN,
google.maps.MapTypeId.SATELLITE,
google.maps.MapTypeId.HYBRID
]
},
//mapTypeId : 'map_style',

zoomControl : true,
mapTypeControl : true,
scaleControl : false,
streetViewControl : true,
rotateControl : true,
fullscreenControl : true,
fullscreenControlOptions : {
position : google.maps.ControlPosition.RIGHT_BOTTOM
}

};
div.aggdata-info {
height: 38px;
width: 170px;
text-align: center;
    line-height: 28px;
background: #fff url(../cmnimages/reit_common/data_by_aggdata.png) center center no-repeat;
box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
font-size: 12px;
position: absolute;
    margin-top: 493px;
    margin-left: 832px;
    padding: 0px 5px 0px 5px;
}

Logo displayed in standard size Logo disappears in full-screen mode

Below is the CSS code for the specified div.

Answer №1

Please follow my code and I apologize for not using your code! I made all the necessary changes in my own code.

Note: In the js file included, you will need to add your Google API key to avoid display errors on the Google map page:

Google Maps API error: InvalidKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key-map-error.

By using this disableDefaultUI: true, I have hidden certain objects on the Google map. It is also possible to hide specific objects on the map.

If you wish to make edits to your code, add the following code below:

var customControlDiv = document.createElement('div');
var customControl = new CustomControl(customControlDiv, map);
customControlDiv.index = 1;

And the function goes like this:

function CustomControl(controlDiv, map) {
            var tempBackgroundImage = "http://www.clker.com/cliparts/W/0/g/a/W/E/map-pin-red-md.png";
            controlDiv.style.padding = '5px';
            controlDiv.style.right = '5px';
            var myLocationControlDiv = document.createElement('DIV');

            var controlUI = document.createElement('DIV');
            controlUI.style.cursor = 'pointer';
            controlUI.style.background = "url(" + tempBackgroundImage + ") 68px 78px";
            controlUI.style.height = '68px';
            controlUI.style.width = '68px';
            controlUI.style.right = '15px';
            controlUI.style.bottom = '50px';
            controlUI.style.backgroundSize= '68px 78px';
            controlUI.title = 'Current location';

            myLocationControlDiv.appendChild(controlUI);
            map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(controlUI);

    }

That's all you need!

You can utilize the complete code below if you're not using any other code:

Html

 var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -34.397, lng: 150.644},
          zoom: 8,
          disableDefaultUI: true
        });
        var customControlDiv = document.createElement('div');
        var customControl = new CustomControl(customControlDiv, map);

        customControlDiv.index = 1;
      }
      function CustomControl(controlDiv, map) {
var tempBackgroundImage = "http://www.clker.com/cliparts/W/0/g/a/W/E/map-pin-red-md.png";
controlDiv.style.padding = '5px';
controlDiv.style.right = '5px';
var myLocationControlDiv = document.createElement('DIV');

var controlUI = document.createElement('DIV');
controlUI.style.cursor = 'pointer';
controlUI.style.background = "url(" + tempBackgroundImage + ") 68px 78px";
controlUI.style.height = '68px';
controlUI.style.width = '68px';
controlUI.style.right = '15px';
controlUI.style.bottom = '50px';
controlUI.style.backgroundSize= '68px 78px';
controlUI.title = 'Current location';

myLocationControlDiv.appendChild(controlUI);
map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(controlUI);

}
 /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
<script src="https://maps.googleapis.com/maps/api/js?key={YOUR_API_KEY}&callback=initMap"
    async defer></script>
<div id="map"></div>

Important thing:

Please adjust the values below according to the image size.

controlUI.style.height = '68px';
controlUI.style.width = '68px';
controlUI.style.backgroundSize= '68px 78px';

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

jQuery - Inserting Content at the End

As an example, I have the following chunk of HTML code: <div class="messageContainer"> <div class="message"> </div> </div> ---Here <div class="messageContainer"> <div class="message"> <here> :) &l ...

The program is designed to only allow up to two images to be wrapped

I'm struggling with a short jQuery program that I need help with. The problem is, I can't seem to get it to wrap more than two images in the same row. My goal is to create a website that side-scrolls, and I thought this approach would be the simp ...

Expansive dropdown options in the navigation bar

Can someone help me create a menu similar to the one in this screenshot? I am looking for a solution where hovering over a cursor will open a large submenu with two sections. Any examples or suggestions would be greatly appreciated. Thank you all in advan ...

There seems to be an issue with the CSS header alignment as the logo is not properly positioned using a top margin of -20px

My goal is to create a header bar that includes an image, a title, and a menu car. I want the bar to be displayed after scrolling 50px down, and I also want the image to be positioned slightly above the wrapping div, showing a bit of it in the top 50px. Ri ...

Maintain the image's aspect ratio by setting the width equal to the height when the height is

I am uncertain if achieving this purely with CSS is possible, but it would be ideal. I currently have an image: <img src="#" class="article-thumb"> CSS: .article-thumb { height: 55%; } Is there a way to set the width equal to the height? My g ...

Creating an Unordered List in GWT that Includes List Items

I've hit a roadblock while trying to create a css-driven menu in GWT. The menu should be rendered exactly like this: <div class="topbar"> <div class="container fixed"> <h3> <a href="" class="logo">test& ...

Increment and Decrement Values with JQuery

I am looking to implement a client-side Plus/Minus system where users can click on the plus sign to increase a value by 1 and minus sign to decrease the value by 1. The value should not go below zero and it should initially start at 0. Is there a simple wa ...

What is the process for incorporating a new task into my HTML/CSS/JavaScript to-do list application when the Enter key is pressed?

Currently, I am working on developing a to-do list application using HTML, CSS, and JavaScript. The application includes a text input field for users to enter their tasks, along with an "Add Task" button. However, I want to enhance the user experience by a ...

Trouble with the display:none attribute in Firefox and Chrome

<tr style="height:5px" id="TRRSHeaderTrialBar" name="TRRSHeaderTrialBar" style='display:none'> <tr id="TREmail" name="TREmail" style="height:1px;" nowrap style='display:none'> Using the code snippet above to hide the bar w ...

Ways to eliminate the excess space surrounding an Image border

I am looking to position the image at the top right corner of the screen. body{ font-family: 'Roboto', sans-serif; font-weight: 300; background: #822B2B; color: #ffffff; overflow: hidden; } #showcase{ display: flex; justify-content: center; al ...

Storing information in a database with multiple entries

Displaying a list of inactive users from a mysqli database in a table format, each user has a row with three drop-down menu options - admin, delete user, and activate user. The table is populated using a prepared statement to fetch data from the database. ...

Unable to locate the CSS file

I'm struggling to link a stylesheet file to my 'base.html' template that is used throughout my entire project. Here's the path to the file I want to link: C:\forum_project\static\main\css\style.css Below is ...

Issues with sending data using ajax

Trying to get weinre working through Ajax by calling this on dom ready: $.ajax({ url: 'http://debug.build.phonegap.com/target/target-script-min.js#hutber', dataType: "script", crossDomain: true, error: function(data){ c( ...

Guide on inserting a dropdown menu following a specific count of <li> elements using Javascript or Jquery

I am currently working on an HTML project <div class="ktmsg"> <ul> <li class="a1"> <a title="Link Tools" href="#"> … </a> </li> <li class="a2"> <a title="Link Tools" href="#"> ...

Verify the Ajax submission of a post request prior to transmitting any data

Currently, I am utilizing Google Tag Manager to handle form submission inside a Bootstrap modal. Due to limited backend access, I have opted for GTB to target a specific button and utilize the onClick event. <script> $(document).on('submit&apos ...

Unleashed placement and drifting

Is it possible to style this layout without specifying an exact height for "Element 1"? Code Element1 { positon: relative; width: 100%; height: auto; /* Avoiding specific height */ } Inner1 { position: absolute; top: xyz px; left: xyz px; } Inner2 { po ...

The submit button is unable to initiate the ajax function

I encountered an issue with my code while attempting to separate my form function into a different PHP file and utilize an Ajax function to call the form based on the IDs. However, after separating the form function, the submit button no longer triggers th ...

Leveraging Parameters in Ajax with jQuery and JavaScript

I've been exploring jQuery and trying to update a specific TD element with innerHTML. However, I'm stuck on how to capture the value of a parameter. In this scenario, my goal is to grab the user-id "1234" in order to update the TD identified as ...

When using Flexbox with a column wrap and setting the height to min-content, the wrapping behavior may not

I'm facing a CSS challenge. I have divs of varying heights and I want the parent element to adjust its height based on the tallest child element, while keeping the rest of the elements aligned properly. The code provided below achieves this for rows b ...

Press here to expose the remaining portion of the text using the truncate helper

Has anyone tried using jQuery with the truncate helper method in Rails? I've managed to turn the omission symbol into a link_to like this: <%= raw(truncate(@book.description, :length => 1000, :omission => (link_to' (continued)', :i ...