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

Prevent default zoom if map is set to fitbounds #236

Open
bozdoz opened this issue Sep 21, 2023 · 1 comment
Open

Prevent default zoom if map is set to fitbounds #236

bozdoz opened this issue Sep 21, 2023 · 1 comment

Comments

@bozdoz
Copy link
Owner

bozdoz commented Sep 21, 2023

RE: https://wordpress.org/support/topic/prevent-default-map-tiles/#post-17065108

if a map is set via [leaflet-map] it defaults to whatever the default lat/lng is. That same map may be instantiated with [leaflet-map fitbounds], and it doesn't need to start at the default lat/lng.

Investigate whether we can wait to create the map, after the shapes have been created.

@webd-uk
Copy link

webd-uk commented Jan 18, 2024

Hi,

Just want to remind you about this because I've recently found that it actually highlights a bug (in my opinion).

If you use this shortcode to initiate the map ...

[leaflet-map fitbounds]

... then the default lat/lng from settings is used before the markers are added and tiles are requested. Then the markers are added, fitbounds is run and the correct tiles are then loaded. This is fine so long as the default lat/lng is the same as the one computed by fitbounds but if it isn't then un-necessary tiles are loaded.

If you instead use this to initiate the map in order to override the default lat/lng ...

[leaflet-map lat=50.9497 lng=0.7373 fitbounds]

... then we find that fitbounds no longer works so we suspect that adding lat and lng parameters disables fitbounds.

Ideally, no map tiles would be loaded if fitbounds parameter is present until fitbounds has run.

Oliver

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

No branches or pull requests

2 participants