Did you defined leg, lat and lgn ? Are you using this script in environment with EcmaScript6 (ES2015) or newer version of JavaScript ? If not, this script doesn’t work.
EcmaScript6 and newer :
var leg = "leg", lat = "lat", lgn = "lgn"
var waypoints_legs = [{leg,latlgn:{lat,lgn}}]
EcmaScript5 and older :
'use strict';
var leg = "leg", lat = "lat", lgn = "lgn";
var waypoints_legs = [{"leg":leg,"latlgn":{"lat":lat,"lgn":lgn}}];
0
solved JAVASCRIPT – How create empty Object