返回首页

大家好,
我已经写了下面的代码。它似乎不会有任何错误,因为它越来越编译。但在地图上是没有得到显示。 PL帮助


<head runat="server">

 

        <title>Google Maps JavaScript API Example</title>

    

        <script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg"

      type="text/javascript">

        </script>

    

        <script type="text/javascript">

    

        function disp() 

        {

            var lat = document.getElementById('<%= txtlat.ClientID %>').value;

            var lng = document.getElementById('<%= txtlng.ClientID %>').value;

            load(lat, lng)

            alert('inside disp()');

        }

    

        function load(float a, float b) 

        {

            if (GBrowserIsCompatible()) 

            {

                var map = new GMap2(document.getElementById("map"));

                map.setCenter(new GLatLng(a, b), 15);

                var marker = new GMarker(new GLatLng(a, b));

	            map.addOverlay(marker);

            }

        }

    

        </script>

 

    </head>

 

    <body>

 

        <div id="map" style="width: 500px; height: 300px"></div>

 

            <form id="form1" runat="server">

    

                <div>

                    <br />

                    <asp:Label ID="lbllat" runat="server" Text="Enter the latitude:" Width="130px"> 

                    <asp:TextBox ID="txtlat" runat="server"><br />

                    <br />

                    <asp:Label ID="lbllng" runat="server" Text="Enter the longitude:" ToolTip=" " Width="130px"> 

                    <asp:TextBox ID="txtlng" runat="server">

                    <br />

                    <br />

                                           

                      

                    <asp:Button ID="btnsubmit" runat="server" Text="Submit" onclientclick="disp"/>

                </div>

      

            </form>

    

    </body>

| debo_india

回答

评论会员:游客 时间:2012/02/06
您好所有,我得到的解决方案......当我把它当成一个输入按钮(而不是作为一个asp按钮)按钮对象,我得到正确的结果。{S0}
迈赫迪吴拉姆:在你的脚本行:
{C}
给下面的错误:
function GBrowserIsCompatible() {return false;}alert("This web site needs a different Google Maps API key. A new key can be generated at http://code.google.com/apis/maps/signup.html.");function GUnload() {}var G_API_VERSION;
评论会员:游客 时间:2012/02/06
Vivek克里希纳穆尔蒂:我建议参考下面的文章,非常漂亮的解释imgsrc=http://www.orcode.com/img/ico/smiley_smile.gif看你的代码,调试会有所帮助。一些提示1。检查什么GBrowserIsCompatible返回也1。您的标签最亘古不变的结束标记。2。检查在Java脚本错误3。的OnClientClick="DISP();"固定在页面上所有的错误应该得到它的运行。后改变代码的变化映射在我的机器上。{体C3}