﻿

function InitializeMap(map_canvasID, address) {
    var geocoder;
    var maps;

    //sets the centre of the map the the address specified
    geocoder = new google.maps.Geocoder();
    geocoder.geocode({ 'address': address }, function (results, status) {

        if (status == google.maps.GeocoderStatus.OK) {

            //creates the map ..
            var myOptions = {
                zoom: 14,
                center: results[0].geometry.location,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            map = new google.maps.Map(document.getElementById(map_canvasID), myOptions);

            //add marker to the map
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });
        } else {
            alert("Sorry there was an error loading google maps:(");
        }
    });
}

function TourReBind() {
    $('.mapElement').each(function (i) {
        var currentId = $(this).attr('id');
        var address = $(this).attr('address');
        InitializeMap(currentId, address);
    });

    /* STRIP NON-ALPHANUMERIC CHARACTORS */
    $('.stripHtml').alphanumeric({ ichars: '<>' });
    $('.stripHtmlTags').alphanumeric({ ichars: '<>' });
}
