GoogleMap API 入门 —— 画图和线条

画图和线条分别用Polygon和Polyline,过程如下

1.定义一个画图信息相关的对象,这个对象画图和画线条都是可以应用的

GoogleMap API 入门 —— 画图和线条
1 var polyOption = 
2 {
3     paths: [],
4     strokeColor: "#FF0000",
5     strokeOpacity: 0.8,
6     strokeWeight: 2,
7     fillColor: "#FF0000",
8     fillOpacity: 0.35
9 }
GoogleMap API 入门 —— 画图和线条

 

2.画多边形,这里有两种画法

  • 可以先setMap,然后setPath
  • 可以直接,设置Path参数,然背后setMap
GoogleMap API 入门 —— 画图和线条
1 var bermudaTriangle = new google.maps.Polygon( polyOption );
2 bermudaTriangle.setMap(map);
3 bermudaTriangle.setPath( triangleCoords )
GoogleMap API 入门 —— 画图和线条

 

3.画线条,一样

GoogleMap API 入门 —— 画图和线条
1 var lineArea = new google.maps.Polyline( polyOption );
2 lineArea.setMap(map);
3 lineArea.setPath( triangleCoords )
GoogleMap API 入门 —— 画图和线条

 

GoogleMap API 入门 —— 画图和线条,布布扣,bubuko.com

GoogleMap API 入门 —— 画图和线条

上一篇:linux X window system


下一篇:MDT2012部署问题,Windows is loading file