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 7497523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:07:55+00:00 2026-05-29T19:07:55+00:00

In this JSON-P callback I’m trying to extend the object called bounds (declared earlier)

  • 0

In this JSON-P callback I’m trying to extend the object called bounds (declared earlier) by each downloaded marker in the iteration. In the log, it does get set as a bounds object, but the NE SW are the same:

ie
$: de
b: 18.031393699999967
d: 18.031393699999967
__proto__: de
Y: he
b: 59.2933167
d: 59.2933167
__proto__: he
__proto__: ie

Why?? This is driving me insane..

addStoreMarkers: function(data) {
            /** This is the function that the injected script automatically calls, it passes the markers data in the form 
                JSON (an array object) as an argument. **/

                //iterate over each instance in the data
                for (var i in data.markers) {

                    //set marker icon
                    var image = new google.maps.MarkerImage('images/'+ data.markers[i].icon  +'.png',
                        new google.maps.Size(32.0, 37.0),
                        new google.maps.Point(0, 0),
                        new google.maps.Point(16.0, 37.0)
                    );

                    //set icon shadow
                    var shadow = new google.maps.MarkerImage('images/shadow.png',
                        new google.maps.Size(51.0, 37.0),
                        new google.maps.Point(0, 0),
                        new google.maps.Point(16.0, 35.0) 
                    );

                    //add markers to map
                    var marker = new google.maps.Marker({
                        position: new google.maps.LatLng(data.markers[i].lat, data.markers[i].lgt),
                        map: map,
                        visible: false,
                        icon: image,
                        shadow: shadow
                    });

                    //add marker to markers array   
                    markers.push(marker);

                    //create the bounds representing all downloaded markers
                    bounds = new google.maps.LatLngBounds();
                    bounds.extend(marker.position);

                    //store infoBox data in markers array
                    markers[i].store = data.markers[i].store;
                    markers[i].distance = data.markers[i].distance;
                    markers[i].i = i;

                    //add click-listener to marker
                    google.maps.event.addListener(markers[i], 'click', function() {
                        //on click
                            //set parameter active (so it won't hide)
                            Map.setMarkerActive(this);
                            //call todisplay custom infoWindow function
                            Map.displayInfo(this);
                    });

                }

                console.log(bounds);

                //fitbounds if requested, else pan a bit to call updateView
                if(first){Map.fitBounds(5);first=false;} else {map.panBy(1,1);}

                //remove data from the DOM
                ejectDOM('#jsonp_ref');

                //notify
                Menu.setStatus('Klart!');

                //housekeeping
                delete data;

                console.log('add markers function complete ' + markers.length);
        },
  • 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-29T19:07:56+00:00Added an answer on May 29, 2026 at 7:07 pm
    //create the bounds representing all downloaded markers
    bounds = new google.maps.LatLngBounds();
    bounds.extend(marker.position);
    

    You are creating an new bounds for each marker. You should create the bounds outside of the for loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understand how to build a JSON object in JavaScript. This JSON
I am trying to make an ajax json callback using a .net application. So
I'm trying to get a json/xml callback of all tweets for user 'zapallpeople' or
I have a web page that returns this JSON when called: [{id:53,desc:Roberts}] I am
I'm trying to grab a dictionary object which is converted to json object in
$.post('testeUpdate.php', 'autocomplete', function(dadosResposta) { $('#ns-nome').val(dadosResposta.nsName); $('#ns-endereco').val(dadosResposta.nsAddress); }, json); I'm trying to understand this. So,
I'm getting this json string info from the server : {members:[[sd2840d,Johny],[jkld341,Marry]]} So I store
I have this JSON (which validates according to JSONLint ): [ { "BugCount":"2", "BugTitle":"C:\\INETPUB\\WWWROOT\\CLUBREADY2\\TRAINERS\\../Connections/LTC.asp",
How can I loop through this json data without referring to the data items
I have a web service that queries data from this json file, but I

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.