Skip to content

Fix: if center changed before google map api was finished, map center will keep as the previous center #1205

Open
sspku-yqLiu wants to merge 1 commit intogoogle-map-react:masterfrom
sspku-yqLiu:master
Open

Fix: if center changed before google map api was finished, map center will keep as the previous center #1205
sspku-yqLiu wants to merge 1 commit intogoogle-map-react:masterfrom
sspku-yqLiu:master

Conversation

@sspku-yqLiu
Copy link
Copy Markdown

hi Google map react team.

We faced an issue during use google map react. If api from https://maps.googleapis.com is very slow, and we change map center before google map api return data. map may cannot detect the center change and will not move the center to the correct place.

Steps to reproduce:

  • use Default center, lets say center of singapore as the fallback location of my address
  • fetch data from https://maps.googleapis.com and https://www.getMyHomeAddress.com
  • https://www.getMyHomeAddress.com return value first
  • change the pin and center value to the api data. and for now, we cannot find this.map_, which mean we will skip the panTo function
  • https://www.getMyHomeAddress.com return value
  • since the prevProps center is already changed to my home, so it wont trigger panTo function also
  • google map will show the center as the fall back address

Plans for solve the problem:

  • add a state initializedCenter_ to force trigger panTo function when map is shown

@sspku-yqLiu sspku-yqLiu changed the title Fix: map center wont change before map api is loaded Fix: if center changed before google map api was finished, map center will keep as the previous center Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant