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

Center or bounds map issue with only 1 location or no locations #6

Open
jamiepittock opened this issue Jun 25, 2023 · 1 comment
Open
Labels
Bug Report Something isn't working

Comments

@jamiepittock
Copy link

jamiepittock commented Jun 25, 2023

I may be doing something wrong. My location entries have an address field.

{% set locations = craft.entries().section('locations').all() %}
{% set options = {
    'id': 'my-map'
} %}
{{ mapbox.map(locations, options).tag() }}

If I query multiple entries, everything works as expected. All the markers appear and the map uses the locations as it's bounds/center.

But if I only have one result, either by filtering or setting .limit(1), the location marker appears but the map looks like it uses the default center value [0,0]. I'm guessing maybe bounds needs more than one set of location coordinates to work?

Similar happens if I have no results, either by filtering the query or by setting the locations variable to an empty array []. That's to be expected with no locations set, but then I've had no luck setting a fallback center and zoom using either the center or zoom dynamic map options or by using the zoom or center universal methods.

Maybe I'm not setting the values of those options or methods correctly. Could you possibly give me an example that works using a) just 1 location and b) no locations (an empty map but with a custom center).

Thanks in advance!

@lindseydiloreto lindseydiloreto added the Bug Report Something isn't working label Jul 11, 2023
@lindseydiloreto
Copy link
Contributor

Hey @jamiepittock, sorry for the lag. I chipped away at this last week, enough to know that you hit a real bug.

I'll try to circle back on it shortly. If/when I've got a bit more news, I'll ping you back either here or on Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants