One popular option to implement a searchable map in Webflow is by integrating Google Maps. Here's a step-by-step guide on how you can achieve this:
1. Sign up for a Google Maps API key: Visit the Google Cloud Platform Console (console.cloud.google.com) and create a new project. Enable the "Maps JavaScript API" and obtain an API key.
2. Add the Google Maps API to your Webflow project: In the Webflow Designer, go to Project Settings > Custom Code. Paste the following script tag in the Head Code section, replacing "YOUR_API_KEY" with the API key you obtained from Google:
```html
<script src="<https://maps.googleapis.com/maps/api/js?key=YOURAPIKEY>"></script>
```
3. Design your map container: Add a new div block to your Webflow page and give it a class name like "map-container". Adjust the dimension and position of this div as desired.
4. Add custom code for the map: Go to the Page Settings > Custom Code for the page where you want to display the map. Paste the following script code in the Head section:
```javascript
<script>
function initMap() {
// Set the coordinates for the center of the map
var centerCoordinates = { lat: 0, lng: 0 };
// Create the map object with your desired options
var map = new google.maps.Map(document.getElementById('map'), {
center: centerCoordinates,
zoom: 12,
});
// Add markers for your business partners
var partners = [
{
name: 'Partner 1',
lat: 37.7749,
lng: -122.4194,
},
{
name: 'Partner 2',
lat: 34.0522,
lng: -118.2437,
},
// Add more partners as needed
];
partners.forEach(function (partner) {
var marker = new google.maps.Marker({
position: { lat: partner.lat, lng: partner.lng },
map: map,
title: partner.name,
});
});
}
</script>
```
5. Add the map container and initialize the map: Insert an HTML embed element in your Webflow page where you want the map to appear. Set the embed code to:
```html
<div id="map" class="map-container"></div>
```
6. Finish setting up the map: At the bottom of the Page Settings > Custom Code section, add the following script code:
```javascript
<script>
document.addEventListener('DOMContentLoaded', function () {
initMap();
});
</script>
```
7. Customize the map and markers: You can modify various options like the map's initial center and zoom level, as well as the appearance of markers. Refer to the Google Maps JavaScript API documentation (developers.google.com/maps/documentation/javascript/) for detailed instructions on customization.
Once the steps above are completed, you should have a searchable map displaying your business partners' locations near the user. Users can interact with the map to pan and zoom, and clicking on a marker will display the relevant partner information. Keep in mind that this guide assumes basic knowledge of HTML and JavaScript for custom code implementation in Webflow.