﻿

function showAddress() {
    var map = null;
    
    var geocoder = null;
    var address = "8015 Shoal Creek Blvd Austin TX 78757";
    //var address = document.getElementById('<%=Label1.ClientID%>').value;
    if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
       
        geocoder = new GClientGeocoder();
    }
    if (geocoder) {
        geocoder.getLatLng(address, function(point) {
            if (!point) { alert(address + " not found"); }
            else {
                map.setCenter(point, 14);
                var marker = new GMarker(point);
                map.addOverlay(marker);
                marker.openInfoWindowHtml(address);

            }
        }
        );
    }

    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());

    GEvent.addListener(map, "click", function(overlay, latlng) {
        if (overlay) {
            // ignore if we click on the info window
            return;
        }
        var tileCoordinate = new GPoint();
        var tilePoint = new GPoint();
        var currentProjection = G_NORMAL_MAP.getProjection();
        tilePoint = currentProjection.fromLatLngToPixel(latlng, map.getZoom());
        tileCoordinate.x = Math.floor(tilePoint.x / 256);
        tileCoordinate.y = Math.floor(tilePoint.y / 256);
        var myHtml = "Latitude: " + latlng.lat() + "<br/>Longitude: " + latlng.lng() +
            "<br/>The Tile Coordinate is:<br/> x: " + tileCoordinate.x +
            "<br/> y: " + tileCoordinate.y + "<br/> at zoom level " + map.getZoom();
        map.openInfoWindow(latlng, myHtml);
    });
   
}

