Reputation: 107
I am getting location details from database as a json response and values are coming correctly but my problem is the alignment of content string getting error like unterminated string literal ...
then i am displaying this details in google map info window..
var contentString = "<div><h4>Start Location : "+ locations[i].start_loc + "</h4>
<h4> Driver Name : "+ locations[i].driver_name + "</h4>
<h4> Driver Mob No : "+ locations[i].mob_num + "</h4>
<h4> Passenger Name : "+locations[i].passenger_name + "</h4>
<h4> Passenger Mob No : "+locations[i].mob_no + "</h4>
<h4> Cab Reg No : "+ locations[i].cab_reg_no + "</h4></div>";
infowindow.setContent(start_contentString);
infowindow.open(start_map, start_marker);
Please help me anyone....
Upvotes: 0
Views: 256
Reputation: 3854
Answer just to show alternative multiline...
var contentString = "<div><h4>Start Location : "+ test + "</h4>" +
"<h4> Driver Name : "+ locations[i].driver_name + "</h4>" +
"<h4> Driver Mob No : "+ locations[i].mob_num + "</h4>" +
"<h4> Passenger Name : "+locations[i].passenger_name + "</h4>" +
"<h4> Passenger Mob No : "+locations[i].mob_no + "</h4>" +
"<h4> Cab Reg No : "+ locations[i].cab_reg_no + "</h4></div>";
Upvotes: 0
Reputation: 5039
Just add \
after every line:
var contentString = "<div><h4>Start Location : "+ test + "</h4> \
<h4> Driver Name : "+ locations[i].driver_name + "</h4> \
<h4> Driver Mob No : "+ locations[i].mob_num + "</h4> \
<h4> Passenger Name : "+locations[i].passenger_name + "</h4> \
<h4> Passenger Mob No : "+locations[i].mob_no + "</h4> \
<h4> Cab Reg No : "+ locations[i].cab_reg_no + "</h4></div>";
Upvotes: 2