Brain Stormer, Web Guy and Comic Nerd

Full Screen Google Map as Site Background

This is meant to be a quick tutorial on how to make a full screen Google map as the background to your site. It will only touch on the Google Map API as there is so much more features/options that I won’t get into here, if you’d like a more in-depth tutorial on Google Maps API let me know in the comments and I’ll set one up in the future.

In the code example I am not going to break up the CSS or JS into separate files just for ease of the tutorial, use your ninja skills to figure out how to break it up and use the code properly on your site.

Let’s start with building the HTML document:

Dirty Code


<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<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>
<style type="text/css"><!--
html { height: 100% }      body { height: 100%; margin: 0px; padding: 0px }      #mapbg { height: 100%; position: fixed; top: 0; bottom: 0; left: 0; right: 0; z-index: 0;}      #wrapper { height:100%; width: 960px; background-color: #FFF; position:absolute; left: 50%; margin-left: -480px; z-index:1;}
--></style>

 
As you can see there is one js file required from Google Maps API. The CSS is pretty basic with two id selectors (#wrapper and #mapbg), using ‘position:fixed;’ and ‘position:absolute;’ it will allow you to use ‘z-index’ properly. Next up the body:

Dirty Code


<div id="wrapper">Your page content here!</div>

<div id="mapbg"></div>

<script type="text/javascript">
function load() {      
var map = new google.maps.Map(document.getElementById("mapbg"),
{        
center: new google.maps.LatLng(55.3, -97),        
zoom: 4,
scrollwheel: false,        
mapTypeId: 'roadmap'      
});      
var infoWindow = new google.maps.InfoWindow;    
}
</script>
<script type="text/javascript">window.onload.load();</script>

As you can see I did not put much in the #wrapper div but this is where your normal page content will go (header, nav, articles, footer etc), then after the #wrapper div we have the #mapbg div which will hold the map itself. The Javascript is setting up the map with some basic options, check out the Google Maps API for reference on what some of these options are and how to add more.

That’s it! The important thing here is the ‘postiton’ and ‘z-index’ options in the CSS, with out those set properly the wrapper will be above the map instead of on top.

WordPress Plugin: Scrolling Twitter Feed Widget

–UPDATE– Twitter has changed their API and finally killed their Search API, meaning this solution no longer works. There is a way around this however it requires oAuth and I really wanted to avoid that for ease of use to the users. I will revisit this in the coming week but there is a good [...]

New Project – Twitter #music Player

I know I haven’t really added much new content here in some time, I thought I should provide an update on an exciting new project that I am working on. uKoel.com is a work in progress that creates youtube playlists in a few interesting ways. There are three “players” availible at the moment; Charts creates [...]

Change the Loop via Ajax

It seems like every site now is using AJAX for infinite scrolling, from Facebook to Pintrest to Twitter. While there are quite a few ways to achieve infinite scrolling in WordPress I’ve decided to show how NOT to. Don’t get me wrong, I love them and would love to have enough content to actually justify [...]

Git or Subversion what version control do you use?

This is more of an open forum than a post. I’m curious who is using what and why. Myself, I actually use both on a daily basis. My work place uses GIT and most of my individual projects use Subversion. Both were somewhat chosen for me to be honest, obviously my work place has been [...]

New Wooden Case for my Raspberry PI!

Well I finally have my RaspberryPI up and running smoothly and now with a great custom built wooden case! You may notice that I didn’t put holes for the composite video or the analog audio, this side of the case is what faces me on the couch and since I am using the HDMI I [...]

WordPress Quickie – Add a Class to Menu Items

WordPress does a pretty good job at adding classes to your nav menu items by default, but sometimes you might need something different. Here is a quick tip that will allow you to set a class based on the item’s title.   //add classes to the nav items to make it easier to match up [...]

WordPress Quickie – Category Specific Single Post Templates

This is the first in a new series that I am going to try to stick to called “WordPress Quickies”. They will be small straight forward posts with a quick few lines of code that could help you when creating a WordPress site. There may not always be an example included with the post of [...]

Some notes on Child Themes in WordPress

Child Themes are great, they save you from having to write to much serious code yet give you the flexibility to modify you site as you see fit. I’ve already written a tutorial on a quick way to create a child theme but I feel like I should break down what a child theme can [...]

Add Custom Taxonomy to Your WordPress Site

Categories and tags are great, you can really do a lot with them when it comes to filtering queries see here. But a ton of categories can really look messy in the backend and confuse your editors (or you at 4am). Here is a quick run down of WordPress’ register_taxonomy function. The code below can [...]

Lorem Ipsum and Place Holder Image Shortcodes

Yet another one of those “does anyone really need this” plugin ideas of mine. If you follow me on twitter you would know that I have started to become a little obsessed with APIs. There are thousands out there and so many of them have that “this is cool but how can I actually use [...]