function loadmap() { if (GBrowserIsCompatible()) { var latlng = new GLatLng(51.26637,-2.53166); // Map lat/long var map = new GMap2(document.getElementById("map")); // Create new map object map.setCenter(latlng, 14); // Set center of map map.addControl(new GSmallMapControl()); // Add direction & zoom control map.addControl(new GMapTypeControl()); // Add map type control var baseIcon = new GIcon(); // Create base icon object var _icon = new GIcon(); // create _icon.iconSize = new GSize(63, 153); // set icon dimensions _icon.iconAnchor = new GPoint(3, 149); // set icon anchor point _icon.infoWindowAnchor = new GPoint(51.26637,-2.53166); // set anchor point of info window _icon.image = "/images/maplogo.png"; // set icon source _icon.shadow = "/images/mapshadow.png"; _icon.shadowSize = new GSize(147, 153); _icon.shadowAnchor = new GPoint(3, 149); var markerOptions = { icon:_icon }; // add icon to marker options var marker = new GMarker(latlng); // create new marker object using marker options GEvent.addListener(marker, "click", function() { // add event listener to marker to detect clicking map.openInfoWindowHtml(latlng, document.getElementById('mapinfo').innerHTML); // open info window using innerhtml of div map.setCenter(latlng, 14); // Set center of map }); map.addOverlay(marker); // Add marker to map } } $(document).ready(loadmap);