Problem/Motivation

If the initial zoom is way smaller than the focus zoom, the first time trigger_geocode() is called the panning will be slightly off.
It seems to happen because Leaflet will pan with the initial zoom (which is low so the panning does not have to be super precise) and then zoom.

Steps to reproduce

  1. Use a geofield_map widget with Leaflet.
  2. Select a town in the autocomplete field.
  3. The map zooms and pans slight out of town.

Proposed resolution

setZoomToFocus() should be called before mapSetCenter().
This way, when the panning happens, it already knows at what zoom level the marker should be into view.

Remaining tasks

I will submit a patch.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

prudloff created an issue. See original summary.

prudloff’s picture

Status: Active » Needs review
itamair’s picture

Status: Needs review » Postponed (maintainer needs more info)

Thanks for reporting this @prudloff
I tested your exact use case and self.mapSetCenter(mapid, position) and self.setZoomToFocus(mapid) are so close each other that they happen at the same time, and sequence is not really perceivable to me ...
I cannot reproduce at all what you define as "pans slight out of town".

May you post better evidence of your issue, such a short video recording of what you see?
Otherwise I still don't feel your correction is really needed ...

prudloff’s picture

StatusFileSize
new208.48 KB
new179.04 KB
new189.7 KB

The sequence is not perceivable to me either. The problem is not that you can see the sequence but that the accuracy of the panning is based on the current zoom level (so the zoom should happen before the panning).

Here are screenshots with and without the patch.
Without the patch, the map is centered slight away from the marker (and if I unzoom, you can see the marker is slightly to the south-east).

avpaderno’s picture

Version: 8.x-2.67 » 8.x-2.x-dev

  • itamair committed fad3b67 on 3.0.x
    Issue #3228713 by prudloff: trigger_geocode() should zoom before panning
    
itamair’s picture

Status: Postponed (maintainer needs more info) » Fixed

Committed into 3.0.x branch.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.