萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> js實現googleMap中虛線的繪制方法

js實現googleMap中虛線的繪制方法

function drawPrePath(array,color){
  
  var sorrow={
  path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW //arrow
  };
  var lineSymbol = {
  path: 'M 0,-1 0,1',
  strokeOpacity: 1,
  scale: 3
  };
  var pathCoord = [
  new google.maps.LatLng(37.772323, -122.214897),new google.maps.LatLng(21.291982, -157.821856),
  new google.maps.LatLng(-18.142599, 178.431),new google.maps.LatLng(-27.46758, 153.027892)
  ];
  path = new google.maps.Polyline({
  path: pathCoord ,
  strokeColor:"#2d2d2d",
  strokeOpacity: 0,
  strokeWeight: 2,
  icons:[{icon:lineSymbol,offset: '0',repeat: '20px'}],
  map:map
  });
  path.setMap(map);
}
  var lineSymbol = {path: 'M 0,-1 0,1',strokeOpacity: 1,scale: 3};
關鍵在於’M 0,-1 0,1’ 其實這是SVG的繪制路徑的寫法,具體什麼意思我還解釋不清楚。嘻嘻 自己學svg教程吧!  
copyright © 萬盛學電腦網 all rights reserved