ASP.NET Google Maps Javascript API V3 实战基础篇一复杂图标

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

<!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>

    <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 Options = {
                zoom: 10, center: new google.maps.LatLng(-33.9, 151.2), mapTypeId: google.maps.MapTypeId.ROADMAP
            }
            var map = new google.maps.Map(document.getElementById("maps"), Options);
            setMarkers(map, beaches);
        }
        //图标数据对象数组
        var beaches = [
        ['Bondi Beach', -33.890542, 151.273856, 4],
        ['Coogee Beach', -33.923036, 151.25902, 5],
        ['Cronulla Beach', -34.028249, 151.157507, 3],
        ['Manly Beach', -33.80010128657071, 151.2874782854187, 2],
        ['Maroubra Beach', -33.950198, 151.259302, 1]
        ];
        //创建并设置图标
        function setMarkers(map, locations) {
            //创建图标
            var image = new google.maps.MarkerImage(
             "../images/nei_24.gif",
             new google.maps.Size(20, 32),
             new google.maps.Point(0, 0),
               new google.maps.Point(0, 32)
             );
            //创建阴影图标
            var shadow = new google.maps.MarkerImage(
            "../images/china.png",
            new google.maps.Size(300, 320),
            new google.maps.Point(0, 0),
            new google.maps.Point(0, 32)
            );
            //外形
            var shape = { coord: [1, 1, 1, 20, 18, 20, 18, 1],
                type: "poly"
            };
            //遍历图标数据数组,创建图标
            for (var i = 0; i < locations.length; i++) {
                var beach = locations[i];
                var LatLng = new google.maps.LatLng(beach[1], beach[2]);
                var marker = new google.maps.Marker(
                {
                    position: LatLng, map: map, shadow: shadow, icon: image, shape: shape, title: beach[0], zIndex: beach[3]
                }
                );
            }
        }
        //将地图初始化函数绑定到window的load事件
        google.maps.event.addDomListener(window, "load", initialize);
        
    </script>

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值