Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:41:12+00:00 2026-05-30T17:41:12+00:00

I have a full screen Google map with HTML/CSS toolbars overlaid on the map,

  • 0

I have a full screen Google map with HTML/CSS toolbars overlaid on the map, and a set of map markers.

Is there a way to ensure there is enough padding between the markers and the edges of the map, so that no markers are obscured by the toolbars?

(Codepen in case the code below doesn’t work)

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    draggable: true,
    streetViewControl: false,
    zoomControl: false
  });

  var marker1 = new google.maps.Marker({
    position: {lat: 37, lng: -121},
    map: map,
  });

  var marker2 = new google.maps.Marker({
    position: {lat: 39.3, lng: -122},
    map: map,
  });
 
  var bounds = new google.maps.LatLngBounds();
  bounds.extend(marker1.position);
  bounds.extend(marker2.position);
  map.fitBounds(bounds);
}
#map {
  height: 640px;
  width: 360px;
}
#overlays {
  position: absolute;
  height: 50px;
  width: 340px;
  background: white;
  margin: -80px 10px;
  text-align: center;
  line-height: 50px;
}
/* Optional: Makes the sample page fill the window. */
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Simple markers</title>

  </head>
  <body>
    <div id="map"></div>
    <div id="overlays">Controls / Order pizza / ETA / etc.</div>
  
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?&callback=initMap">
    </script>
  </body>
</html>

The problem is this:

enter image description here

UPDATE I’ve tried adding a control as documented at Custom controls, but the map isn’t exactly aware of it – see this fiddle forked from the Maps custom control example. One of the markers is still obscured by the control.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:41:14+00:00Added an answer on May 30, 2026 at 5:41 pm

    PHP to make your map fit into your google maps canvas:

    a. create a maxmin frame around your imagine wiht maxLat, minLat, maxLng and minLng from everything that you want to show.

    $queryMaxMin = 'SELECT max(Nr_Coordinate_Latitude) AS maxLat, min(Nr_Coordinate_Latitude) AS minLat, max(Nr_Coordinate_Longitude) AS maxLng, min(Nr_Coordinate_Longitude) AS minLng FROM coordinate ';
    $resultMaxMin = mysql_query($queryMaxMin);
    if (count($resultMaxMin) > 0) {
        $rowMaxMin = mysql_fetch_array($resultMaxMin);
        include ('distanceGeoPoints.php');
        $distance = distanceGeoPoints($rowMaxMin['maxLat'], $rowMaxMin['maxLng'], $rowMaxMin['minLat'], $rowMaxMin['minLng']);
    }
    

    b. then take the diagonal (maxLat, minLng) to (minLat, maxLng) and calculate the distance using the geometry.spherical library or any algorithm you like – the earth is NOT spherical girls and boys, different models are better equiped to calculate area/distance in your region of the world (wikipedia has a great article on algorithms)

    function distanceGeoPoints ($lat1, $lng1, $lat2, $lng2) {
    $earthRadius = 3958.75;
    $dLat = deg2rad($lat2-$lat1);
    $dLng = deg2rad($lng2-$lng1);
    $a = sin($dLat/2) * sin($dLat/2) +
       cos(deg2rad($lat1)) * cos(deg2rad($lat2)) *
       sin($dLng/2) * sin($dLng/2);
    $c = 2 * atan2(sqrt($a), sqrt(1-$a));
    $dist = $earthRadius * $c;
    // from miles
    $meterConversion = 1609;
    $geopointDistance = $dist * $meterConversion;
    return $geopointDistance;
    }
    

    c. depending on your canvas’s dimensions, set up a zoom factor array (this is mine):

    $zoomFactor[0] = null;
    $zoomFactor[1] = null;
    $zoomFactor[2] = null;
    $zoomFactor[3] = null;
    $zoomFactor[4] = null;
    $zoomFactor[5] = 2000000;
    $zoomFactor[6] = 1000000;
    $zoomFactor[7] = 500000;
    $zoomFactor[8] = 250000;
    $zoomFactor[9] = 120000;
    $zoomFactor[10] = 60000;
    $zoomFactor[11] = 30000;
    $zoomFactor[12] = 15000;
    $zoomFactor[13] = 7500;
    $zoomFactor[14] = 3500;
    $zoomFactor[15] = 2000;
    $zoomFactor[16] = 1100;
    $zoomFactor[17] = 500;
    $zoomFactor[18] = null;
    $zoomFactor[19] = null;
    $zoomFactor[20] = null;
    

    d. then create a routine that takes the distance you got in step b and check it against array:

    // zoom factor establish
    $zoomFactorFinal = '';
    if (($distance > 500) && ($distance < 2000000))  {
        include ('zoomFactor.php');
        for ($i=20;$i>0;$i--) {
            if (!is_null($zoomFactor[$i])) {
                if ($distance < ($zoomFactor[$i])) {
                    // save until distance is smaller than
                    $zoomFactorFinal .= '&z='.$i;
                    $zoomInt = $i;
                    $i = 0;
                    //echo 'SUCESSO '.$zoomFactorFinal;
                } 
            }
        }
    } else {
        if ($distance <= 500)  {
            $zoomFactorFinal .= '&z=16';
            $zoomInt = 16;
        }
        if ($distance >= 2000000)  {
            $zoomFactorFinal .= '&z=2';
            $zoomInt = 2;
        }
    }   
    

    f. finally, append the $zoomFactorFinal to your googlemaps URL if you are embedding or use a variation of setZoom() method on your canvas display

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Silverlight application running full screen. Is there a way i can
I'd like my application to have a full-screen mode. What is the easiest way
I have a simple app with a full screen UIWebView. This contains HTML generated
What I'm doing is I have a full-screen form, with no title bar, and
I have several aspx pages that can be opened either normally (full screen in
I have an IE6 absolute position div that I want to be full screen
I am trying to have a UI which is a full screen UIWebView. When
So, I have a screen capture utility (it takes full screen shots and saves
In the application I'm developping (in Java/swing), I have to show a full screen
I have been trying with no luck to load a google map over a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.