question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sprig filter with a Google Map

See original GitHub issue

Question

I have a Google Map within a Sprig component that loads fine until I apply a filter. The map still loads but it covers the browser window and doesn’t show the updated results. Am I missing something on the filter to allow it to work with the map? I’m using the beta version of SmartMap which appears to be working fine until a Sprig filter is applied.

Here is a stripped down version of the code showing a couple of filters and the map.

<div s-replace="#jobListings">

    <div id="pageTitle" class="d-flex align-items-end px-2 py-3 mb-3 text-white bg-purple rounded shadow-sm">
        <div class="col px-2">
            <small><i class="bi bi-funnel"></i> DRIVER TYPE</small>
            <select sprig id="driverType" name="driverType" class="form-select" aria-label="-Select-">
                {% for option in driverType.options %}
                    {% set selected = entry is defined
                        ? entry.driverType.value == option.value
                        : option.default %}
                    {% set driverType = option.value %}
                    <option value="{{ driverType }}"{% if selected %}selected{% endif %}>
                        {{ option.label }}
                    </option>
                {% endfor %}
            </select>
        </div>
        <div class="col px-2">
            <small><i class="bi bi-funnel"></i> TRUCK TYPE</small>
            <select sprig id="truckType" name="truckType" class="form-select" aria-label="-Select-">
                {% for option in truckType.options %}
                    {% set selected = entry is defined
                        ? entry.truckType.value == option.value
                        : option.default %}
                    {% set truckType = option.value %}
                    <option value="{{ truckType }}"{% if selected %}selected{% endif %}>
                        {{ option.label }}
                    </option>
                {% endfor %}
            </select>
        </div>
    </div>

    <div id="jobListings">
        <div class="col-sm-12 my-4">
            {# Get all locations #}
            {% set locations = craft.entries.section('jobs').all() %}

            {% set options = {
                id: 'my-map',
                height: 300,
                zoom: 6,
                draggable: false,
                markerOptions: {
                    icon: 'https://maps.google.com/mapfiles/ms/icons/green-dot.png'
                },
                infoWindowOptions: {
                    maxWidth: 200
                }
            } %}
            {% set map = googleMaps.map(locations, options) %}
            {{ map.tag() }}

        </div>
    </div>
</div>

{{ sprig.script }}

<script>
    htmx.on('htmx:afterSwap', function(event) {
        googleMaps.init('my-map');
    });
</script>

Additional context

Add any other context or screenshots about the support request here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ConversioniaDevcommented, Feb 18, 2021

Thanks, @bencroker! The htmx:afterSettle worked without issue.

1reaction
lindseydiloretocommented, Feb 26, 2022

Good news, we’ve officially documented the process for using Sprig with Google Maps! 👏

Any other questions, feel free to ping to Double Secret Agency!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proximity Search with Sprig | Google Maps plugin for Craft CMS
The search input is a simple text field for capturing the proximity search target . Optional search filters can refine the results (eg:...
Read more >
Triggers, Filters and Groups - Sprig
Sprig supports filtering up to 10 total event properties across all triggers in a study. ... Select the column that you want to...
Read more >
Sprig use category filtering AND load more
The problem is that it appends everything in the sprig component, including the category filters. _sprig/component : {% set category = craft.
Read more >
How to apply spring boot filter based on URL pattern?
The filter is automatically identified by the Spring Boot Framework and works fine for all of the REST API. I want this filter...
Read more >
Filtering and Transforming Collections in Guava - Baeldung
Filter collections with Predicates and transform them with ... A short guide to Guava Multimap in comparison with standard java.util.Map.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found