Google Maps API Basic Tutorial

© 2006, 2007, 2008, 2009 Mike Williams

 

Maps in articles

If you've got a page that contains significant information other than the map, then you won't want to deny access to people using browsers that are not compatible with the Google maps API or which have Javascript turned off. They might be interested to read the text in the rest of the page

What you can do is to remove the <noscript> section, and the alert that you'd normally throw for a non-compatible browser. Instead, initially create the map <div> with zero size, like this.

<div id="map" style="width: 0px; height: 0px"></div>
Then, in your Javascript, if the browser is compatible, change the width and height to the required size just before creating the GMap.
    var m = document.getElementById("map");
    m.style.height = "400px";
    m.style.width = "500px";
    var map = new GMap2(m);
   
If you switch off Javascript and reload this page, or view it in a non-compatible browser, you'll still be able to read all the text and see everything else on the page, but there will be no map, and no empty space where the map would have been.

Back to Mike's Homepage
Up to the start of this tutorial