<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>

[{'answer_id': 16655, 'author': 'Eric Z Beard', 'author_id': 1219, 'author_profile': 'https://Stackoverflow.com/users/1219', 'pm_score': 3, 'selected': True, 'text': '<p>Maybe a CLR stored procedure is what you are looking for.  These are generally used when you need to interact with the system in some way.</p>\n'}, {'answer_id': 16723, 'author': 'AdamSane', 'author_id': 805, 'author_profile': 'https://Stackoverflow.com/users/805', 'pm_score': 3, 'selected': False, 'text': '<p>You will have to mark the CLR as EXTERNAL_ACCESS in order to get access to the System.IO namespace, however as things go that is not a bad way to go about it. </p>\n\n<blockquote>\n  <p>SAFE is the default permission set, but it’s highly restrictive. With the SAFE setting, you can access only data from a local database to perform computational logic on that data.\n  EXTERNAL_ACCESS is the next step in the permissions hierarchy. This setting lets you access external resources such as the file system, Windows Event Viewer, and Web services. This type of resource access isn’t possible in SQL Server 2000 and earlier. This permission set also restricts operations such as pointer access that affect the robustness of your assembly.\n  The UNSAFE permission set assumes full trust of the assembly and thus imposes no "Code Access Security" limitations. This setting is comparable to the way extended stored procedures function—you assume all the code is safe. However, this setting does restrict the creation of unsafe assemblies to users who have sysadmin permissions. Microsoft recommends that you avoid creating unsafe assemblies as much as possible.</p>\n</blockquote>\n'}, {'answer_id': 18000, 'author': 'Paul G', 'author_id': 162, 'author_profile': 'https://Stackoverflow.com/users/162', 'pm_score': 2, 'selected': False, 'text': "<p>I still believe that a CLR procedure might be the best bet. So, I'm accepting that answer. However, either I'm not that bright or it's extremely difficult to implement. Our SQL Server service is running under a local account because, according to Mircosoft, that's the only way to get an iSeries linked server working from a 64-bit SQL Server 2005 instance. When we change the SQL Server service to run with a domain account, the xp_fileexist command works fine for files located on the network.</p>\n\n<p>I created this CLR stored procedure and built it with the permission level set to External and signed it:</p>\n\n<pre><code>using System;\nusing System.Data;\nusing System.Data.SqlClient;\nusing System.Data.SqlTypes;\nusing Microsoft.SqlServer.Server;\nusing System.Security.Principal;\n\npublic partial class StoredProcedures\n{\n    [Microsoft.SqlServer.Server.SqlProcedure]\n    public static void FileExists(SqlString fileName, out SqlInt32 returnValue)\n    {\n        WindowsImpersonationContext originalContext = null;\n\n        try\n        {\n            WindowsIdentity callerIdentity = SqlContext.WindowsIdentity;\n            originalContext = callerIdentity.Impersonate();\n\n            if (System.IO.File.Exists(Convert.ToString(fileName)))\n            {\n                returnValue = 1;\n            }\n            else\n            {\n                returnValue = 0;\n            }\n        }\n        catch (Exception)\n        {\n            returnValue = -1;\n        }\n        finally\n        {\n            if (originalContext != null)\n            {\n                originalContext.Undo();\n            }\n        }\n    }\n}\n</code></pre>\n\n<p>Then I ran these TSQL commands:</p>\n\n<pre><code>USE master\nGO\nCREATE ASYMMETRIC KEY FileUtilitiesKey FROM EXECUTABLE FILE = 'J:\\FileUtilities.dll' \nCREATE LOGIN CLRLogin FROM ASYMMETRIC KEY FileUtilitiesKey \nGRANT EXTERNAL ACCESS ASSEMBLY TO CLRLogin \nALTER DATABASE database SET TRUSTWORTHY ON;\n</code></pre>\n\n<p>Then I deployed CLR stored proc to my target database from Visual Studio and used this TSQL to execute from SSMS logged in with windows authentication:</p>\n\n<pre><code>DECLARE @i INT\n--EXEC FileExists '\\\\\\\\server\\\\share\\\\folder\\\\file.dat', @i OUT\nEXEC FileExists 'j:\\\\file.dat', @i OUT\nSELECT @i\n</code></pre>\n\n<p>Whether I try a local file or a network file, I always get a 0. I may try again later, but for now, I'm going to try to go down a different road. If anyone has some light to shed, it would be much appreciated.</p>\n"}]
['https://Stackoverflow.com/questions/16638', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1992/']