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

If only one marker is present the map doesnt render properly #126

Open
svondervoort opened this issue Dec 17, 2024 · 3 comments
Open

If only one marker is present the map doesnt render properly #126

svondervoort opened this issue Dec 17, 2024 · 3 comments

Comments

@svondervoort
Copy link

There is this weird issue that when there is only 1 marker on the map the map doesn't render properly.

Here is an example query with multiple marker results: https://orbotglobal.com/partners?category=&query=Eindhoven%2C+Netherlands
Here is an example query with a single marker result: https://orbotglobal.com/partners?category=&query=Johannesburg%2C+South+Africa

Here is a screenshot of the local debug log:
image

My best guess it has to do with the boundaries since the zoom level is set to 11.

Version info:

  • Craft Pro 5.5.5
  • Google Maps 5.1.0
@lindseydiloreto
Copy link
Collaborator

Thanks. Would you mind sharing the Twig snippet which is rendering the map?

It looks like the map's center is not being set correctly. That should happen automatically (regardless of how many entries), but it may depend on how your Twig is configured.

@svondervoort
Copy link
Author

Sure. Here is the Twig snippet for the map rendering:

{% do googleMaps.loadAssets({'libraries': 'places'}) %}

{% set map = googleMaps.map(partnerEntries, {
        'id': 'partner-locator-page-map',
        'cluster': {
            'renderer': 'CustomRenderer'
        },
        'styles': googleMapsStyle,
        'mapOptions': {
            'streetViewControl': false,
            'fullscreenControl': false,
            'mapTypeControl': false,
            'maxZoom': '15',
        },
        'callback': 'mapReady',
        'markerClick': 'function (event) {
        showPartnerInfo({id});
    }'
    }) %}

{% set partnersQuery = craft.entries.section('partnerPages').orderBy('title ASC') %}
{% set partnerEntries = partnersQuery.all() %}

{{ map.tag({'assets': false}) }}

It also happens on another project with a simpler setup:

{% set dentistDentalPractices = entry.dentistDentalPractices.eagerly().all() %}

{% set map = googleMaps.map(dentistDentalPractices, {
    'id': 'dentist-page-maps',
    'mapOptions': {
        'streetViewControl': false,
        'fullscreenControl': false,
        'mapTypeControl': false,
        'maxZoom': '15',
    }
}) %}

{{ map.tag() }}

@svondervoort
Copy link
Author

@lindseydiloreto just checking in if you had any luck with recreating the issue :)

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