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

The Archive Base Latest Questions

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

The issue I am having is with the initialisation of the Google maps api.

  • 0

The issue I am having is with the initialisation of the Google maps api. When I have the maps api in a normal div that is set to be displayed it works perfectly and toggles up and down but when I set the display to none it does not load correctly. The map only loads half way down and the pin image is not displayed. Is there a work around for this or will this simply not function in a toggle slide that is initially not displayed.

The example page I have created is as below.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type='text/javascript' src='scripts/jscripts/jquery-1.4.js'></script>

<style type="text/css">
.slideTogglebox{
    float:left;
    padding:8px;
    margin:16px;
    border:1px solid red;
    width:500px;
    height:350px;
    background-color:#000000;
    color:white;
    display:none;
}
.clear{
    clear:both;
}
</style>

</head>

<body>
<?php
$url ="http://maps.googleapis.com/maps/api/geocode/xml?address=PL329YN&sensor=false";
$getAddress = simplexml_load_file($url);
$lat = $getAddress->result->geometry->location->lat;
$lng = $getAddress->result->geometry->location->lng;
?>

<div class="clear">
<h3>slideToggle() example</h3> <a href="javascript:slideToggle()" id=slideToggle>Click Me</a>
<br/>
<div class="slideTogglebox" id='map_canvas'>

</div>

</div>

<script type="text/javascript">

function initialize() {

    <?php
    print "var lat = $lat;";
    print "var lng = $lng;";
    ?>

    var latlng = new google.maps.LatLng(lat, lng);
    var myOptions = {
        zoom: 10,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var image = 'images/map/pin_green.png';
    var myLatLng = new google.maps.LatLng(lat, lng);
    var beachMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: image
    });
}

var init = false;

$("#slideToggle").click(function () {

   if (!init) {
        initialize();
        init = true;
   }
   $('.slideTogglebox').slideToggle('slow');
});


</script>
  • 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-27T12:13:17+00:00Added an answer on May 27, 2026 at 12:13 pm

    There appears to be an issue with the new v3 api and jquery. It does seem to work with the v2 of the Google maps api without issue.

    Therefore to fix the problem I have called the initialize function from after the div toggles. Then I have set the background in the CSS to match the background on the page so that it appears to fadein after the toggle.

    <script type="text/javascript">
    
    $("#slideToggle").click(function () {
    
       $('.slideTogglebox').slideToggle(function initialize() {
    
            <?php
            print "var lat = $lat;";
            print "var lng = $lng;";
            ?>
    
            var latlng = new google.maps.LatLng(lat, lng);
            var myOptions = {
                zoom: 10,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
            var image = 'images/map/pin_green.png';
            var myLatLng = new google.maps.LatLng(lat, lng);
            var beachMarker = new google.maps.Marker({
                position: myLatLng,
                map: map,
                icon: image
            });
        });
    });
    
    
    </script> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a device that support SAE J1939 interface and having issue with finding
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm having an issue with a standard ASP.NET page that has a TextBox and
I'm having issue with Action Listener of a JTable that being updated according the
I am having issue with git pull.I have commited my changes in local repo.
I am encountering an issue where having a ending script tag inside a quoted
I'm having an issue with my regex. I want to capture <% some stuff
I'm having an issue with a Flash/Flex erroring in Firefox but not IE. I
I’m having an issue where a drop down list in IE 6/7 is behaving
I am having an issue where Tomcat is treating extra path information as part

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.