Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps API - Problems with class GLatLngBounds
    primarykey
    data
    text
    <p>I am having some trouble with the <a href="http://code.google.com/apis/maps/documentation/reference.html" rel="nofollow noreferrer">Google Maps API</a>. I have an array which holds a ojbect I created to store points.</p> <p>My array and class:</p> <pre><code>var tPoints = []; function tPoint(name) { var id = name; var points = []; var pointsCount = 0; ... this.getHeadPoint = function() { return points[pointsCount-1]; } } </code></pre> <p>tPoint holds an array of <a href="http://code.google.com/apis/maps/documentation/reference.html#GLatLng" rel="nofollow noreferrer">GLatLng</a> points. I want to write a function to return a <a href="http://code.google.com/apis/maps/documentation/reference.html#GLatLngBounds" rel="nofollow noreferrer">GLatLngBounds</a> object which is extended from the current map bounds to show all the HeadPoints.</p> <p>Heres what I have so far..</p> <pre><code>function getBounds() { var mBound = map.getBounds(); for (var i = 0; i &lt; tPoints.length; i++) { alert(mBound.getSouthWest().lat() + "," + mBound.getSouthWest().lng()); alert(mBound.getNorthEast().lat() + "," + mBound.getNorthEast().lng()); currPoint = trackMarkers[i].getHeadPoint(); if (!mBound.containsLatLng(currPoint)) { mBound.extend(currPoint); } } return mBound; } </code></pre> <p>Which returns these values for the alert. (Generally over the US)<br /></p> <blockquote> <p>"19.64258,NaN"<br /> "52.69636,NaN"<br /> "i=0"<br /> "19.64258,NaN"<br /> "52.69636,-117.20701"<br /> "i=1"<br /></p> </blockquote> <p>I don't know why I am getting NaN back. When I use the bounds to get a zoom level I think the NaN value is causing the map.getBoundsZoomLevel(bounds) to return 0 which is incorrect. Am I using <a href="http://code.google.com/apis/maps/documentation/reference.html#GLatLngBounds" rel="nofollow noreferrer">GLatLngBounds</a> incorrectly?</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.
    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