﻿
function loadGMap(mapdiv, lat, lng, zl) 
{
    if (GBrowserIsCompatible()) {
        var map;
        map = new GMap2(document.getElementById(mapdiv));
        map.setCenter(new GLatLng(lat, lng), zl);
        map.addControl(new GLargeMapControl());
        map.addControl(new GScaleControl());
        return map;
       
/*
        if( locationName != null && locationName != '' )
        {
            // Create our 'tiny' marker icon
            var blueIcon = new GIcon(G_DEFAULT_ICON);
            blueIcon.iconSize = new GSize(32, 32);
            blueIcon.image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png';
            // Set up our GMarkerOptions object
            markerOptions = { icon: blueIcon };
            var point = new GLatLng(lat, lng);
            var marker = new GMarker(point, markerOptions);
            map.addOverlay(marker);
            GEvent.addListener(marker, 'click', function() 
            {
                this.openInfoWindowHtml('<br><b>' + locationName + '</b><br>');
            };
         }
         */
     }
}

function createGIcon(iconImage, shadowImage, iconAnchorWidth, iconAnchorHeight, infoWindowAnchorWidth, infoWindowAnchorHeight) {

    if (iconImage == '')
        return new GIcon(G_DEFAULT_ICON);

    var _icon = new GIcon();

    if (iconImage != '')
        _icon.image = iconImage;

    if (shadowImage != '')
        _icon.shadow = shadowImage;

    _icon.iconAnchor = new GPoint(iconAnchorWidth, iconAnchorHeight);
    _icon.infoWindowAnchor = new GPoint(infoWindowAnchorWidth, infoWindowAnchorHeight);

    return _icon;
}



function createGMarker(map, latitude, longitude, infoHtml, icon) {

    if (map != null && map.isLoaded()) {

        var point = new GLatLng(parseFloat(latitude), parseFloat(longitude), true);

        var bounds = map.getBounds();
        bounds.extend(point);
        var newzl = map.getBoundsZoomLevel(bounds);
        map.setZoom(newzl);

        var marker = new GMarker(point, icon);
        map.addOverlay(marker);

        if (infoHtml != null && infoHtml != "") {
            GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(infoHtml); });
        }
    }
}


