In today's digital world, businesses need to make it easy for customers to find their stores or dealers. Whether you’re selling products through authorized dealers or running a chain of physical stores, a Find a Dealer/Store Locator module helps customers locate the nearest point of purchase effortlessly.
This guide will walk you through how to build an interactive dealer locator using HubSpot and Mapbox API. We’ll cover everything, from getting API keys to implementing an intuitive map with real-time dealer data.
A dealer locator isn’t just a fancy map—it’s a powerful business tool. Here’s why:
Customers can view all dealer locations on a global map. Each location is marked with a pin for easy identification.
When a customer clicks on a specific location, the map zooms in, and a sidebar opens on the left displaying dealer details:
The “Return to Map” button resets the map to its default view, allowing users to explore more locations.
Businesses can update, add, or remove dealer locations through the HubSpot Page Editor. This ensures accurate and up-to-date store listings.
The module is powered by Mapbox, offering an engaging, visually appealing experience.
Dealer locations update dynamically whenever changes are made via the HubSpot Page Editor.
Clicking a dealer location opens a sidebar showing:
Easy navigation, with a “Return to Map” button for quick resets.
Fully responsive across desktops, tablets, and smartphones.
For Mapbox integration, follow these steps:
To get started, we need to initialize the map using Mapbox . First, we set the access token, which allows us to use Mapbox’s services. Then, we create a new map instance by defining the container, map style, center coordinates, and zoom level. In this example, the map is set to a light theme, with a default center point and zoom level.
mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v10',
center: [-77.034084142948, 38.909671288923],
zoom: 1,
scrollZoom: false
});
map.addControl(new mapboxgl.NavigationControl());
To show dealer locations on the map, we need to define them with their coordinates and details. In this example, we’re using a JSON FeatureCollection, where each dealer has a specific location (latitude and longitude) along with important details like name, address, city, and contact information. This setup makes it easy to manage multiple dealer locations and display them accurately on the map.
const stores = {
'type': 'FeatureCollection',
'features': [
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [-77.034084, 38.909671]
},
'properties': {
'id': 1,
'dealer': 'Dealer Name',
'address': '123 Main St',
'city': 'City Name',
'contact': '123-456-7890'
}
}
]
};
The Find a Dealer/Store Locator module is a powerful way to connect customers with your business locations. Using HubSpot and Mapbox API, you can create an interactive experience that enhances customer satisfaction and increases store visits.
By following this guide, you now have a fully functional store locator that you can customize as needed.