i'm trying dynamically add markers google maps using gmap3 plugin. in code below when pass variable _addresslist .gmap(), shows 1 marker. exact, last marker shows {address: "100e 800n, 84321", data: "marker 4"}
// address sample format {address: "727e 800n, 84321", data: "marker 1"}, {address: "900e 800n, 84321", data: "marker 2"}, {address: "200e 800n, 84321", data: "marker 3"}, {address: "100e 800n, 84321", data: "marker 4"},
this ajax code. idea's i'm doing wrong?
$.ajax({type: "get", url: url, data: poststr, success: function(data) { var _add = new array(); var _data; (i = 0; < data.length; i++) { _data = '{address: "'+data[i][1]+'", data: "'+data[i][0]+'"}'; _add.push(_data); } //convert string json var _addresslist = eval("(" + _add + ")"); $("#map-canvas").gmap3({ marker:{ values: [ _addresslist ] } }); }, datatype: "json" }); }
could please provide link of page. anyway noticed json string not formatted. can validate @ http://jsonlint.com.
the keys should enclosed in double quotes
[ { "address": "727e 800n, 84321", "data": "marker 1" }, { "address": "900e 800n, 84321", "data": "marker 2" } ]
Comments
Post a Comment