﻿// JScript File
//Mapping Functions

function ShowLocationMap(address, containerDiv)
{
    if( window.GClientGeocoder != null )
    {
        var geocoder = new GClientGeocoder();
        geocoder.getLocations(address, function( response ){
                ShowMap(response, containerDiv);
            });
    }
    else
    {
        //map javascript not included because of either incorrect key/key not found
        containerDiv.innerHTML = "Map service not available.";
    }
}

//show map from geocoded location
function ShowMap( response, containerDiv )
{
    if (GBrowserIsCompatible())
    {    
        if (!response || response.Status.code != 200 || !(response.Placemark[0]))
        {
            containerDiv.innerHTML = "Unable to produce Map for this address.";
        }
        else
        {
            var map = new GMap2(containerDiv);
            map.setCenter(new GLatLng(34, 0), 1);
            map.clearOverlays();
            
            place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1],
                                place.Point.coordinates[0]);
            
            marker = new GMarker(point);
            map.addOverlay(marker);
            map.setCenter(point, 13);
            map.addControl(new GSmallMapControl());
            //marker.openInfoWindowHtml('Your school');
        }
    }
    else
    {
        containerDiv.innerHTML = "Browser is not compatible for Map.";
    }
}
//End mapping functions
