Sprig filter with a Google Map
See original GitHub issueQuestion
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:
- Created 3 years ago
- Comments:14 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, @bencroker! The
htmx:afterSettle
worked without issue.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!