google地图--运动轨迹(自己上班的运动轨迹)

本文介绍如何使用Google地图API在网页上绘制指定轨迹的方法。通过设置地图的缩放级别、中心位置及路线的颜色、透明度和宽度等属性,实现对特定路径的可视化展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!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>google地图 ——轨迹</title>
    <script type="text/javascript" src="js?sensor=false"></script>
    <script type="text/javascript">
        function initialize() {
            var myOptions = {
                zoom: 16,
                center: new google.maps.LatLng(39.964556,116.274834),
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
            // 这里填上轨迹的经纬坐标,或者ajax从后台读取
	    // 坐标做好是在路口的,不然画线不在路上。
            var trackPoints = [
                new google.maps.LatLng(39.964556,116.274834),
                new google.maps.LatLng(39.956662,116.275735),
                new google.maps.LatLng(39.957221,116.284447),
                new google.maps.LatLng(39.95834,116.29406),
                new google.maps.LatLng(39.959326,116.29951),
		new google.maps.LatLng(39.960083,116.303029),
		new google.maps.LatLng(39.96209,116.307793)
            ];
            
            var trackPath = new google.maps.Polyline({
                path: trackPoints,
                strokeColor: "#FF0000", // 线条颜色
                strokeOpacity: 1.0, // 线条透明度
                strokeWeight: 2 // 线条粗细
            });

            trackPath.setMap(map);
        }
</script>
</head>
<body οnlοad="initialize()">
    <form id="form1" runat="server">
    <div id="map_canvas" style="width:1000px; height:700px;"></div>
    </form>
</body>
</html>
运行效果:

评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值