ASP.NET Google Maps Javascript API V3 实战基础篇一样式化地图

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MapType_Style_Sample.aspx.cs"
    Inherits="Samples.Overlays.MapType_Style_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>

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

    <script language="javascript" type="text/javascript">

        var map;
        var brooklyn = new google.maps.LatLng(40.6743890, -73.9455);
        function initialize() {
            //将道路更改为黄色,住宅区更改为褐色
            var stylez = [
            { featureType: "road.local", elementType: "geometry", stylers: [{ hue: "#f0000" },
             { saturation: 100}]
            },

             { featureType: "landscape", elementType: "geometry", stylers: [{ hue: "#000000" }, { saturation: 75 },
              { lightness: -100}]
             }
            ];
            var Options = { zoom: 11, center: brooklyn };
            map = new google.maps.Map(document.getElementById("maps"), Options);
            var styledMapOptions = {
                map: map, name: "Hip-Hop"
            }
            //实例化样式器对象
            var jayzMapType = new google.maps.StyledMapType(stylez, styledMapOptions);
            //设置地图样式器
            map.mapTypes.set("hiphop", jayzMapType);
            //设置地图样式
            map.setMapTypeId("hiphop");
        }
        //将地图初始化函数绑定window的load事件
        google.maps.event.addDomListener(window, "load", initialize);
    </script>

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值