learn web technologies, the easy way

Using the New Marker and Shadow in your Map

If you did the tutorial called "Custom Google Map Markers" then you've seen what we're about to show here. You need to 'tell' the Google Map a few things about your marker, including:

 

The JavaScript Code

Following is the exact JavaScript needed to display the pencil and pencil's shadow that we've create in this tutorial:

var MyIcon = new GIcon(); // create a new Google Icon object
MyIcon.image = "images/pencil.png";// image file name
MyIcon.shadow = "images/pencil_shadow.png";// shadow file name
MyIcon.iconSize = new GSize(8, 30);// width (px) and height (px)
MyIcon.shadowSize = new GSize(30, 30);// the shadow's size
MyIcon.iconAnchor = new GPoint(5, 30);// base of the icon
var marker = new GMarker(point, MyIcon);
map.addOverlay(marker);

 

The Resulting Map:

 

Right-click here and save the file to your hard drive. This contains the HTML and JavaScript for the map.