json 데이터 추출때문에요
본문
var json_data = {"marker":[],"polyline":[{"type":"polyline","points":[{"x":126.64238506487754,"y":37.38201987788234},{"x":126.63991457267708,"y":37.37918317975657},{"x":126.64211693176131,"y":37.3766670085712},{"x":126.64424904723542,"y":37.379430562910365},{"x":126.64704477955764,"y":37.37554653200276}],"coordinate":"wgs84","options":{"strokeColor":"#ff0000","strokeWeight":3,"strokeStyle":"solid","strokeOpacity":1}},{"type":"polyline","points":[{"x":126.6423627396136,"y":37.38196574919992},{"x":126.64007350186715,"y":37.37900345957334},{"x":126.64186880445871,"y":37.37661219624543},{"x":126.6432839435615,"y":37.37818424822508},{"x":126.6456500710992,"y":37.37442509586208},{"x":126.64709002412901,"y":37.37552864660796}],"coordinate":"wgs84","options":{"strokeColor":"#0707f3","strokeWeight":3,"strokeStyle":"solid","strokeOpacity":1}}]}
여기에서 첫번째 x , y 값을 가져오려고 하는데 잘 안되네요 --;
json_data.points.x[0]; 이러면 될줄 알았는데.....
답변 3
크롬 개발자도구로 했을때는 문제 없는데요..
json_data 부분이 object 가 맞는지 확인해보셔야 할거같은데요.
console.log(json_data);
해서 찍어보세요.
json_data.polyline[0].points[0].x
이렇게 하셔야 할거같습니다.
console.log(json_data.polyline[0].points[0].x);
잘되네요.