Google Map With Auto Info Window

There are many guides out the there that explain in detail how to create a google map, however I struggled to find one that would show you how to create a Google map for your webpage, create a marker on the map, create an info window and make that window centre on the page and open automatically on page load. After doing all this I also wanted the map to load in satellite view as a default too.

The biggest flaw I found was in opening the html info window of the map automatically,  I managed to get this working in Firfox, however in the latest version of IE I simply received a Javascript error and the map would not load.

This tutorial will show you how to;

Create a Google map
get co-ordinates for your location quickly
Place a marker and info window on the map
Open the widow automatically
Load the map in Satellite mode as default

Lets start by obtaining your Maps API key from Google

Go here and sign up for a Google maps api Key http://code.google.com/apis/maps/signup.html

Once completed you will be provided with a Key that is unique to your domain name, copy this and put it somewhere safe for a few moments.

Open up your webpage in a HTML editor and place this line into the head section of your page.
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAoeym2RwBy_aygGSCU-AxjRQ7qZ61VBL5U7OYDjSzrhfRKw1GIxSNsyhPasBJnueyUp-gcfonzwIm1Q" type="text/javascript"></script>
Where it says key= be sure to include your key instead of the one seen here.

Now create the div that will contain your map

If you have not already done so, now is the time to create the area that you want the map to go in. Create a div in your html page with the ID map, so <div id="map">

In your style sheet, lets setup how you want it to look, for the sake of this tutorial, I will simply create a simple div;

#map { width:500px; height:500px }

Lets create the actual map

All of this code should be added in the head section of your website.

The first thing we are going to add is the event that will trigger the info window to open on page load. If you would prefer just to show your marker and not have the window open on load then ignore this section.
<script type="text/javascript">
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
</script>

Now we need to initialise the map and make it target the div you have just created, note: if your div has a different id then sipply chang “map” in the script below to your div.
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(43.298344, 5.383221), 13);
}
}

This map is now centered over somewhere in France, you are probably thinking at this point, how the hell do I get the co-ordinates for where I want the map to show. You will be pleased to know that it is simple.

Go to http://maps.google.com/ and enter your location, lets choose Marseilles in France. click search maps.

Once the map has loaded enter this line of code into your browser address bar and press enter

javascript:void(prompt('',gApplication.getMap().getCenter()));

You should now have the co-ordinates open in a popup window ready for you use. Where in the code we have this

map.setCenter(new GLatLng(43.298344, 5.383221), 13);

Simply replace my co-ordinates with your own. We have now set the area that the map will show.

And now for your marker

We need to use the script to create a marker point, we also do this using co-ordinates, for the sake of this tutorial and to keep things simple, lets use the same co-ordinates that the map is located in.
var point = new GLatLng(43.298344, 5.383221);
var marker = createMarker(point)
map.addOverlay(marker);

Lets add your info window. This can contain HTML and you can even include images
map.openInfoWindowHtml(map.getCenter(),("<b>A Title</b><br>Text about France"));

Put it all together and you should have something that looks like this;
<script type="text/javascript">
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(43.298344, 5.383221), 13);
map.openInfoWindowHtml(map.getCenter(),("<b>A Title</b><br>Text about France"));
var point = new GLatLng(43.298344, 5.383221);
var marker = createMarker(point)
map.addOverlay(marker);
}
}
</script>

There is one final thing you need to do and that is initiate the map load when the page is viewed by someone, we do this by adding this piece of code in place of your body tag;
<body onload="initialize()" onunload="GUnload()">

The extras

I personally prefer maps to open in Satellite view by default and also with smaller controls on the map, we do this by adding the following to the script;
map.setMapType(G_SATELLITE_MAP);
map.addControl(new GSmallMapControl());

And thats it! everything is now complete and if you want the same code as me, it should look something like this;


<script type="text/javascript">
function createMarker(point,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(43.298344, 5.383221), 13);
map.setMapType(G_SATELLITE_MAP);
map.openInfoWindowHtml(map.getCenter(),("<b>A Title</b>
text about France"));
var point = new GLatLng(43.298344, 5.383221);
var marker = createMarker(point)
map.addOverlay(marker);
}
}
</script>

Ampersands With Attitude

By Huw Wilkins

Ampersands have long been the character in a typeface with which typographers can indulge themselves. Sweeping curves, flirtatious finishes and bold statements – these are the things that make ampersands an exciting character to use and, better still, to design.

Ampersands with attitude?

Can you spot what typeface is used to display the ampersand in the image above? Large view

