A high-performance, responsive Shopify section that plots your products on an interactive map using Leaflet.js and OpenStreetMap.
- Interactive Map: Built with Leaflet.js and OpenStreetMap (no API keys required).
- Responsive Design: Works perfectly on mobile, tablet, and desktop.
- Advanced Filtering: Filter products by collection directly from the map.
- Location Search: Users can search for locations via the Nominatim API.
- "Near Me" Integration: One-click geolocation to find products near the user.
- Customizable Popups: Shows product title, image, and price with a direct link to purchase.
- Product Page Context: Specialized section for product pages that shows all product locations while focusing on the current item.
- Focus Product Mode: General map section includes an optional "Focus Product" setting to zoom into a specific location by default.
- Accessibility Optimized: WCAG-compliant with full ARIA support, keyboard navigation, and screen-reader optimized popups.
You need a place to store the coordinates for your products.
- Go to Settings > Custom data > Products.
- Click Add definition.
- Name:
Location - Namespace and key:
custom.location - Type: Single line text.
- Ensure "Storefronts" access is checked and click Save.
This specialized template provides the data for the map.
- In your Shopify Admin, go to Online Store > Themes > Edit Code.
- Under Templates, click Add a new template.
- Select search and name it
product-map-api. (Filename:search.product-map-api.liquid). - Paste the code from
templates/search.product-map-api.liquid. - Save.
- Under Sections, click Add a new section.
- Name it
product-map. - Paste the code from
sections/product-map.liquid. - (Optional) Repeat for
sections/product-page-map.liquidif you want a map on individual product pages. - Save.
The coordinates must be in the format latitude,longitude (e.g., 51.5074,-0.1278).
- You can add these manually to each product in the Metafields section at the bottom of the product page.
- Or use the Bulk Editor to paste them in for multiple products at once.
- API Strategy: Uses a custom Liquid search template to fetch JSON data, ensuring performance even with hundreds of pins.
- Robust Metafield Loading: Implements an
all_productslookup trick to ensure metafields are reliably loaded across different themes. - Privacy: No external tracking or required API keys.
MIT