javascript - Parse JSON and add markers to google map -
i trying parse json data , transform google map markers, problem still getting error:
unexpected non-whitespace character after json data
function initialize() { var mylatlng = new google.maps.latlng(-35.889050,-64.735108); var mapoptions = { zoom: 4, center: mylatlng, maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(document.getelementbyid('map_canvas'), mapoptions); var jsonarch = '{ "codigo" : "3127" , "nombre" : "name" , "zona" : "3127" , "geox" : "-58.443597" , "geoy" : "-34.807164" },{ "codigo" : "3128" , "nombre" : "name" , "zona" : "3128" , "geox" : "-58.488797" , "geoy" : "-34.576852" },{ "codigo" : "3124" , "nombre" : "name" , "zona" : "3124" , "geox" : "00.000000" , "geoy" : "00.000000" }'; var archijason = jquery.parsejson(jsonarch); /*jquery.parsejson(jsonarch, function(json1) {*/ jquery.each( archijason, function(key, data) { var latlng = new google.maps.latlng(parsefloat(data.geox), parsefloat(data.geoy)); // creating marker , putting on map var marker = new google.maps.marker({ position: latlng, map: map, title: data.nombre }); marker.setmap(map); }); /*});*/ } google.maps.event.adddomlistener(window, 'load', initialize);
the map visible, not load markers...
this json data:
'{ "codigo" : "3127" , "nombre" : "name" , "zona" : "3127" , "geox" : "-58.443597" , "geoy" : "-34.807164" },{ "codigo" : "3128" , "nombre" : "name" , "zona" : "3128" , "geox" : "-58.488797" , "geoy" : "-34.576852" },{ "codigo" : "3124" , "nombre" : "name" , "zona" : "3124" , "geox" : "00.000000" , "geoy" : "00.000000" }'
thank much, appreciated, matters me.
Comments
Post a Comment