1
폴리 라인에 좌표를 추가하려고하지만 작동하지 않습니다. 하지만 수동으로 할당하면 작동합니다.Google지도 API는 PolyLine을 배열에서 설정할 수 없습니다.
배열별로 작업하는 방법.
var lat=[13.698090113461573,13.72771754374393,13.732881766645967,13.737967711523885];
var lng=[100.75223565101624,100.74861466884613,100.69132804870605,100.56249350309372];
// HERE IT DOESN"T WORK
var poly = new Array();
for (var j=0;j<lat.length;j++){
var pos = new google.maps.LatLng(lat[0],lng[0])
poly.push(pos);
}
// HERE IT'S WORK
var poly = [
new google.maps.LatLng(lat[0], lng[0]),
new google.maps.LatLng(lat[1], lng[1]),
new google.maps.LatLng(lat[2], lng[2]),
new google.maps.LatLng(lat[3], lng[3])
];
console.log(poly);
var Path = new google.maps.Polyline({
path: poly,
geodesic: true,
strokeColor: '#ff004c',
strokeOpacity: 1.0,
strokeWeight: 5
});
Path.setMap(map);
오처럼! 고맙습니다. 알았다. 바보 같은 질문에 대한 미안. –
@Supasit Suebsunthorn, 여러분 환영합니다. 아무에게도 일어날 수 있다고 걱정하지 마십시오. –
@Supasit Suebsunthorn 그건 그렇고, 당신의 질문에 답하면 해결할 수 있습니까? –