There are, however, two problems. The first is that the English language gives us few situations to use such a daring character. We seldom get to show off these beautiful examples of typography. The second is that the poor little ampersand so often goes unnoticed.

Allow me to share with you my top 10 different styles of ampersands. Some are similar, but each have their own personality. In an effort to limit my sample selection, I have only chosen ampersands from freely available sans fonts.

1. Nilland

Nilland

Here we have a pretty run-of-the-mill ampersand. It comes from the font Nilland. You see this style in common fonts like Helvetica and Arial. It has the classic one piece figure-of-eight body. The little horizontal tail finishes this character off nicely, it seems to give a certain perkiness that it otherwise might have lacked.

2. Bitstream Vera Sans

Bitstream

You might recognise this style as well. This particular character comes from Bitstream Vera Sans. There are a few ways to look at this ampersand, and this is one of the reasons this character works so well. It looks like the ampersand above, only with the top right side of the figure-of-eight cut out (yet it actually ends up not looking very much like the above character). It also looks like a sweeping back-to-front 3 with a extension from the middle (you can see this better if you turn your head so your left ear is pressed against your shoulder).

3. BPmono

BPmono

This is where things start to get a little weird. Is it a ‘g’ gone wrong? Is it a swan? Is it a fishing hook? Actually it’s the ampersand from BPmono. I probably shouldn’t have likened it to a swan and a fish hook, because now you’re probably having a hard time seeing it for what it is… a sweet little ampersand with a cute tucked in style.

4. Kontrapunkt

Kontrapunkt

Here we have another style entirely. It’s an evolution of what you might see in handwriting. However, on paper the line would be drawn down the middle of the ‘E’ shape. This is the font Kontrapunkt, so it’s been given angles and a lovely boldness.

5. Diavlo

Diavlo

Diavlo is a great font with nice tips, and this character is no exception. At this size it looks like it has an oriental brush stroke style.

6. La Peruta FLF

LaPerutaFLF

Oh! I’m glad someone managed to prop up that eight before it fell over… wait let’s make that into an ampersand. LaPerutaFLF, with a name like that, you have to be cheeky.

7. Skia

Skia

Another more classical approach from Skia. The nice variation here is how the two halves intersect in that off-set way.

8. Tuffy

Tuffy

And. There’s no confusion here. It knows what it’s there to do and does it. Somehow, though, in this font it looks great. Nice one, Tuffy.

9. Lacuna

Lacuna

I’ve decided to finish off with two italicized ampersands. This one is from Lacuna and looks like some kind of crazy ‘e’. Somehow, with that cross bar and the horizontal plate at the end, it still ends up feeling like an ampersand.

10. Fontin

Fontin

And last, but certainly not least, here is the italicized ampersand from Fontin. It has a cheeky bulbous bottom and that classic plate finish.

So there we have it. 10 interesting takes on the ampersand. I hope you’ve been educated, I hope you have fallen in love with typography a little more, and I hope that next time you are creating a typeface you will be inspired to make an ampersand with attitude.

About the author

Huw Wilkins is the lead creative for a digital agency. He has a passion for user experience, usability, interfaces and good design. He also has a background in development. His little corner of the web is at huwshimi.com.

What Do You Want To Know?

So this is your chance, are you stuck on a project? need help with a menu? Javascript causing you a problem? what would you like to find out about? Pick our brains and put us to the test! or if you simply want to see some great design links, let us know what you want.

Add your comments below

Website 2.0 Colour Palette

OK so web 2.0 has been around for a while but we still find the web 2.0 colour palette usefull. Web 2.0 is about finding new ways to interact on the internet and collaboration, at least to a certain extent. Those of us in the know realise what Web2.0 is really all about – putting things on super shiney tables and painting them with gradients and candy colours and shiny silver and stuff.

Organised into 3 distinct colour groups – neutrals, muted tones and bold colours, you may recognize a few of the shades from some of your favourite Web2.0 sites. Now you can quickly and easily assemble your own colour scheme – simply choose any number of bold or muted colours, then add as many neutrals as you see fit – you’ll have a Web2.0 masterpiece in no time at all!

http://www.modernlifeisrubbish.co.uk/article/web-2.0-colour-palette

LavaLamp jQuery Navigation

I love this navigation and have used it in a number of websites lately, there are a couple of bugs in the script, but if you read my comments (Mark) on the page then it will help you get the navigation working perfectly.

Lately I am using jQuery for a number of things online and will be creating some tutorials over the next couple of week to show you how to add animation to your webpage without flash.