Note that there are some explanatory texts on larger screens.

plurals
  1. PO2nd marker & map.fitBounds() with jquery mobile causing huge zoom out
    primarykey
    data
    text
    <p>I am using the jQuery 1.7 and the latest jQuery Mobile along with Google Maps Places library. </p> <p>I am facing a problem similar to <a href="https://stackoverflow.com/questions/10030760/jquery-ui-map-fit-bounds-with-a-polyline">this</a> question on polylines, except that I am not using (and if possible, would prefer to not use) any plugins. </p> <p>Clicking a button on one page populates the map on another page in the same document. </p> <p>I am trying to display all my search results as legibly and zoomed-in as possible by making use of the below code snippet..</p> <pre><code>var bounds = new google.maps.LatLngBounds(); for(var i=0; i&lt;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); } </code></pre> <p>My problem is a result of the last line above! </p> <p>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.. </p> <p>This zooming out does not happen for the same code when </p> <ul> <li><p>not using jQuery Mobile!!</p></li> <li><p>the map is on the same page as the Search button that populates the map with the markers</p></li> </ul> <p>Any help or pointers is very much appreciated..</p> <p>Thanks in advance..</p> <p>Regards,</p> <p>Achu</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload