OpenLayers OpenLayers

Ticket #1402 (closed bug: fixed)

Opened 6 months ago

Last modified 5 months ago

Google maps smooth panning in 2.93

Reported by: overstdr Assigned to: overstdr
Priority: minor Milestone: 2.6 Release
Component: Layer.Google Version: 2.5
Keywords: Cc: euzuro
State: Complete

Description

Google maps api version 2.93 features a new terrain layer to the map. One problem with switching to this version is that you lose the smooth dragging capability found in previous versions. This patch (hack) allows the use of version 2.93 for smooth dragging within OpenLayers.

Attachments

google.patch (1.2 kB) - added by overstdr on 02/28/08 13:09:44.
Changes made to Google.js file to allow smoothDrag in 2.93
updatedGooglePatch.patch (2.2 kB) - added by overstdr on 03/09/08 15:44:10.
Updated Google patch for 2.93...uses GDraggableObject instead of hack we currently use.
drag.patch (8.3 kB) - added by tschaub on 03/11/08 13:03:57.
smooth GDragging
google_withdocs.patch (7.9 kB) - added by crschmidt on 03/11/08 14:18:13.

Change History

02/28/08 13:09:44 changed by overstdr

  • attachment google.patch added.

Changes made to Google.js file to allow smoothDrag in 2.93

(follow-up: ↓ 2 ) 02/28/08 13:19:11 changed by overstdr

All tests pass in FF and IE6. please review

(in reply to: ↑ 1 ) 02/28/08 13:32:30 changed by overstdr

Thanks to euzuro for original smooth drag fix in v2.83

03/09/08 15:44:10 changed by overstdr

  • attachment updatedGooglePatch.patch added.

Updated Google patch for 2.93...uses GDraggableObject instead of hack we currently use.

03/09/08 15:46:34 changed by overstdr

After researching the Google Maps API some more, it looks like for 2.93 they have finally exposed getDragObject for the map. Now we can use this to drag the map instead of previous method. Patch added above. Please review.

03/09/08 16:36:39 changed by tschaub

  • milestone changed from 2.7 Release to 2.6 Release.

Thanks for this patch! I'm reviewing now. Do we have a CLA from you? I think this is worth getting in to 2.6.

03/09/08 16:45:54 changed by tschaub

Only tweaks in my patch are to the manual test and sm example (and a few tab/space replacements).

I still see an issue dragging across the dateline with an odd sized viewport. Looking into this right now.

03/09/08 16:49:12 changed by tschaub

Ok, if we ditch the changes from r5627, then we're back to double-dragging for odd sized viewports.

03/09/08 20:05:38 changed by tschaub

  • state changed from Review to Needs More Work.

The latest patch corrects the dateline jump with odd sized viewports. Many thanks for this find overstdr. This gives us smooth panning with Google. The only case where we get a flicker is crossing the dateline (and that is on Google's side again). And the manual acceptance tests pass for dragging (for the first time). The panning tests still don't pass - but I don't care about that here.

03/09/08 21:21:26 changed by tschaub

Patch update.

  • We can use the draggable.moveBy method instead of moveTo - this takes out a couple calculations.
  • The odd viewport changes (r5627) were necessary because there is other code that is broken. I'd like to get rid of that and correct the broken stuff.
  • The EventPane pixel change calculation using resolution (r5224) was wrong for non-spherical mercator. In general, resolution cannot be used for pixel conversions on layers that pretend they are in geographic but are really not.
  • Dragging in the y-direction is still "hard" because evtpane.getLonLatFromViewPortPx does not always return different lonlat (different in the y sense) for different pixels (different in the y sense).

The latest patch makes dragging better. But I'd like to get the getLonLatFromViewPortPx issue figured out as well.

03/10/08 11:18:02 changed by tschaub

  • state changed from Needs More Work to Review.

Now it all works. This is great. Smooth panning in Google using the GMap2 API. This means anybody who uses v2 in their script tag gets smooth panning (no special instructions).

The patch is a bit big because there were issues scattered around that all affected EventPane (relatives) dragging. Detailed below.

Changes to Google.js

  • Use the API getDragObject method and store results on the layer as dragObject (big thanks to overstdr for pointing out this addition to the GMap2 API).
  • The drag object moveBy method takes exactly what we want - a pixel displacement.
  • At least give us a console report if things go wrong.

Changes to EventPane.js

  • Map resolution is not a constant for all EventPane layers when not in spherical mercator. As the center changes, we can't rely on resolution (degrees per pixel) as we do here.
  • The corrections for odd sized viewports (r5627) are no longer necessary because of changes here and in DragPan.js.

Changes to DragPan.js

  • The assumption that the center location will be equal to half the width and half the height (as a pixel) translated to map units is not a good one. Specifically, this fails with odd sized viewports using EventPane.
  • The map pan method already does the correct translation for pixel differences, so better to use that.

Changes to Map.js

  • The pan method previously took only one options property. We need to be able to pass along the dragging flag to moveTo, so we allow that as an option (default is false).
  • The pan method has the information it needs to call moveTo directly.

With this, tests pass, examples work, and we have smooth panning. Will commit with approval.

03/10/08 11:32:33 changed by overstdr

Thanks. Yes I faxed a CLA to MetaCarta last week, so you should have it. If not, please let me know and I can send again. I really like the updated patch tschaub! Thanks for making those changes and switching to moveBy..Its much cleaner and will result in better performance.

03/10/08 11:34:54 changed by tschaub

Cool, thanks overstdr, will make sure the CLA page gets updated.

03/10/08 15:01:46 changed by overstdr

Not sure if it was from this patch or i just didnt realize earlier, but is anyone elses moveend event not being fired. Do we want to call moveend within panMapDone in DragPan.js?

03/11/08 13:03:57 changed by tschaub

  • attachment drag.patch added.

smooth GDragging

03/11/08 13:06:12 changed by tschaub

Thanks for the catch overstdr. I've updated the patch to address this. Now the events.html example looks good. Animated panning is properly stopped as well.

If others think this is 2.6 material, I'd like to get it in the trunk to see what else comes up.

03/11/08 13:07:33 changed by crschmidt

Can we add a comment to the Google example which describes that in order to take advantage of smooth panning, users must be using 2.93 or greater of the Google Maps API?

03/11/08 13:55:26 changed by overstdr

tschaub i implemented the updated patch and it looks good. Events are firing properly again :)

03/11/08 14:18:13 changed by crschmidt

  • attachment google_withdocs.patch added.

03/11/08 14:19:46 changed by crschmidt

  • state changed from Review to Commit.

Added patch with some documentation about version requirements. Tim, I'm cool with this version of the patch. Thanks for all your hard work (and same to you, overstdr).

03/11/08 14:32:17 changed by tschaub

  • keywords deleted.
  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6492]) Smooth GDragging at last. Thanks to overstdr for digging up the getDragObject method. With v2.93 and later we no longer get flickers on panning. Non-API smooth dragging is no longer supported. r=crschmidt,me (closes #1402)