带有更新面板的Google地图未显示

时间:2015-04-14 12:25:16

标签: javascript c# google-maps

我正在Google地图上工作,并且已经在我的网页上成功显示了它。但是当点击按钮并且按钮确实回发地图时,不会在更新面板中显示此地图。



 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">
        var markers = [
        <asp:Repeater ID="rptMarkers" runat="server">
        <ItemTemplate>
                 {
                "title": '<%# Eval("City") %>',
                 "lat": '<%# Eval("Latitude") %>',
                 "lng": '<%# Eval("Longitude") %>',
                
             }
    </ItemTemplate>
    <SeparatorTemplate>
        ,
    </SeparatorTemplate>
    </asp:Repeater>
    ];
    </script>
        
    <script type="text/javascript">

        function myfunction()
        {
            window.onload = function () {
                var mapOptions = {
                    center: new google.maps.LatLng(markers[0].lat, markers[0].lng),
                    zoom: 15,
                
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
            
                var infoWindow = new google.maps.InfoWindow();
                var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);
                for (i = 0; i < markers.length; i++) {
                    var data = markers[i]
                    var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                    var marker = new google.maps.Marker({
                        position: myLatlng,
                        map: map,
                        title: data.title
                    });
                    (function (marker, data) {
                        google.maps.event.addListener(marker, "click", function (e) {
                            infoWindow.open(map, marker);
                        });
                    })(marker, data);
                }
            }
        }

        myfunction();
        

    </script>
&#13;
 <asp:ScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel runat="server" ID="panel2">
            <ContentTemplate>
                <div id="dvMap" style="width: 500px; height: 500px;margin-right: auto;margin-left: auto;right: 137px;top: -55px;display:block">
                </div>
                <div class="container">

                    <div class="flotleftt" style="width: 750px">
                        <div class="breadcrumb" style="position: relative; top: -10px; ">
                            <a href="#" style="padding-right: 20px;" class="active">Select</a>
                            <a href="#" style="padding-right: 25px;">Add services</a>
                            <a href="#" style="padding-right: 25px;">Login</a>
                            <a href="#" style="padding-right: 29px;">Summary</a>
                            <a href="#" style="padding-right: 77px;">Confirmation</a>
                        </div>
                        <br />
                        <div class="flotright">
                            <a href="<%=cutURL + "&cu=En-gb" %>" title="English">
                                <img src="img/en.png" alt="en" class="lngimg" /></a> <a href="<%=cutURL + "&cu=de-DE" %>" title="German">
                                   
                                <img src="img/gr.png" alt="gr" class="lngimg" /></a> <a href="<%=cutURL + "&cu=FR-FR" %>" title="French">
                                       
                                <img src="img/fr.png" alt="fr" class="lngimg" /></a> <a href="<%=cutURL + "&cu=IT-IT" %>" title="Italian">
                                           
                                <img src="img/ie.png" alt="ie" class="lngimg" /></a> <a href="<%=cutURL + "&cu=es-es" %>" title="Spanish">
                                    
                                <img src="img/es.png" alt="es" class="lngimg" /></a>

                        </div>
                      <ContentTemplate>
                      <asp:UpdatePanel/>
&#13;
&#13;
&#13;

我的代码

public void getxmldata()--> this function i call the map from code behind
{
    try
    {
        getsesiondata();
        LangID = 4;

        strRes = Ag.AVSearch_PropertyDetails(int.Parse(Request["Hid"].ToString()), dateArrival, dateDeparture, intPersons, int.Parse(drp_child.SelectedValue), intRooms, LangID, true, strRateFilter, "", strRateFilter, intMinRate, intMaxRate, strCurrency);
        GetData(strRes);
    }
    catch
    {

    }

}

1 个答案:

答案 0 :(得分:0)

我认为你应该先修改这些代码:

<强>之前

<ContentTemplate>
<asp:UpdatePanel/>

<强>后

</ContentTemplate>
</asp:UpdatePanel>