<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: Bounding Box in Google Maps</title>
	<atom:link href="http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/</link>
	<description>A blog about web developement and usability.</description>
	<lastBuildDate>Fri, 30 Jul 2010 15:17:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Grapsus</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-15825</link>
		<dc:creator>Grapsus</dc:creator>
		<pubDate>Fri, 30 Jul 2010 15:17:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-15825</guid>
		<description>Here is an adaptation of this code I made for API v3 :
http://grapsus.net/blog/post/Google-API-v3-fit-map-zoom-and-bounds-to-all-markers</description>
		<content:encoded><![CDATA[<p>Here is an adaptation of this code I made for <acronym title="Application Programming Interface">API</acronym> v3 :<br />
<a href="http://grapsus.net/blog/post/Google-API-v3-fit-map-zoom-and-bounds-to-all-markers" rel="nofollow">http://grapsus.net/blog/post/Google-<acronym title="Application Programming Interface">API</acronym>-v3-fit-map-zoom-and-bounds-to-all-markers</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Toleti S</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-9880</link>
		<dc:creator>Toleti S</dc:creator>
		<pubDate>Tue, 17 Nov 2009 16:32:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-9880</guid>
		<description>We have an image with two points in the middle and the bound area in pixels only and two reference points in the image with their pixel coordinates.  We can get a zoom/scale for the image based on the above data.

We also know the latlng for the above two reference points.

How do I set the box north-east and south-west corners so that I can place it on the map.

Appreciate any help/pointers.

Thanks</description>
		<content:encoded><![CDATA[<p>We have an image with two points in the middle and the bound area in pixels only and two reference points in the image with their pixel coordinates.  We can get a zoom/scale for the image based on the above data.</p>
<p>We also know the latlng for the above two reference points.</p>
<p>How do I set the box north-east and south-west corners so that I can place it on the map.</p>
<p>Appreciate any help/pointers.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gopi</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-5146</link>
		<dc:creator>gopi</dc:creator>
		<pubDate>Fri, 05 Jun 2009 10:00:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-5146</guid>
		<description>Here This bounded rectangle is not working in all the cases 
when we move the map at some zoomlevel 
  
 NorthEast  (topRight)  points (70.495574, -102.304688) 
topRight[0] = 70.495574;
topRight[1]= -102.304688;

 SouthWest(BottomLeft) points (-59.712097, 47.109375)
BottomLeft[0] =-59.712097;

and my point is under this getBounds 

we have a condition like 

if(lat &gt;  bottomLeft[0]  and lat  BottomLeft[1] and lng &lt; TopRight[1])
{}
this condition falils in some points even though its under that Bounded Rectangle
 and the actual point is (30.145127,75.234)  between those top and bottom points</description>
		<content:encoded><![CDATA[<p>Here This bounded rectangle is not working in all the cases<br />
when we move the map at some zoomlevel </p>
<p> NorthEast  (topRight)  points (70.495574, -102.304688)<br />
topRight[0] = 70.495574;<br />
topRight[1]= -102.304688;</p>
<p> SouthWest(BottomLeft) points (-59.712097, 47.109375)<br />
BottomLeft[0] =-59.712097;</p>
<p>and my point is under this getBounds </p>
<p>we have a condition like </p>
<p>if(lat &gt;  bottomLeft[0]  and lat  BottomLeft[1] and lng &lt; TopRight[1])<br />
{}<br />
this condition falils in some points even though its under that Bounded Rectangle<br />
 and the actual point is (30.145127,75.234)  between those top and bottom points</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex O'Byrne</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-2073</link>
		<dc:creator>Alex O'Byrne</dc:creator>
		<pubDate>Sun, 22 Feb 2009 13:01:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-2073</guid>
		<description>OK that didn&#039;t post directly... I&#039;ll reformat it and post again later.</description>
		<content:encoded><![CDATA[<p>OK that didn&#8217;t post directly&#8230; I&#8217;ll reformat it and post again later.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex O'Byrne</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-2072</link>
		<dc:creator>Alex O'Byrne</dc:creator>
		<pubDate>Sun, 22 Feb 2009 12:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-2072</guid>
		<description>If you&#039;re getting the lat and long from a collection of Ruby objects. 

Here&#039;s the method:

  # returns a hash of top right and bottom left bounds
  def self.bounds(collection)
    top = 0
    bottom = 0
    right = 0
    left = 0
    initially_set = false
    collection.each do &#124;point&#124;
      if point.lat and point.long
        if !initially_set or point.long &gt; top
          top = point.long
        end
        if !initially_set or point.long  right
          right = point.lat
        end
        if !initially_set or point.lat &lt; left
          left = point.lat
        end
        initially_set = true
      end
    end
    # you could add 10% to each value here 
    # if your map is correct portioned (otherwise)
    # your centre will be skewed
    # now create the hash
    result = Hash.new
    result[:top] = top
    result[:bottom] = bottom
    result[:right] = right
    result[:left] = left
    return result
  end

And then in the map definition...


// if we have a collection of items, set the map to fit them all 
// Define the two corners of the bounding box  
var sw = new GLatLng(, );  
var ne = new GLatLng(, );  
var bounds = new GLatLngBounds(sw, ne);</description>
		<content:encoded><![CDATA[<p>If you&#8217;re getting the lat and long from a collection of Ruby objects. </p>
<p>Here&#8217;s the method:</p>
<p>  # returns a hash of top right and bottom left bounds<br />
  def self.bounds(collection)<br />
    top = 0<br />
    bottom = 0<br />
    right = 0<br />
    left = 0<br />
    initially_set = false<br />
    collection.each do |point|<br />
      if point.lat and point.long<br />
        if !initially_set or point.long &gt; top<br />
          top = point.long<br />
        end<br />
        if !initially_set or point.long  right<br />
          right = point.lat<br />
        end<br />
        if !initially_set or point.lat &lt; left<br />
          left = point.lat<br />
        end<br />
        initially_set = true<br />
      end<br />
    end<br />
    # you could add 10% to each value here<br />
    # if your map is correct portioned (otherwise)<br />
    # your centre will be skewed<br />
    # now create the hash<br />
    result = Hash.new<br />
    result[:top] = top<br />
    result[:bottom] = bottom<br />
    result[:right] = right<br />
    result[:left] = left<br />
    return result<br />
  end</p>
<p>And then in the map definition&#8230;</p>
<p>// if we have a collection of items, set the map to fit them all<br />
// Define the two corners of the bounding box<br />
var sw = new GLatLng(, );<br />
var ne = new GLatLng(, );<br />
var bounds = new GLatLngBounds(sw, ne);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Svennerberg</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1603</link>
		<dc:creator>Gabriel Svennerberg</dc:creator>
		<pubDate>Thu, 29 Jan 2009 13:59:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1603</guid>
		<description>&lt;strong&gt;&lt;em&gt;Aiska:&lt;/em&gt;&lt;/strong&gt; After looking at your code again it occurred to me that there&#039;s a problem in it and that is in how you extend the bound. You don&#039;t use the &lt;code&gt;new&lt;/code&gt; keyword when you create a new &lt;code&gt;GLatLng&lt;/code&gt;. It should be:

&lt;code&gt;bounds.extend(new GLatLng(lat, lng));&lt;/code&gt;

Maybe that&#039;s the reason it doesn&#039;t work properly?

I haven&#039;t looked at your new method yet.</description>
		<content:encoded><![CDATA[<p><strong><em>Aiska:</em></strong> After looking at your code again it occurred to me that there&#8217;s a problem in it and that is in how you extend the bound. You don&#8217;t use the <code>new</code> keyword when you create a new <code>GLatLng</code>. It should be:</p>
<p><code>bounds.extend(new GLatLng(lat, lng));</code></p>
<p>Maybe that&#8217;s the reason it doesn&#8217;t work properly?</p>
<p>I haven&#8217;t looked at your new method yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aiska</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1599</link>
		<dc:creator>Aiska</dc:creator>
		<pubDate>Thu, 29 Jan 2009 10:32:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1599</guid>
		<description>&lt;strong&gt;Gabriel Svennerberg:&lt;/strong&gt; yeah that&#039;s right maybe this is bugs in API.

I found new method how to set zoom level of a google map base on markers.

maybe you can check this out for your reference. Thanks

&lt;a href=&quot;http://aiskahendra.blogspot.com/2009/01/set-zoom-level-of-google-map-base-on.html&quot; title=&quot;http://aiskahendra.blogspot.com/2009/01/set-zoom-level-of-google-map-base-on.html&quot; rel=&quot;nofollow&quot;&gt;Set zoom level of a google map base on markers&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p><strong>Gabriel Svennerberg:</strong> yeah that&#8217;s right maybe this is bugs in <acronym title="Application Programming Interface">API</acronym>.</p>
<p>I found new method how to set zoom level of a google map base on markers.</p>
<p>maybe you can check this out for your reference. Thanks</p>
<p><a href="http://aiskahendra.blogspot.com/2009/01/set-zoom-level-of-google-map-base-on.html" title="http://aiskahendra.blogspot.com/2009/01/set-zoom-level-of-google-map-base-on.html" rel="nofollow">Set zoom level of a google map base on markers</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Svennerberg</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1547</link>
		<dc:creator>Gabriel Svennerberg</dc:creator>
		<pubDate>Wed, 28 Jan 2009 12:28:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1547</guid>
		<description>&lt;strong&gt;&lt;em&gt;Aiska:&lt;/em&gt;&lt;/strong&gt; Cool! I never thought of that, but naturally that&#039;s one way to do it. Thanks!

I have never encountered the error you&#039;re talking about myself. Could be a bug in the API?</description>
		<content:encoded><![CDATA[<p><strong><em>Aiska:</em></strong> Cool! I never thought of that, but naturally that&#8217;s one way to do it. Thanks!</p>
<p>I have never encountered the error you&#8217;re talking about myself. Could be a bug in the <acronym title="Application Programming Interface">API</acronym>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aiska</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1546</link>
		<dc:creator>Aiska</dc:creator>
		<pubDate>Wed, 28 Jan 2009 11:52:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1546</guid>
		<description>Actually you don&#039;t have to Define the two corners of the bounding box because it can assign later by using extend.

&lt;code&gt;var bounds = new GLatLngBounds();
bounds.extend(GLatLng(lat:Number, lng:Number));&lt;/code&gt;

so you have to assign all marker by using this code 
&lt;code&gt;bounds.extend(GLatLng(lat:Number, lng:Number));&lt;/code&gt;

but sometimes the function of :
&lt;code&gt;map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));&lt;/code&gt;
didn&#039;t work properly and will returns an incorrect zoom level. until now i can&#039;t figure out this problem.</description>
		<content:encoded><![CDATA[<p>Actually you don&#8217;t have to Define the two corners of the bounding box because it can assign later by using extend.</p>
<p><code>var bounds = new GLatLngBounds();<br />
bounds.extend(GLatLng(lat:Number, lng:Number));</code></p>
<p>so you have to assign all marker by using this code<br />
<code>bounds.extend(GLatLng(lat:Number, lng:Number));</code></p>
<p>but sometimes the function of :<br />
<code>map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));</code><br />
didn&#8217;t work properly and will returns an incorrect zoom level. until now i can&#8217;t figure out this problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Svennerberg</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1425</link>
		<dc:creator>Gabriel Svennerberg</dc:creator>
		<pubDate>Mon, 19 Jan 2009 09:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1425</guid>
		<description>&lt;strong&gt;&lt;em&gt;Alan:&lt;/em&gt;&lt;/strong&gt; There are several ways to do it servers-side depending on which language you use. In a solution I&#039;m currently working on where we use C# and SQL Server 2008 I use the SqlGeometry object to handle GEO data. I get the data that I want to display on the map as a SqlGeometry object and on that object I then call the method STEnvelope() which returns a Bounding Box for the GEO data.

In the Google Maps API there&#039;s the &lt;code&gt;GLatLngBounds&lt;/code&gt; class which is  a representation of a BoundingBox. Some overlays such as &lt;code&gt;GPolyLine&lt;/code&gt; and &lt;code&gt;GPolygon&lt;/code&gt; has a &lt;code&gt;getBounds()&lt;/code&gt; method that returns a &lt;code&gt;GLatLngBounds&lt;/code&gt;. In the case of markers I don&#039;t know of any easy way to do it. I guess one have to do as you suggest and loop through them all to extract min and max values.</description>
		<content:encoded><![CDATA[<p><strong><em>Alan:</em></strong> There are several ways to do it servers-side depending on which language you use. In a solution I&#8217;m currently working on where we use C# and <acronym title="Structured Query Language">SQL</acronym> Server 2008 I use the SqlGeometry object to handle GEO data. I get the data that I want to display on the map as a SqlGeometry object and on that object I then call the method STEnvelope() which returns a Bounding Box for the GEO data.</p>
<p>In the Google Maps <acronym title="Application Programming Interface">API</acronym> there&#8217;s the <code>GLatLngBounds</code> class which is  a representation of a BoundingBox. Some overlays such as <code>GPolyLine</code> and <code>GPolygon</code> has a <code>getBounds()</code> method that returns a <code>GLatLngBounds</code>. In the case of markers I don&#8217;t know of any easy way to do it. I guess one have to do as you suggest and loop through them all to extract min and max values.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1354</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Fri, 16 Jan 2009 08:33:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1354</guid>
		<description>Can you explain a good way to determine the sw and ne from the data?

I can imagine doing a minimum and maximum loop thru all the data, but it seems like there should be an easier way to get via an api call of some sort.</description>
		<content:encoded><![CDATA[<p>Can you explain a good way to determine the sw and ne from the data?</p>
<p>I can imagine doing a minimum and maximum loop thru all the data, but it seems like there should be an easier way to get via an api call of some sort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabriel Svennerberg</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1321</link>
		<dc:creator>Gabriel Svennerberg</dc:creator>
		<pubDate>Thu, 15 Jan 2009 06:17:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1321</guid>
		<description>&lt;strong&gt;&lt;em&gt;Alan:&lt;/em&gt;&lt;/strong&gt; Yes that&#039;s right, but for the sake of simplicity in the example, I have explicitly defined the corners of the bounding box. In a real-world implementation I would naturally calculate sw and ne from the data that I&#039;m showing.</description>
		<content:encoded><![CDATA[<p><strong><em>Alan:</em></strong> Yes that&#8217;s right, but for the sake of simplicity in the example, I have explicitly defined the corners of the bounding box. In a real-world implementation I would naturally calculate sw and ne from the data that I&#8217;m showing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-1320</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Thu, 15 Jan 2009 04:11:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-1320</guid>
		<description>Wait a minute - where did you get the values for sw and ne from?  Wasn&#039;t the point of the article to show how to create a box around a _dynamic_ set of points?</description>
		<content:encoded><![CDATA[<p>Wait a minute &#8211; where did you get the values for sw and ne from?  Wasn&#8217;t the point of the article to show how to create a box around a _dynamic_ set of points?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mathias</title>
		<link>http://www.svennerberg.com/2008/11/bounding-box-in-google-maps/comment-page-1/#comment-641</link>
		<dc:creator>Mathias</dc:creator>
		<pubDate>Mon, 24 Nov 2008 02:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.svennerberg.com/?p=640#comment-641</guid>
		<description>Thank you so much I been looking for this for a looong time :)</description>
		<content:encoded><![CDATA[<p>Thank you so much I been looking for this for a looong time <img src='http://www.svennerberg.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
