﻿
    var map = null;
    var geocoder = null;

    function initialize() {
        debugger;
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 1);
       // map.setMapType(G_HYBRID_MAP);
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        geocoder = new GClientGeocoder();
	//GUnload();
      }
    }

    function showAddress() {
    debugger;
	address = document.getElementById("ctl00_ContentPlaceHolder2_txtAddress").value;
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) 
            {
              var va=' not found';
            } 
            else 
            {

              map.setCenter(point, 15);
      	      var center = map.getCenter();
      	      
	      document.getElementById("ctl00_ContentPlaceHolder2_lat").value = center.lat();
	      document.getElementById("ctl00_ContentPlaceHolder2_lang").value = center.lng();

              var marker = new GMarker(point, {draggable: true});
              map.addOverlay(marker);
              GEvent.addListener(marker, "dragend", function() {
                marker.openInfoWindowHtml(marker.getLatLng().toUrlValue(6));
              });
              GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml(marker.getLatLng().toUrlValue(6));
              });
	      GEvent.trigger(marker, "click");
            }
          }
        );
      }
    }

   function mapbyCords()
   {
   initialize()
   showAddress();
	llat = document.getElementById("ctl00_ContentPlaceHolder2_lat").value;
	llang = document.getElementById("ctl00_ContentPlaceHolder2_lang").value;
	//document.getElementById("txtAddress").value = "";
      // Retrieve the latitude and longitude
      point = new GLatLng(llat,
                          llang);
      // Center the map on this point
      map.setCenter(point, 9);
      // Create a marker
      marker = new GMarker(point);
      // Add the marker to map
      map.addOverlay(marker);
      // Add address information to marker
    
      
       GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(document.getElementById("ctl00_ContentPlaceHolder2_txtAddress").value);
              });
	      GEvent.trigger(marker, "click");
      
   }

