﻿// JScript File

// JScript File
           
            var map = null;
            var geocoder = null;

            function initialize() {
              if (GBrowserIsCompatible()) {
                map = new GMap2(document.getElementById("map_canvas"));
                map.setCenter(new GLatLng(37.4419, -122.1419), 13);
                geocoder = new GClientGeocoder();
                hdnAddress = document.getElementById("hdnAddress");
                showAddress(hdnAddress.value);
                
                
              }
            }
 
    //<![CDATA[
    //var map = new GMap2(document.getElementById("map"));
    //var geocoder = new GClientGeocoder();
    //var address = 'San Diego, California';
    //function showAddress(address) {  geocoder.getLatLng(    address,    function(point) {      if (!point) {        alert(address + " not found");      } else {        map.setCenter(point, 13);        var marker = new GMarker(point);        map.addOverlay(marker);        marker.openInfoWindowHtml(address);      }    }  );}
    
//    function load() {
//      if (GBrowserIsCompatible()) {
//        var map = new GMap2(document.getElementById("map"));
//        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
//      }
//    }

    ////////////////////////////////////
    //Modified by: Ahsan Naseer
    //Desc: Have modified to Display info as required in the Bubble that is displayed on MAP
    ////////////////////////////////////
  
    function showAddress(address) {
        /////////////////////////////////
        
        //Format the info to be displayed in the Bubble
        var strEvent = document.getElementById("hdnEventInfo").value; 
        
        var WINDOW_HTML = '<div style="width: 210px;padding-right: 10px;">The starting location of event <b> ' + strEvent + '</b></div>';
        //WINDOW_HTML = WINDOW_HTML + ' is <b>' + address + '</b></div>';
        /////////////////////////////////    
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              //alert("[" + address + "] not found");
            } else {
              map.setCenter(point, 13);
              //map.addControl(new GOverviewMapControl ());
              
//              // Create our "tiny" marker icon
//              var  blueIcon = new GIcon(G_DEFAULT_ICON);
//              blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
//                
//              // Set up our GMarkerOptions object
//              markerOptions = { icon:blueIcon };

              var marker = new GMarker(point);// ,  {draggable: true} );
              
              map.addOverlay(marker);
             
             /////////`````````````````````````Shahid
//              var map = new GMap2(document.getElementById("map_canvas"));
//              map.setCenter(new GLatLng(37.4419, -122.1419), 13);
//              map.addControl(new GSmallMapControl());
              GEvent.addListener(map, 'click', function(overlay, latlng) {
              var lat = latlng.lat();
              var lon = latlng.lng();
              var latOffset = 0.01;
              var lonOffset = 0.01;
              var polygon = new GPolygon([
                new GLatLng(lat, lon - lonOffset),
                new GLatLng(lat + latOffset, lon),
                new GLatLng(lat, lon + lonOffset),
                new GLatLng(lat - latOffset, lon),
                new GLatLng(lat, lon - lonOffset)
                    ], "#f33f00", 5, 1, "#ff0000", 0.2);
                //map.addOverlay(polygon);
});
//////////////////////////`````````````Shahid
             
              
              //marker.openInfoWindowHtml(address);
             // marker.openInfoWindowHtml(WINDOW_HTML);
              
              
            }
          }
        );
      }
    }
//    function generateLatLng (address) 
//    { 
//     
//       
////        geocoder.getLatLng(address, function (point) 
////                                    { 
////                                       if (!point) 
////                                       {    alert(address + " not found");      
////                                            //alert('if'); 
////                                       } 
////                                       else 
////                                       {   
////                                           alert('else');     
////                                           map.setCenter(point, 13);        
////                                           var marker = new GMarker(point);        
////                                           map.addOverlay(marker);        
////                                           marker.openInfoWindowHtml(address);      
////                                       }    
////                                    });
//        //alert ("after geocoder"); 



//    } 

    
    
    //]]>
