ASP.NET Google Maps Javascript API V3 实战基础篇一信息窗口

来源:互联网 发布:chrome for mac下载 编辑:程序博客网 时间:2024/05/29 16:33

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Overlay_Infowindow_Sample.aspx.cs"
    Inherits="Samples.Overlays.Overlay_Infowindow_Sample" %>

<!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>
    <style type="text/css">
        #maps
        {
            height: 450px;
        }
    </style>
    <!-- 引用Google Maps API-->

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=zh-CN"></script>

    <script language="javascript" type="text/javascript">
        //地图初始化函数
        function initialize() {
            var LatLng = new google.maps.LatLng(-25.363882, 131.044922);
            var Options = {
                zoom: 4, center: LatLng, mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("maps"), Options);
            //信息内容
            var contentString = "<div id='content'>" +
           "<div id='siteNotice'>" + "</div>." +
           "<h1 id='firstHeading' class='firstHeading'>UIuru</h1>" +
           "<div id='bodyContent'>" + "<p><b>UIuru</b>,also referrred to as <b>Ayers Rock</b>,is a large" +
           "sandstone rock formation in the southern part of the" +
           "Northern Territory ,central Australia .It lies 335 km(208 mi)" +
           "south west of the nearest large town,Alice Springs:450km" +
           "(280 mi) by road.Kata Tjuta and UIuru are the two major" +
           "features of the UIuru - Kata Tjuta National Park .UIuru is" +
           "sacred to the Pitjanjatjara and Yankunytjatjara, the " +
           "Aboriginal people of the area.It has many springs,waterholes," +
           "rock caves and ancient paintings.UIuru is listed as a World" +
           "Heritage site.</p>" +
           "<p>Attribution:UIuru,<a href='http://en.wikipedia.org/w/index.php?title=UIuru&oldid=297882194'" +
           "http://en.wikipedia.org/w/index.php?title=UIuru</a>(last visited June 22,2009).</p>" +
           "</div>" + "</div>";
            //创建信息窗口对象
            var infowindow = new google.maps.InfoWindow({ content: contentString });
            //创建标记
            var marker = new google.maps.Marker({ position: LatLng, map: map, title: "UIuru (Ayers Rock)" });
            //将信息窗口绑定到标记的click事件,点击标记时,打开信息窗口
            google.maps.event.addListener(marker, "click", function() {
                infowindow.open(map, marker);
            });
        }
        //将地图初始化函数绑定到window的load事件
        google.maps.event.addDomListener(window, "load", initialize);
       
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="maps">
    </div>
    </form>
</body>
</html>