No Map on aspx

258 views
Skip to first unread message

Spodgy

unread,
Mar 22, 2010, 5:35:36 PM3/22/10
to Google Maps JavaScript API v3
Hi there,

I've been trying out Google's "Hello World" Map V3 app using VS2008
and IIS.
When I put the script into a html page, it works fine. When I copy the
script to the same places in an aspx page, I get a blank screen (both
on Cassini and IIS).
Any ideas?

<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="GoogleMapsFirst._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /
>
<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()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>

Chad Killingsworth

unread,
Mar 22, 2010, 6:01:35 PM3/22/10
to Google Maps JavaScript API v3
This is more of an HTML/CSS issue.

Many of the examples depend on the browser rendering the page in
quirks mode (without a doctype). This allows the "height: 100%" styles
to work without any additional CSS or JavaScript. There are several
threads that address this in this group both from a CSS only
perspective and by using JavaScript.

Chad Killingsworth

Spodgy

unread,
Mar 23, 2010, 6:03:10 AM3/23/10
to Google Maps JavaScript API v3
Thanks Chad,

I'll chase up the threads.

Best Wishes
Jim

On Mar 22, 10:01 pm, Chad Killingsworth

> > </html>- Hide quoted text -
>
> - Show quoted text -

Spodgy

unread,
Mar 23, 2010, 9:35:30 AM3/23/10
to Google Maps JavaScript API v3
Update:

OK.. after reading several discussion threads, staring at w3c's html
4.01 guide for a bit, and the input of a css savvy guru I found two
solutions:

1) Change width and height in the DIV to pixels instead of
percentages.
2) Remove the DocType tag (Flame goggles on)

I'd like to keep the percentages :)
There were a few mentions of <doctype html> as a potential solution
but no dice with the percentages.
Still trying to work out why it works on htm and not aspx... is this
to do with the sequence of events firing?
Rather than capturing the onload event, would it work if I fired the
code later? (if possible, without user intervention)

Thanks
Jim

> > - Show quoted text -- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages