﻿
var googlemap_pos;
var googlemap_marker;
var googlemap_loaded = false;
var map = null;

function showMap(latitude, longitude)
{
    googlemap_loaded = false;
    
    if (GBrowserIsCompatible())
    {
        if (map)
            map.clearOverlays();
        else
        map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(latitude,longitude), 16);
        
        //map.addControl(new GSmallMapControl());
        //map.addControl(new GMapTypeControl());
	   
        // Create a base icon for all of our markers that specifies the
        // shadow, icon dimensions, etc.
        var baseIcon = new GIcon();
        baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
        baseIcon.infoShadowAnchor = new GPoint(18, 25);

        // Creates a marker whose info window displays the letter corresponding
        // to the given index.
        function createMarker(point, index) {
            // Create a lettered icon for this point using our icon class
            var letter = String.fromCharCode("X".charCodeAt(0) + index);
            var icon = new GIcon(baseIcon);
            icon.image = "http://www.google.com/mapfiles/marker" + letter + ".png";
            var marker = new GMarker(point, icon);

            GEvent.addListener(marker, "mouseover", 
                function() {
                    marker.openInfoWindowHtml("<strong>Pirotecnia Espinòs</strong><br/>Carretera Castellvell, 7<br/>43206 Reus (Tarragona) Spain<br/>Tel. <strong>93 977314761</strong><br/>Fax <strong>93 977314761</strong>");
                });
            return marker;
        }

        // Add 1 markers to the map at the location
        var point = new GLatLng(latitude,longitude);
        map.addOverlay(createMarker(point, 0));

        googlemap_loaded = true;
        
        map_open("map");

        //mark.parentNode.scrollIntoView(true);
        
        return false;
        }
    }
   