Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6604843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:12:38+00:00 2026-05-25T19:12:38+00:00

I want to put markers on a map. The source is a json request,

  • 0

I want to put markers on a map. The source is a json request, which returns cities.

I’ve got a function (sencha) that returns the records (asynchronous) and a function (google maps api) that returns the lng, lat for specific cities (asynchronous) and a method (google maps), that puts markers on the map.

The result should be a marker on the map at the location calculated by google with a caption retrieved from the record.

load records

offers = App.stores.offers.load({
    callback: function(records, operation, success){...}
})

get location

geocoder = new google.maps.Geocoder();
geocoder.geocode(
  {'address': adress},
  function(results, status) {...}
}

and set the marker

marker = new google.maps.Marker({
  map: map,
  position: loc,
  title: text
});

What I wan’t to do is, load the record, loop over each record, find out about location of the city and put a marker there.

synchronous I would do:

   records = App.stores.offers.load();
   for (var i=0; i < records.length; i++) {
     setMarker( map, getLocation(records[i].data["city"]), cords[i].data["text"]);
   }

What’s the right way to put it together with the asynchronous functions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:12:39+00:00Added an answer on May 25, 2026 at 7:12 pm

    I don’t really know what does the App.stores.offers.load function do exactly but I’ll assume its callback function arguments contain loading results in records variable. In this case loop through records inside callback function and for each call geocode, and on geocode’s callback place markers (nothing wrong with this).

    EDIT: this is untested and probably not most efficient but should work:

    offers = App.stores.offers.load({
        callback: function(records, operation, success){
            if (success) {//or sth like this
                var complete;
                for (var i = 0; i < records.length; i++) {
                    complete = false;
                    geocoder.geocode( {'address': records[i].adress},
                      function(results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            map.setCenter(results[0].geometry.location);
                            var marker = new google.maps.Marker({
                                map: map,
                                title: results[i].text,
                                position: results[0].geometry.location
                            });
                        } else {
                            alert("Geocode was not successful for the following reason: " + status);
                        }
                        complete = true;
                    });
                    while (!complete);
                }
            }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a mapview that I want to put some markers on top of.
I've got a value type that I want put into a map. It has
I have a page layout for my MOSS '07 site that I want put
Created a google map with GMap2 and put pinpoints on there that open up
I want to put a pop-up on top of some markers in a MapView
I have put multiple markers on my map by click event and now I
code //array store the markers var googleMarker = []; //this function get json object
So I've got some scripts I've written which set up a Google map on
I've got the following setup, what I want to do is update the markers
I want to put a map in a web page where users will be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.