Three ways to embed the Mafrend map on any website
Copy and paste a single HTML tag. No JavaScript required.
<iframe
src="https://mafrend.com/map/embed/?lat=46.9480&lng=7.4474&zoom=13&marker=true"
width="100%" height="400"
style="border:none;border-radius:8px;"
loading="lazy" allowfullscreen allow="geolocation"
title="Mafrend Map">
</iframe>
Add a div with data attributes and include the widget script. The map initializes automatically.
<div data-mafrend-map
data-lat="48.8566"
data-lng="2.3522"
data-zoom="12"
data-marker="true"
data-marker-color="#e63946"
data-height="400px">
</div>
<script src="https://mafrend.com/map/embed/mafrend-map.js"></script>
Create the map programmatically and control it with the MafrendMap API.
<div id="my-map"></div>
<script src="https://mafrend.com/map/embed/mafrend-map.js"></script>
<script>
var map = MafrendMap.create({
container: '#my-map',
lat: 51.5074,
lng: -0.1278,
zoom: 10,
height: '400px',
marker: true
});
// Control the map
map.flyTo(48.8566, 2.3522, 12);
map.addMarker(48.8566, 2.3522, '#e63946');
// Listen to events
map.on('mafrend:moveend', function (data) {
console.log('Map moved to', data.lat, data.lng);
});
map.on('mafrend:click', function (data) {
console.log('Clicked at', data.lat, data.lng);
});
</script>
All parameters for the iframe embed URL.
| Parameter | Type | Default | Description |
|---|---|---|---|
lat | number | 0 | Latitude of the map center |
lng | number | 0 | Longitude of the map center |
zoom | number | 2 | Initial zoom level (0-22) |
bearing | number | 0 | Map rotation in degrees |
pitch | number | 0 | Map tilt in degrees (0-85) |
marker | boolean | auto | Show a pin marker at lat/lng |
markerColor | string | #2563eb | Marker color (hex) |
nav | boolean | true | Show zoom/rotation controls |
geo | boolean | false | Show geolocation button |
interactive | boolean | true | Allow pan/zoom/rotate |
badge | boolean | true | Show "Powered by Mafrend" badge |
minZoom | number | - | Minimum allowed zoom level |
maxZoom | number | - | Maximum allowed zoom level |
hash | boolean | false | Sync map state to URL hash |
style | string | mafrend | Custom MapLibre style URL |