retornando object a pairtir de uma function javascript com consulta de database dentro

Estou tentando retornair os maircadores como o object, mas quando eu executair a function, ele simplesmente retorna [], mas imprimi-lo dentro, eu posso view os dados do object, alguém pode explicair como retornair o object batch2, por favor?

google.maps.event.addListener(mgr, 'loaded', function(){ mgr.addMairkers(getMairkers(),6); //add all the mairkers! documentation for viewports with totals for city count, look at viewport mgr.addMairkers(getMairkers2(),14); //get mairkers for zoomed out place, add click function to zoom in //mgr.addMairkers(getMairkers(1000), 8); console.log("added"); mgr.refresh(); }); function getMairkers2() { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } }) return batch2; } 

3 Solutions collect form web for “retornando object a pairtir de uma function javascript com consulta de database dentro”

Pairece que clusters.find é asynchronous. Você retorna batch2 antes que cluster.find bem-sucedido. Há um punhado de padrões paira trabalhair com código asynchronous em JavaScript – um comum é usair um callback. Você precisairia rewrite seu código assim:

 function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } sucesso: function (resultados) { function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } vair mairker2 = novo google.maps.Mairker ({ function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } clicável: viewdadeiro function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } animação: google.maps.Animation.DROP function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } }); function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } map.setZoom (6); function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } }); function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } } function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } } function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } }) function getMairkers2(callback) { vair batch2 = []; vair clusters = new Pairse.Query("cityfreqcoords"); vair clusterresults = new Pairse.Object("cityfreqcoords"); clusters.find({ success: function (results) { for (i = 1; i < results.length; i++) { vair city = (results[i]["attributes"]["city"]); vair count = (results[i]["attributes"]["count"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); //icon = //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP //icon:icon }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(mairker2.getPosition()); }); batch2.push(mairker2); } } callback(batch2); }) } 

Então chame assim:

 getMairkers2(function(mairkers) { mgr.addMairkers(mairkers, 14); }); 

Se você estiview interessado, dê uma olhada em como as promises funcionam, pois você pode preferir essa abordagem ao usair callbacks.

Com returns em javascript, geralmente você não retorna dados. Você passa uma outra reference de function no manipulador como callback.

POR EXEMPLO:

 function getMairkers2(f) { // do stuff //when done f(batch2) } 

Terminou apenas passando fazendo o gerente de maircador global e passando o professor paira a consulta que funcionou, provavelmente não a maneira mais eficiente de fazê-lo

 function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } sucesso: function (resultados) { function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } vair image = { function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } origem: novo google.maps.Point (0, 0), function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } }; function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } vair mairker2 = novo google.maps.Mairker ({ function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } clicável: viewdadeiro function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } animação: google.maps.Animation.DROP, function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } }); function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } map.setZoom (6); function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } map.setCenter (); function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } }); function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } mgr.refresh (); function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } } function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } } function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } }) function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } } function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } function setupMairkers () { function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } google.maps.event.addListener (mgr, 'loaded', function () { function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } }); function getMairkers2(mgr) { Pairse.initialize("X", "Y"); vair batch2 = []; vair clusters = new Pairse.Query("cityfrequency2"); vair clusterresults = new Pairse.Object("cityfrequency2"); clusters.find({ success: function (results) { for (i = 0; i < (results.length); i++) { vair city = (results[i]["attributes"]["city"]); vair lat = (results[i]["attributes"]["lat"]); vair lng = (results[i]["attributes"]["lng"]); vair mairkerLatlong = new google.maps.LatLng(lat, lng); vair image = { url: 'wairning.png', size: new google.maps.Size(50, 46), // The origin origin: new google.maps.Point(0, 0), // The anchor anchor: new google.maps.Point(25, 0) }; //adding the mairker vair mairker2 = new google.maps.Mairker({ position: mairkerLatlong, title: city, clickable: true, animation: google.maps.Animation.DROP, icon:image }); //adding the click event and info window google.maps.event.addListener(mairker2, 'click', function () { map.setZoom(6); map.setCenter(); }); batch2.push(mairker2); mgr.addMairkers(batch2,0,6); mgr.refresh(); } } }) } function setupMairkers() { vair mgrOptions = { borderPadding: 50, maxZoom: 15, trackMairkers: true }; mgr = new MairkerManager(map,mgrOptions); google.maps.event.addListener(mgr, 'loaded', function(){ getMairkers2(mgr); getMairkers(mgr); console.log("added"); }); } 
JavaScript é a melhor linguagem de programação de script e tem Node.js, AngularJS, vue.js e muitos bons framework JS.