Maps V3 loaded but not displaying (happens across all browsers)

500 views
Skip to first unread message

Isen Ng

unread,
Mar 28, 2011, 6:59:13 AM3/28/11
to google-map...@googlegroups.com
Hi,

I am facing this weird issue. (btw I am upgrading from v2 to v3)

When copy and pasted the code directly from the tutorial page found here:

However, when I added a <form> tag around it, maps stopped working altogether. I can see that i is loading from the loading text at the bottom of the browser and using firebug, i can see all the map divs being loaded. However they are just not being rendered. I'm using master pages and may use maps in user controls, so having the map canvas only at the root level is not exactly very smart.

Here is the sample code im using to trigger the bug:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0px; padding: 0px }
      #map_canvas { height: 100% }
    </style>
    <script type="text/javascript"
        src="http://maps.google.com/maps/api/js?sensor=false">
    </script>
    <script type="text/javascript">
        function initialize() {
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var myOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
        }
</script>
</head>
<body onload="initialize()">
    <form id="form1" runat="server">
        <div id="map_canvas" style="width:100%; height:100%"></div>
    </form>    
</body>
</html>

Please let me know if this is a bug or maps v3 is supposed to work like this. If that's the case, i may have to write additional iframes just to display maps.

Regards,
Isen

Andrew Leach

unread,
Mar 28, 2011, 8:00:11 AM3/28/11
to google-map...@googlegroups.com
On 28 March 2011 11:59, Isen Ng <iseng...@gmail.com> wrote:

> However, when I added a <form> tag around it, maps stopped working
> altogether.

Do they stop working? Or are they simply not displayed? You are
specifying percentage heights -- you need to ensure that that *every*
element up the hierarchy to <html> has its height specified.

Currently there is an element in the DOM hierarchy which has zero height.

Please bear in mind that you should post a link, not code. In *this*
case it's possible to see fairly easily what's likely to be wrong. But
we still can't verify that with a code listing, and we could had you
posted a link. There will be other queries which cannot be answered
without a link, so it's best to supply one all the time.

Isen Ng

unread,
Mar 28, 2011, 8:28:02 AM3/28/11
to google-map...@googlegroups.com, andrew...@bcs.org
here's a link to the buggy page:

How are you debugging to get 'there is an element in the DOM hierarchy which has zero height.'? using firebug does not allow (or maybe i dont know how) me to debug this.

I'm not very good at debugging at the DOM level. I would appreciate it if there's a direction I could follow to debug and ultimately solve this issue. (and learn a new debugging skill)

Andrew Leach

unread,
Mar 28, 2011, 8:34:45 AM3/28/11
to google-map...@googlegroups.com
On 28 March 2011 13:28, Isen Ng <iseng...@gmail.com> wrote:
> here's a link to the buggy page:
> http://www.isbweb.dev.mow.wavesecure.com/test/locationv3test.aspx
>
> How are you debugging to get 'there is an element in the DOM hierarchy which
> has zero height.'? using firebug does not allow (or maybe i dont know how)
> me to debug this.

By reading your code! You didn't give any other opportunity.

> I'm not very good at debugging at the DOM level. I would appreciate it if
> there's a direction I could follow to debug and ultimately solve this issue.
> (and learn a new debugging skill)

Firefox probably won't object to your <form> element not having a
height, but generally use the HTML tab in Firebug, highlight elements
in the hierarchy and look at the Style shown in Firebug's right-hand
frame.

Isen Ng

unread,
Mar 28, 2011, 8:41:55 AM3/28/11
to google-map...@googlegroups.com, andrew...@bcs.org
Hmm,
Ok.

So theoratically, if I add height:100% to the form tag, the problem should be solved.

Thanks!
I will try it later!

Isen

en4ce

unread,
Mar 28, 2011, 11:48:07 AM3/28/11
to Google Maps JavaScript API v3
yep this:

<form name="form1" method="post" action="locationv3test.aspx"
id="form1" style="width:100%; height:100%">

do the trick

Isen Ng

unread,
Mar 29, 2011, 2:39:56 AM3/29/11
to google-map...@googlegroups.com, en4ce
Thanks! i got the buggy page working.

However what's even weirder is that my actual page started working even before I made any changes. The actual page don't use any % height, it has a absolute px height. Weird, but as long as it works

en4ce

unread,
Mar 29, 2011, 7:33:13 AM3/29/11
to Google Maps JavaScript API v3
if i follow your link again, its still not working ...
Reply all
Reply to author
Forward
0 new messages