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 6891929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:28:16+00:00 2026-05-27T06:28:16+00:00

I am using the Google Maps API to pull back a map with a

  • 0

I am using the Google Maps API to pull back a map with a series of points on it. I am also pulling back directions which are displayed in the element with ID=”directionsPanel”. This is all well and good except for the fact that when we get past a certain number of points (3 in Firefox, 4 in Chrome) they spill off the page.

I am using the following jQuery code to detect what the element height is (presumably after the directions are loaded) and then adjust it accordingly:

$(document).ready(function() {
  if($.browser.mozilla)
  {
    var sHeight = $("#directionsPanel").height();
    sHeight = (sHeight * 1.5);
    $("#directionsPanel").height(sHeight);
  }
  else
  {
    // do stuff for other browsers
  }

});

Unfortunately the element is not being adjusted to the right amount (perhaps it is not detecting the correct initial height?) and things are still spilling off the page. Any thoughts on how I might make this more robust?

  • 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-27T06:28:17+00:00Added an answer on May 27, 2026 at 6:28 am

    Google Maps API probably lets you specify a callback function for when the map has loaded, and that is where you should put your code.

    For example:

    var directionsDisplay;
    var directionsService = new google.maps.DirectionsService();
    var map;
    var haight = new google.maps.LatLng(37.7699298, -122.4469157);
    var oceanBeach = new google.maps.LatLng(37.7683909618184, -122.51089453697205);
    
    function initialize() {
      directionsDisplay = new google.maps.DirectionsRenderer();
      var myOptions = {
        zoom: 14,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: haight
      }
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      directionsDisplay.setMap(map);
    }
    
    function calcRoute() {
      var selectedMode = document.getElementById("mode").value;
      var request = {
          origin: haight,
          destination: oceanBeach,
          // Note that Javascript allows us to access the constant
          // using square brackets and a string value as its
          // "property."
          travelMode: google.maps.TravelMode[selectedMode]
      };
      directionsService.route(request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
          directionsDisplay.setDirections(response);
        }
        //YOUR CODE FOR RESIZING HERE
      });
    }
    <div>
    <b>Mode of Travel: </b>
    <select id="mode" onchange="calcRoute();">
      <option value="DRIVING">Driving</option>
      <option value="WALKING">Walking</option>
      <option value="BICYCLING">Bicycling</option>
    </select>
    </div>
    

    Don’t use $(document).ready() since that executes immediately when the DOM is loaded.

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

Sidebar

Related Questions

I'm using Google Maps API v2 and Geoxml to produce a map which is
I'm using the Google Maps API v2. I add markers to the map and
I'm using the Google Maps API to build a map full of markers, but
In Google Maps API v2, I was using map.clearOverlays() to remove the marker and
I'm developing a map application in Android. I'm using Google maps API to show
I am using Google Maps API to display a map on a certain page.
I'm using the Google Maps API (v2) and would like to center the map
I am using Google Maps V3 API to create a polyline with 2 points.
I'm using Google Maps API V3 and my page loads a map with 5
I'm using Google maps api v3. In the middle of the map there is

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.