如何在Google地图上绘制Polyline [英] How to draw Polyline on Google Map

查看:181
本文介绍了如何在Google地图上绘制Polyline的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以指导我如何在自定义颜色的两个地理编码点之间绘制一条简单的多段线。 绘制 在两点之间使用下面的函数来传递地图和经纬度,并在第一点和第二点长。

  var mapOptions = {
zoom:zoom,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

map = new google.maps.Map(document.getElementById('map-canvas _'+ id),mapOptions);

函数poliLines(map,latPointBefore,lonPointBefore,latPointAfter,lonPointAfter){

var routes = [
new google.maps.LatLng(latPointBefore,lonPointBefore)
,new google.maps.LatLng(latPointAfter,lonPointAfter)
];
$ b var polyline = new google.maps.Polyline({
path:routes
,map:map
,strokeColor:'#ff0000'
, strokeWeight:5
,strokeOpacity:0.5
,clickable:false
});

}


Could some one point me how to draw a simple polyline between two geo coding point with custom color.

解决方案

To draw line between two points using the following function to which I pass the map and lat and long in the first point and second point.

var mapOptions = {
    zoom: zoom,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
};

map = new google.maps.Map(document.getElementById('map-canvas_'+id), mapOptions);    

function poliLines(map, latPointBefore, lonPointBefore, latPointAfter, lonPointAfter){

        var routes = [
          new google.maps.LatLng(latPointBefore, lonPointBefore)
          ,new google.maps.LatLng(latPointAfter, lonPointAfter)
        ];

        var polyline = new google.maps.Polyline({
           path: routes
           , map: map
           , strokeColor: '#ff0000'
           , strokeWeight: 5
           , strokeOpacity: 0.5
           , clickable: false
       });

}

这篇关于如何在Google地图上绘制Polyline的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