doctype tag blocks embedded Google Maps

I have a website template which was developed for me by another company. The first line of this is:

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

I have added some code to the site to embed Google Maps onto the site, a section of this code is as follows:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var Duffields = new google.maps.LatLng(52.5241, 1.2576);
    var myOptions = {
      zoom: 8,
      center: Duffields,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
...

I was surprised when I visited this page to note that the map didn't appear.

After much experimentation, I discovered that if I deleted the doctype tag the map appeared fine, however with the doctype tag gone the layout of the site's nav bar was affected.

Can anyone telll me why the doctype tag is breaking Google Maps, and more importantly how to fix it!

Richard
LVL 1
rpmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NetExpert-WarszawaCommented:
Try the following DOCTYPE:

<!DOCTYPE html PUBLIC "-//W3C//DTD xhtml 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 
0
rpmAuthor Commented:
Still kills the map, I'm afraid!
0
NetExpert-WarszawaCommented:
Could you give a link please?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

rpmAuthor Commented:
http://www.duffields.co.uk/bfs-map.asp

The doctype tag is currentkly removed so that the map displays, but this mucks up the nav bar
0
NetExpert-WarszawaCommented:
You might use an old google code. See a source of http://code.google.com/intl/pl/apis/maps/documentation/examples/map-markers.html and note the difference:

Yours:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
...

Googles:
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
            type="text/javascript"></script>
...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Google Maps JavaScript API Example: Map Markers</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
            type="text/javascript"></script>
    <script type="text/javascript">
    
    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
 
        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i < 10; i++) {
          var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
                                  southWest.lng() + lngSpan * Math.random());
          map.addOverlay(new GMarker(point));
        }
      }
    }

    </script>
  </head>

  <body onload="initialize()" onunload="GUnload()">
    <div id="map_canvas" style="width: 500px; height: 300px"></div>
  </body>
</html>

Open in new window

0
rpmAuthor Commented:
The example you have just quoted is the v2 api, I am using the v3 api
0
NetExpert-WarszawaCommented:
First, your website is not XHTML compliant. XHTML 1.0 Strict doctype makes no sense. However I corrected all errors and it still does not show the map.

For now you can use doctype:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

I will further investigate the problem
0
NetExpert-WarszawaCommented:
I believe this is the error:
<div id="map_canvas" style="width:600; height:500"></div>

You wanted to use:
<div id="map_canvas" style="width:600px; height:500px"></div>

Could you verify it please?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rpmAuthor Commented:
Genius! Thank you very much.

That was based on sample Google code, you'd have though they would get it right!

Richard
0
NetExpert-WarszawaCommented:
0
rpmAuthor Commented:
Thanks for the tip!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.