I've been trying to use the jquery plugin gmap3 to grab a json array from a textbox, reformat it and set it to a variable so that I can use it as the values for the "marker:" property. I got the values to display in a paragraph but I get nothing when setting it to the Marker:values.
I've created a jsFiddle below.
http://jsfiddle.net/ryanverdel/FUmpF/
Any help would be great.
$(function(){
$("#test").gmap3();
$('#test-ok').click(function(){
//var addr = $('#test-address').val();
$("#display p").empty();
var coordinates = $("#geofenceCoords").val();
var jsonObj = jQuery.parseJSON(coordinates);
//if ( !addr || !addr.length ) return;
$("#test").gmap3({
getlatlng:{
//address:addr,
callback: function(results){
var markers=[];
$.each(jsonObj, function(i, item) {
$('#display p').append('{'+'latLng: '+'['+jsonObj[i].latitude+', '+jsonObj[i].longitude+']'+', options:{icon: "http://www.mindboxdesigns.com/test-images/map_marker.png"}'+'}'+',');
markers.push('{'+'latLng: '+'['+jsonObj[i].latitude+', '+jsonObj[i].longitude+']'+', options:{icon: "http://www.mindboxdesigns.com/test-images/map_marker.png"}'+'}'+',');
});
if ( !results ) return;
$(this).gmap3({
marker:{
//latLng:results[0].geometry.location,
values:markers,
map:{
center: true,
},
},
autofit:{},
});
}
}
});
});
$('#test-address').keypress(function(e){
if (e.keyCode == 13){
$('#test-ok').click();
}
});
});