• 高德地图-设置直线路线


    1、问题背景

         给点了地图上两个坐标,然后连接两个点,成为一条直线


    2、实现源码

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8" />
    		<meta http-equiv="X-UA-Compatible" content="IE=edge">
        	<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    		<title>高德地图-设置直线路线</title>
    		<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
        	<script src="http://webapi.amap.com/maps?v=1.3&key=c2eb520334ddc5ab2bb70a3afe6a58cc"></script>
        	<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
        	<style>
        		html,body{
        			 100%;
        			height: 100%;
        			font-family: "微软雅黑";
        			font-size: 12px;
        			font-feature-settings: normal;
        			font-size-adjust: initial;
        			font-stretch: extra-condensed;
        			font-synthesis: initial;
        		}
        		#lineMap{
        			 100%;
        			height: 100%;
        			font-size: 12px;
        			font-family: "arial, helvetica, sans-serif";
        		}
        	</style>
    	</head>
    	<body>
    		<div id="lineMap"></div>
    		<script>
    			//实例化和初始化地图
    			var map = new AMap.Map('lineMap', {
            		resizeEnable: true,
            		center: [114.295482,30.582582],
            		zoom: 14
        		});
        		
        		//选定两个坐标
        		var line = [
        			[114.254283,30.567507],
        			[114.328098,30.54489]
        		];
        		
        		//设置连接线样式
        		var polyline = new AMap.Polyline({
            		path: line,          //设置线覆盖物路径
            		strokeColor: "#FF0000", //线颜色
            		strokeOpacity: 0.8,       //线透明度
            		strokeWeight: 1,        //线宽
            		strokeStyle: "dashed",   //线样式
            		strokeDasharray: [10, 10] //补充线样式
        		});
        		
        		polyline.setMap(map);
    		</script>
    	</body>
    </html>
    

    3、实现结果


  • 相关阅读:
    WPF 如何画一颗心
    WPF 通过Border来画边框
    WPF 如何引入外部样式
    WPF 变量转换的实现
    WPF 动画显示控件
    wpf 悬浮窗口的实现
    WPF 如何绘制不规则按钮,并且有效点击范围也是不规则的
    WPF 变量绑定实现
    2016年终总结:从程序员到项目经理的转身
    使用FastReport打印二维码
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314176.html
Copyright © 2020-2023  润新知