Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix zoom animation for v3.32#559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
itsmichaeldiego merged 7 commits intogoogle-map-react:masterfromstephenfarrar:zoom2
Apr 27, 2018

Conversation

stephenfarrar
Copy link
Contributor

I managed to reduce the surface of the change.
The basic demo seems to work fine, but I haven't tried it in any other demos.

Summary of change:

  • This uses a better method to position the marker container div in the map top-left.
  • It also lets each marker use thefromLatLngToContainerPixel() method, which accounts for fractional zoom during a zoom animation.

Fixes#552

Copy link
Member

@itsmichaeldiegoitsmichaeldiego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Great work overall! I've a couple of questions and comments, I am pretty excited to get this merged, let me know if you need any help!

} else {
this_.updateCounter_++;
this_._onBoundsChanged(map, maps);
if (mapsVersion < 32) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can we move 32 to a const variable?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

const ptx = overlayProjection.fromLatLngToDivPixel(
new maps.LatLng(ne.lat(), sw.lng())
overlayProjection.fromContainerPixelToLatLng({ x: 0, y: 0 })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could you elaborate why setting{ x:0, y:0 } fixes the animation problem?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good question, this is subtle. There are two ways of getting the lat-lng coordinates of the map's top-left corner.

  1. Usingmap.getBounds() gives you thefinal bounds. That's because it is based onmap.getCenter() andmap.getZoom() which give you the final center and the final zoom. In other words, if you callmap.setZoom() or click on the zoom control,map.getZoom() immediately reflects the new zoom, and so doesmap.getBounds(). You would use this if you were, say, fetching data from a server based on the map bounds.

  2. UsingoverlayProjection.fromContainerPixelToLatLng({ x: 0, y: 0}) gives you the bounds forthe current frame. We use this because we are drawing each frame.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@stephenfarrar Great, thanks for the answer. That makes sense, ifmap.getBounds gives you thefinal bounds, that is exactly what is making the markers animate from the corners.

@@ -566,6 +566,9 @@ export default class GoogleMap extends Component {

this._setLayers(this.props.layerTypes);

const versionMatch = maps.version.match(/^3\.(\d+)\./);
const mapsVersion = versionMatch ? Number(versionMatch[1]) : 99;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could we make this code more readable? What is99? orversionMatch[1]? (I understand ofc but its not so readable)

vertic4l reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Done.

itsmichaeldiego reacted with thumbs up emoji
@@ -34,6 +34,9 @@ const K_GOOGLE_TILE_SIZE = 256;
const K_IDLE_TIMEOUT = 100;
const K_IDLE_CLICK_TIMEOUT = 300;
const DEFAULT_MIN_ZOOM = 3;
// Starting with version 3.32, the maps API calls `draw()` each frame during
// a zoom animation.
const DRAW_CALLED_DURING_ANIMATION = 32;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@stephenfarrar Good work, I will add_VERSION to this const real quick if you don't mind.

Copy link
Member

@itsmichaeldiegoitsmichaeldiego left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@stephenfarrar Great work, I think this is good to go.

@itsmichaeldiego
Copy link
Member

itsmichaeldiego commentedApr 24, 2018
edited
Loading

@stephenfarrar Although I keep thinking if we want to keep simulating thedraw() for versions below3.32, as this map uses the latest version as default 🤔. We could remove this whole block:https://github.com/google-map-react/google-map-react/pull/559/files#diff-0146a78a4269b3d2562b8f44d0137200R673

I understand that removing this would affect our support for older versions, but at the same time I don't believe we should have different code for each version of Google Map (I know its not the case and its just for versions below 3.32, but my question is more related to which approach to take when).

What do you think?

🤔

@stephenfarrar
Copy link
ContributorAuthor

I wrote it this way because I think it's good for customers to be able to choose independently the version of the Maps API and google-map-react.

But I agree that this version-detection is not very good.

We can delete this section in late August 2018, because v3.31 is scheduled to be deleted by then. Does that sound acceptable?

adriamarzo added a commit to Badiapp/google-map-react that referenced this pull requestApr 27, 2018
@itsmichaeldiego
Copy link
Member

@stephenfarrar I think it does! Lets keep it as it is right now, I will delete it afterwards if needed.

@lock
Copy link

lockbot commentedDec 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@locklockbot locked asresolvedand limited conversation to collaboratorsDec 1, 2019
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@itsmichaeldiegoitsmichaeldiegoitsmichaeldiego approved these changes

Assignees

@itsmichaeldiegoitsmichaeldiego

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Fix zoom animation with Google Maps API v3.32
2 participants
@stephenfarrar@itsmichaeldiego

[8]ページ先頭

©2009-2025 Movatter.jp