javascript - $.goMap plugin - Get markers function -


I have trouble with the goMap plugin for jquery I want to get all the markers on my map, however, When calling getMarkers () function, it returns an empty array.

I think that's something to do with Scopes?

I add markers by querying the database with an AJAX call.

  $ ("# canvas"). GoMap (Latitude: 44.230065, Longitude: - 76.50000, Zoom: 14, Maitrippe: 'Roadmap'}); Load_markers (); Function load_markers (query_url) {if (query_url == undefined) {query_url = '/ posts / get_markers'; } $ .getJSON (query_url, function (data) {$ .each (data, function) {var id = data [pair] ['post'] ['id']; $ .goMap.createMarker ({Latitude: Data [pair] ['post'] ['late'], longitude: data [pair] ['post'] ['lng'], dragable: incorrect, id: id, html: {AJAX: "posts / Ajax_show / "+ id, content: 'loading ...', popup: wrong}});});}); } Console.log (($ .GoMap.getMarkers ()));   

Thanks!

Try to print in the handler of the call GetJSON calls, otherwise you do not know if you are still Data is found up to. If right, issue of one time than the scope.

  $ GetJSON (query_url, function (data) {$ .each (data, function (pair) {var id = data [pair] ['post'] ['id']; $ .gom.catmark ({latitude: data [pair ] ['Post'] ['Let'], longitude: data [pair] ['post'] ['lng'], draggable: false, id: id, html: {ajax: "posts / ajax_show /" + id , Content: 'Loading ...', Popup: Incorrect}})}); console.log (($$ .getMarkers ());});    

Comments