Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #789: Set the map language to UI language #790

Closed
wants to merge 2 commits into from

Conversation

WindLi001
Copy link
Contributor

This is a solution of #789. The language of map in Place will be set to the same one of the UI. If the UI language is NOT supported by Mapbox, then the English map will be provided.

@codecov
Copy link

codecov bot commented Jan 17, 2023

Codecov Report

Merging #790 (a2108a4) into master (92bcba0) will decrease coverage by 0.27%.
The diff coverage is 9.67%.

@@            Coverage Diff             @@
##           master     #790      +/-   ##
==========================================
- Coverage   65.51%   65.24%   -0.27%     
==========================================
  Files         137      137              
  Lines       12903    12965      +62     
  Branches      533      533              
==========================================
+ Hits         8453     8459       +6     
- Misses       4295     4351      +56     
  Partials      155      155              
Flag Coverage Δ
api 36.13% <ø> (ø)
ui 69.68% <9.67%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
ui/src/localization.ts 22.22% <8.77%> (-5.12%) ⬇️
ui/src/components/mapbox/MapboxMap.tsx 34.09% <20.00%> (-0.85%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@WindLi001
Copy link
Contributor Author

Adding another bug fix. Now photoview generating 1024px thumbnail for each photo, including the photo smaller than 1024px.
I add a limit. If the original photo is smaller than 1024x, then the thumbnail will be the same size of the original photo.

Copy link
Member

@viktorstrate viktorstrate left a comment

Choose a reason for hiding this comment

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

Thank you for your pull request, it would be a nice addition.
I've left som small comments with some change requests.

I'm very sorry that I didn't had the time to look at this before now

@@ -59,13 +60,17 @@ const useMapboxMap = ({
mapboxLibrary.accessToken = mapboxData.mapboxToken

map.current = new mapboxLibrary.Map({
zoom: 6, // zoom must be initialized to 6 or more, or the language of map cannot be set.
center: [-77.0259, 38.901], // Initial to the land.
Copy link
Member

Choose a reason for hiding this comment

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

Why did you hard-code these coordinates in particular?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set the map center, because if it isn't set, the center will be in the ocean by default. Then at zoom 6, the clients will see nothing on the map, and maybe they will think the map is broken. The best way is choosing the coordinate of the client's nation by default, but I don't find the way to get this information. So I have to hard-code a random coordinate in the land.

Copy link
Member

Choose a reason for hiding this comment

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

Is it maybe appropriate to use the default [0, 0] coordinate and then have the default zoom be zoomed out to the max value so the entire world is visible and the user can zoom to their desired place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set zoom to 6 because of a bug of mapbox-gl-language. https://github.com/mapbox/mapbox-gl-language/issues/60
In fact, at beginning I don't set either the zoom or the center, but just only call MapboxLanguage({defaultLanguage: xxx}). Then I found the map language is still English. I check the codes several times but have no idea. Fortunately, at last I found the BUG of mapbox-gl-language and raise the issue above. But until now, this bug is still here.
So now we have 2 choices:

  1. Waiting mapbox-gl-language fix this bug, and don't set either the zoom or the center. But before they fix it, the map language will always be English.
  2. Setting the zoom and center to provide multi-language map, waiting them fix this bug, and then delete the setting of zoom and center.
    I want to fix this bug by myself, but I'm still learning JavaScript now.

Copy link
Contributor Author

@WindLi001 WindLi001 Feb 9, 2023

Choose a reason for hiding this comment

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

With the beginner’s luck, I found another way can change the map language without setting zoom to more than 6. If delete the setting of map projection in ui\src\Pages\PlacesPage\PlacesPage.tsx like this,

  const { mapContainer, mapboxMap, mapboxToken } = useMapboxMap({
    configureMapbox: configureMapbox({ mapboxData, dispatchMarkerMedia }),
    mapboxOptions: {
      //projection: {
      //  name: 'globe',
      //},
    },
  })

the map language can be changed too.
I still don't know why the map language is related to the zoom or projection. And I have a look to the code of mapbox-gl-language but found nothing about zoom or projection.
I think may the map projection is important to the plane and ship, but not a photo gallery :-). So, if you agree, I'll revert this commit, delete the setting of zoom and center, delete the setting of projection, and commit again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I move this commit to a new pull request #797, and this one will be closed.

Comment on lines +51 to +54
if width > dimensions.Width {
width = dimensions.Width
height = dimensions.Height
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd appreciate if you send another PR for this change.
Should it also consider if the height is smaller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the aspect of thumbnail is the same as photo, comparing width or height is enough. I choose comparing width.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I move this commit to a new pull request #798, and this one will be closed.

@WindLi001
Copy link
Contributor Author

This pull request is created directly on my master branch, which is absolutely wrong. So, I create new pull requests #797 and #798 on other branch, and this one will be closed.

@WindLi001 WindLi001 closed this Feb 10, 2023
kkovaletp added a commit to kkovaletp/photoview that referenced this pull request May 13, 2024
This is a solution of photoview#789.
The language of the map in Place will be set to the same as the UI. If
the UI language is NOT supported by Mapbox, then the English map will be
provided.
This is a new pull request of setting the map language to UI language,
and I commit it to a new branch other than master. The old one will be
closed soon.
As per the comment in the old pull request
photoview#790, I deleted the settings
of zoom and center and deleted the setting of projection, which means
the map language cannot be changed.
I have looked at the commit setting the projection, it said "chore: add
mapbox globe view", so I guess the committer just wants to show the
mapbox with the whole world map initially. But I think maybe he or she
doesn't know what the projection really means, in fact, global
projection just makes a spherical map. So, I add zoom: 1 to show the
mapbox with the whole world map initially.

---------

Co-authored-by: WindLi001 <lichenggang1@hotmail.com>
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.

None yet

2 participants