Etch component
Map 1
Google map that loads only when the visitor clicks it, so the page sends nothing to Google until then. Give it an address; it needs no API key.
Documentation
A Google map that loads only when the visitor clicks it. Until then it's a button with the address, so the page sends nothing to Google until the visitor asks for the map.
How to use it
- Set Address: a street address or a place name, as you'd type it in Google Maps. The map searches for it, so it needs no API key.
- Zoom sets how close the map starts: 15 shows the streets around the address, and lower numbers show more of the area.
- Button Text says the map comes from Google ("Show the map from Google Maps" by default). Keep that in it, because visitors choose on that basis.
- Icon swaps the map icon.
- Its shape, corners and colors are CSS recipes, below. Try them in the preview's Styles tab, then paste the ones you pick in the site's
mainstylesheet.
Good to know
- On click, the script puts Google's iframe in the button's place and moves the focus into it. Before that, the page makes no request to Google.
- Add a line to the site's privacy policy: Google receives the visitor's IP address and the page they're on only if they choose to show the map, and Google Maps may then set its own cookies.
- The script also sets
window.MacMap1:MacMap1.load(element)shows a map from code,MacMap1.init()sets up maps added to the page later, and each map firesmac-map-1:loadonce it's loaded.
CSS recipes
--mac-map-1-ratio sets the map's shape (16 / 9) and --mac-map-1-ratio-s its shape on phones, up to 480px wide (4 / 3). --mac-map-1-radius (--radius) and --mac-map-1-border set its corners and line, and --mac-map-1-background (--bg-ultra-light), --mac-map-1-icon-background (white) and --mac-map-1-icon-color (--primary) the button's colors until the map loads. A recipe changes every Map 1 on the site. Paste it in the site's main stylesheet, which Etch prints after the components' styles.
On a light section
For a map on a light section, where its light button would blend in, the button white.
/* Map 1's button white, for a light section */
.mac-map-1 {
--mac-map-1-background: var(--white);
}
Square, beside text
For a map beside an address or a contact form, a square. On phones it keeps its 4 / 3.
/* Map 1 square */
.mac-map-1 {
--mac-map-1-ratio: 1 / 1;
}
Taller on phones
For a map that shows more of the area on phones, taller than wide there (3 / 4) instead of 4 / 3.
/* Map 1 taller than wide on phones */
.mac-map-1 {
--mac-map-1-ratio-s: 3 / 4;
}
Reference
Read from the component's JSON, so it's always current.
Loading the reference