I have got the code:
$(document).ready(function() {
var adress = [];
var locations = ' [';
$('.office p').each(function(el) {
adress[el] = $(this).text();
locations = locations + '{address:\''+adress[el]+'\', data: \'0\', options:{icon: "http://selectner.com/img/bullet.png"}},';
});
locations = locations + ']';
console.log(locations);
$('#tablink').click(function (e) {
$('#map').gmap3({
map:{
options:{
center:[51.4675954,0.048876],
zoom: 2,
scrollwheel: true,
draggable: true,
}
},
marker:{
values : locations,
options:{
draggable: true
},
events:{
}
}
});
});
});
If I will copy console.log results and paste it into JSON (in gmap3 function - locations place) - all will work, but now it is not working.
I think, that I must to use JSON.parse(), but it write error to me:
SyntaxError: JSON.parse: expected property name or '}' at line 1 column 3 of the JSON data
How I can solve this problem?
[{"address":'Toronto, SCARBOROUGH JUNCTIO', "data": '0', "options":{"icon": 'http://selectner.com/img/bullet.png'}},{"address":'Moscow, tverskaya street, 18', "data": '0', "options":{"icon": 'http://selectner.com/img/bullet.png'}},{"address":'Leipzig, SÜDVORSTADT', "data": '0', "options":{"icon": 'http://selectner.com/img/bullet.png'}},]