使用Javascript& amp;在Google地图中添加InfoWindow和多个标记ASP.NET

时间:2014-04-23 13:41:52

标签: c# javascript asp.net google-maps google-maps-api-3

请帮我创建一个显示多个标记和信息窗口的网页。尝试了所有内容,但仍未达到预期效果。

以下是我的代码:

// <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Multiple_Marker.cs" Inherits="WebApplication7.Multiple_Marker" %>

!DOCTYPE html>
html lang="en">
head>
meta charset="utf-8">
title>Multiple Marker</title>

    <link rel="shortcut icon" href="images/TTS.png" />
    <link href="styles/imagesliderTTSstyle.css" rel="stylesheet" type="text/css" />
    <script src="scripts/imageslider.js" type="text/javascript"></script>
    <link href="styles/TTStyle.css" type="text/css" rel="stylesheet"/>

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

        var map;
        function initialize() {
           //var markerIcon = "images/marker.gif";
           var myLatlng = new google.maps.LatLng(<%=Session["lat"]%>, <%=Session["long"]%>);
        var mapOptions = {
            zoom: 11,
            center: myLatlng
        }
        map = new google.maps.Map(document.getElementById("mapdiv"), mapOptions);

        // To add the marker to the map, use the 'map' property
            var marker = new google.maps.Marker({
                position: myLatlng,
                map: map,
                title: "Marker" //Even this title isn't showing up
            });
        }
        google.maps.event.addDomListener(window, 'load', initialize);    


    </script>

    </head>
<body>
    <div class="mapheader">     
        <div class = "mapheaderimg">
            <img src="images/logo.png" alt="Logo" height="80px"/>
        </div>
        <li class="note">
            <div>
                Welcome, <asp:Label ID="lblWelcomeUser" runat="server"/>
            </div>
        </li>
        <li class="logout">
            <div>
                <a href="index.aspx" style="color: #FFFFFF; text-decoration: none">Logout</a>
            </div>
        </li>
    </div>
    <div class="mapcontainer">
        <form id="form2" runat="server" >
        <asp:ScriptManager ID="timerScriptManager" runat="server"></asp:ScriptManager>
        <asp:Timer ID="timerControl" runat="server" Interval="120000" OnTick="timerControl_Tick"></asp:Timer>
            <div class="vehicledetails">
                    <li class="details">DETAILS:</li>
                    <li class="details">
                    <asp:Label ID="lblNumberDetails" runat="server" Text="Vehicle Number: " Font-Size="Small" Font-Bold="true"/>
                        <asp:DropDownList ID="ddlList" runat="server" AutoPostBack="true" 
                            Font-Size="Small" 
                            OnSelectedIndexChanged="ddlList_SelectedIndexChanged" 
                            Height="18px" />
                    </li>

                    <li class="details">
                    <asp:Label ID="lblSparkDetails" runat="server" Text="Spark: " Font-Size="Small" Font-Bold="true"/>
                    <asp:Label ID="lblSparkDetails" runat="server" Font-Size="Small" Font-Bold="false"/>
                    </li>

                    <li class="details">
                    <asp:Label ID="lblLatestUpdateDetails" runat="server" Text="Latest Update: " Font-Bold="true" Font-Size="Small" />
                    <asp:Label ID="lblTimeStampDetail" runat="server" Font-Size="Small" Font-Bold="false"/>
                    </li>

                    <li class="details">
                    <asp:Label ID="lblHistoryDetails" runat="server" Text="History: " Font-Bold="true" Font-Size="Small" />
                    <asp:DropDownList ID="ddlHistoryList" runat="server" AutoPostBack="true" 
                            OnSelectedIndexChanged="ddlList_SelectedIndexChanged" />
                    </li>
            </div>
        </form>
        <br />
            <div id="mapdiv" style = "height:31em; width: 100%"></div>
     </div>

    <div class="clear"></div><br />
    <div class="footer">
        <p>Copyright.</p>
    </div>  
</body>
</html>

我想我错过了某些内容或我的代码不正确? 甚至标记也没有显示标题。这是我的代码问题还是我必须添加更多的功能或对象来纠正它。

请大家......任何可以帮助我的人,非常感谢。 提前谢谢!

-Sohail

0 个答案:

没有答案