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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:11:48+00:00 2026-06-14T10:11:48+00:00

I am using the jQuery 1.7 and the latest jQuery Mobile along with Google

  • 0

I am using the jQuery 1.7 and the latest jQuery Mobile along with Google Maps Places library.

I am facing a problem similar to this question on polylines, except that I am not using (and if possible, would prefer to not use) any plugins.

Clicking a button on one page populates the map on another page in the same document.

I am trying to display all my search results as legibly and zoomed-in as possible by making use of the below code snippet..

var bounds = new google.maps.LatLngBounds();
for(var i=0; i<results.length; i++)
{
    var resCoOrds = new google.maps.LatLng(results[i].geometry.location.lat(), results[i].geometry.location.lng());
    var marker = new google.maps.Marker({
        position : resCoOrds, 
        map : myMap, 
        icon: myMarkerIcon
    });

    makerList.push(marker);

    google.maps.event.addListener(marker, 'click', function()
    {
        var resInfoWindow = new google.maps.InfoWindow({content:liContent});
        resInfoWindow.open(map, this);
    });


    bounds.extend(resCoOrds);
    myMap.fitBounds(bounds);
}

My problem is a result of the last line above!

Addition of the first marker works as expected, but on addition of the second marker, the map gets zoomed way out making all my search results appear together on a small dot on the map, forcing user to zoom in, which does not serve my purpose..

This zooming out does not happen for the same code when

  • not using jQuery Mobile!!

  • the map is on the same page as the Search button that populates the map with the markers

Any help or pointers is very much appreciated..

Thanks in advance..

Regards,

Achu

  • 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-06-14T10:11:50+00:00Added an answer on June 14, 2026 at 10:11 am

    Figured it out…

    Here is my solution : I noticed that the zoom issue is not present if the map is already loaded AND visible on the active page by the time I start adding the markers or call map.fitBounds(). So I used the map’s tilesloaded event to wait until the map is ready, and then add markers & fit bounds.

    Below is the code I used…

    function searchCallback(results, status) {
        if (status == google.maps.places.PlacesServiceStatus.OK) 
        {
            if (results.length) 
            {
                $.mobile.changePage("#mapview");
                google.maps.event.addListenerOnce(map, "tilesloaded", function()
                {
                    var bounds = new google.maps.LatLngBounds();
                    for ( var i = 0; i < results.length; i++) 
                    {
                        /* code to add markers */
                        bounds.extend(results[i].geometry.location);
                    }
                    map.fitBounds(bounds);
                }   
            }
         }
     }
    

    This approach solves my problem, but if anyone has a better solution, please do let me know..

    Thanks..

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

Sidebar

Related Questions

I'm having quite a peculiar problem with PhoneGap and JQuery Mobile, using the latest
Why is this selector not working? I'm using the latest version of JQuery Mobile
I am newbie using jquery mobile with php. I have a little problem on
Now i'm using jQuery library and i faced the folowing problem: Supppose i have
I am using jquery mobile latest version. I have a select field that actually
I am using jQuery(Latest release) and have a function called calculate() which gets called
I'm using the latest version of the jquery plugin DataTables and I tried to
I was using JQuery in this download link, and included it in the head
I am using jquery validation 1.9.0. I have used the latest Jquery and on
I am using latest Jquery and the following script: <script type=text/javascript> $(document).ready(function(){ var el

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.