ボタンをクリックするとGoogleマップが表示されます

23770 ワード

原文:
ボタンをクリックするとGoogleマップが表示されます
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="http://maps.google.cn/maps?file=api&amp;v=2&amp;sensor=true&amp;key=ABQIAAAA8B5G0MGppsCNDDpwRLRu6BQrnClq8QSrQDsyF0yBh6Nxb_fPdRRy62PSpSpNN1RgvxBBuP0b63sdXA"
        type="text/javascript"></script>
    <style type="text/css">
        .sideDiv
        {
            z-index: 9999;
            margin-bottom: 3px;
            display: none;
            position: absolute;
            border: solid 1px #6e8bde;
        }
        .mapDiv
        {
            clear: both;
        }
        .filterDiv
        {
            color: #C7EDCC;
            background-color: inherit;
            position: absolute;
            top: 0px;
            left: 0px;
            filter: alpha(opacity=50);
        }
    </style>
    <script type="text/javascript">
        function showDiv(id) {
            // 
            initialize();
            //
            $("<div id='filterDiv' style='color: #C7EDCC;background-color: inherit;position: absolute;top: 0px;left: 0px;filter: alpha(opacity=50);'></div>")
            .width("100%")
            .height("100%")
            .click(function () { hideDiv(id); })
            .appendTo("body")
            .fadeIn(200);
            // 
            var bgdiv = $("#" + id);
            bgdiv.css({ "position": "fixed" })
            .animate({ left: "30%", top: "30%", opacity: "show" }, "slow");
        }


        function hideDiv(id) {
            // 
            $("#filterDiv").remove();
            $("#" + id).animate({ left: "0%", top: "0%", opacity: "hide" }, "slow");
        }


        function initialize() {
            if (GBrowserIsCompatible()) {
                // div 
                var map = new GMap2(document.getElementById("map"));
                // , 
                map.setCenter(new GLatLng(31.21552, 121.34464), 18);
                // 
                map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10, 10)));
                // 
                map.addControl(new GHierarchicalMapTypeControl());
                // 
                map.enableScrollWheelZoom();
                //
                map.enableGoogleBar();
            }
        }
    </script>
</head>
<body onunload="GUnload();">
    <form id="form1" runat="server">
    <input type="button" id="btnTest" value=" " onclick="showDiv('map');" /><br />
        <%--<div id='div-id' style="width: 550px; height: 440px; z-index: 9999; display: none;position: absolute; border: solid 1px #6e8bde;">--%>
            <div  id="map" class="mapDiv" style="width: 550px; height: 440px; z-index: 9999; display: none;border: solid 1px #6e8bde;"></div>
        <%--</div>--%>
        
    </form>
</body>
</html>