<?xml version="1.0" encoding="utf-8"?>
<!-- generator="Kukkaisvoima version 7" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel>
<title>vmx: OpenLayers</title>
<link>http://vmx.cx/cgi-bin/blog/index.cgi</link>
<description>Blog of Volker Mische</description>
<pubDate>Wed, 11 Nov 2009 12:25:35 +0200</pubDate>
<lastBuildDate>Wed, 11 Nov 2009 12:25:35 +0200</lastBuildDate>
<generator>http://23.fi/kukkaisvoima/</generator>
<language>en</language>
<item>
<title>Drag as long as you want
</title>
<link>http://vmx.cx/cgi-bin/blog/index.cgi/drag-as-long-as-want%3A2009-11-11%3Aen%2COpenLayers%2CJavaScript%2Cgeo</link>
<comments>http://vmx.cx/cgi-bin/blog/index.cgi/drag-as-long-as-want%3A2009-11-11%3Aen%2COpenLayers%2CJavaScript%2Cgeo#comments</comments>
<pubDate>Wed, 11 Nov 2009 12:25:35 +0200</pubDate>
<dc:creator>Volker Mische</dc:creator>
<category>en</category>
<category>OpenLayers</category>
<category>JavaScript</category>
<category>geo</category>
<guid isPermaLink="false">http://vmx.cx/cgi-bin/blog/index.cgi/drag-as-long-as-want%3A2009-11-11%3Aen%2COpenLayers%2CJavaScript%2Cgeo/</guid>
<description><![CDATA[ 
 [...]]]></description>
<content:encoded><![CDATA[

<p>It has been a very long outstanding bug (officially it was a missing
feature) in <a href="http://www.openlayers.org/">OpenLayers</a> that annoyed
me from the first time I’ve been using OpenLayers. I’m talking about
<a href="http://trac.openlayers.org/ticket/39">ticket #39</a>: “Allow
pan-dragging while outside map until mouseup”.
</p>
<p>Normally when you drag the map in OpenLayers it will stop dragging as soon
as you hit the edge of the map viewport (the <code>div</code> that contains
the map). Whenever you have a small map, but a huge window and a loooong way to
drag, it can get quite annoying, as the maximum distance you can drag at once
is the size of that viewport.
</p>
<p>But yesterday
<a href="http://openlayers.org/pipermail/commits/2009-November/009095.html">it
finally happend</a>. A patch to fix it landed in trunk. A first rough cut was
made at the
<a href="http://openlayers.org/blog/2009/10/26/openlayers-at-the-foss4g-code-sprint/">OpenLayers
code sprint at the FOSS4G</a>.
<a href="http://wiki.osgeo.org/wiki/User:Ahocevar">Andreas Hocevar</a> reviewed
the code and made a more unobtrusive version of it (thanks, again).
</p>
<p>Try these two examples to see the difference. Click on the map an drag it a
long way to the right and back to the left again (you might need to zoom it a bit to see the full effect):
<ul>
  <li><a href="http://openlayers.org/dev/examples/lite.html">default
behaviour</a></li>
  <li><a href="http://openlayers.org/dev/examples/document-drag.html">documentDrag behaviour</a></li>
</ul>
<p>As it is a new feature, it isn’t enabled by default (and only available on
current SVN trunk, it will be available in OpenLayers 2.9). To enable it on
 your map, just use the following code to add the <code>documentDrag</code>
parameter to the
<a href="http://dev.openlayers.org/docs/files/OpenLayers/Control/DragPan-js.html">DragPan control</a> (you obviously need a recent SVN checkout).
<p><strong>Update</strong> (2009-11-18): It got even easier with
<a href="http://openlayers.org/pipermail/commits/2009-November/009109.html">r9805</a>:
</p>
<p>
  <pre>
<code>// Use default controls but with documentDrag enabled.
var controls = [
    new OpenLayers.Control.Navigation({documentDrag: true}),
    new OpenLayers.Control.PanZoom(),
    new OpenLayers.Control.ArgParser(),
    new OpenLayers.Control.Attribution()]
map = new OpenLayers.Map('map', {controls: controls});
</code></pre>
</p>
<p>For a full working version have a look at
<a href="http://svn.openlayers.org/trunk/openlayers/examples/document-drag.html">the
source of the documentDrag example</a>.
]]></content:encoded>
<wfw:commentRss>http://vmx.cx/cgi-bin/blog/index.cgi/drag-as-long-as-want%3A2009-11-11%3Aen%2COpenLayers%2CJavaScript%2Cgeo/feed/</wfw:commentRss>
</item>
</channel>
</rss>
