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

  • SEARCH
  • Home
  • 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 8256495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:52:37+00:00 2026-06-08T01:52:37+00:00

i am working on google map api v3. map is perfectly showing on my

  • 0

i am working on google map api v3. map is perfectly showing on my page… problem is that when i resize the browser, map fit to its original size when i load the page…

initial state when i load the pageenter image description here

when i resize the browser, map is still sized at initial state size.

enter image description here

[Code]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<script src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type='text/javascript'>
var point;
var mrktx;

function mshow()
{
        $("#search_content").css("display","");
}
function mhide()
{
        $("#search_content").css("display","none");
}

function load() {

   if(navigator.geolocation)
   {
        navigator.geolocation.getCurrentPosition(ShowPosition)
   }
   else
   {
      alert("Browser does not support");
      setTimeout( function(){ window.location = "../" },500);
   }
   function ShowPosition(position)
   {
        var lat = position.coords.latitude;
        var lng = position.coords.longitude;


   var cwidth = document.getElementsByTagName("body")[0].clientWidth;
   var cheight = document.getElementsByTagName("body")[0].clientHeight;
   //alert(cwidth + ',' + cheight);
    $("#body").css("overflow","hidden");
   $("#map_canvas").css("position","absolute");
   $("#map_canvas").css("overflow","auto"); 
   $("#map_canvas").css("height",cheight);
   $("#map_canvas").css("width",cwidth);
   $("#map_canvas").css("z-index","99")
   $("#map_canvas").css("top","0");
   $("#map_canvas").css("left","0em");
   $("#top_nav").css("width",cwidth);
   $("#top_nav").css("height","8%");

   var latlng = new google.maps.LatLng(lat,lng);
   var myOptions = {
      zoom: 11,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
   };

   var map = new google.maps.Map(document.getElementById("map_canvas"), 
              myOptions);

   $('document').resize(function(){
        google.maps.event.trigger(map, 'resize');
        map.setZoom( map.getZoom() );
   });



   var myMrkrTxt = "";
   var infowindow = new google.maps.InfoWindow({ content : myMrkrTxt });      
   var myMrkr = new google.maps.Marker({position:latlng,map:map});
        google.maps.event.addListener(myMrkr,'mouseover', function(){ infowindow.open(map,myMrkrTxt); });
        google.maps.event.trigger(map, "resize");


   }

}
</script>
<style>
#top_nav
{
    position: absolute; z-index: 200; top: 0px; background-color: black;
}
#top_nav h2
{
    color: white;
}
body, html {
  height: 100%;
  width: 100%;
}



</style>
</head>
<body onload='load()'>


<div id="map_canvas"></div>
</body>
</html>
  • 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-06-08T01:52:38+00:00Added an answer on June 8, 2026 at 1:52 am

    i guess you have to resize your map_canvas as well.

    so just add this to your resize()

    //its maybe better to attach this handler to the window instead of the document
    $(window).resize(function(){
            $('#map_canvas').css("height",$(window).height());
            $('#map_canvas').css("width",$(window).width());
            google.maps.event.trigger(map, 'resize');
            map.setZoom( map.getZoom() );
       });
    

    so you have track of the resizing of your browserwindow 🙂

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

Sidebar

Related Questions

I've been working on a google map (v3 of the api) that is plotting
I'm working on an advanced map application in Google Maps API V3. I'm using
I'm working on an application that generates a large number of Google Map markers
I am working with google map api ... http://code.google.com/p/gmaps-samples-flash/source/browse/trunk/samplecode/GeocodingSimple.mxml What i want to do
I am working on a google Map Api using fusion. I have multiple search
I am working on a Google Map that shows a spot on the map
i have a google map api key which is working in my website but
I'm using Google Maps Javascript API for showing a map in my site with
I wrote an app that plots my position on the google map API using
I am working on Google map application using Google Maps JavaScript API V2 .

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.