Components
63
Accordion Items Basic Hero Basic Map Benefits Grid Contained Content Content Form Content Image Content Parallax Image Cookie Table Cta Blocks Events Example Featured Items Grid Featured Post Flockler Embed Gated Content Hero Slider Image Image Video Content Key Features Key Stats Large Hero Latest Careers Latest Posts List Grid Live Data Location Stack Logo Carousel Market Education Search News Filter News Grid Package Tables Accordion Parallax Benefit Tiles Pdf Footer Post Search Product Buttons Product Data Table Product Finder Cta Product Search Product Spec Search Quote Quote Carousel Regions Banner Related Posts Section Anchors Settle For More Banner Single Column Content Small Cta Banner Speaker Grid Speaker Overview Speakers Split Content Statistic Tiles Statistics Carousel Tabbed Content Table Team Carousel Title Title Content Vacancy Browser Values Video Video Hero

Basic Map

Field
Field Type
Field Name
Instructions
Block Data
tab
Heading Type
select
heading_type
Heading Text
text
heading_text
Map Location
google_map
map_location
Name
text
name
Used to override the caption name
Address
wysiwyg
address
Overrides the value of the displayed address. Use this if you want to provide more details or fix formatting
Block Meta
tab
ID
text
block_id
Block Classes
text
block_classes
Block Theme
select
block_theme
Background Colors
select
background_colors
Padding Top
select
padding_top
Padding Bottom
select
padding_bottom
Margin Top
select
margin_top
Margin Bottom
select
margin_bottom

				
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";

.block-basic-map {
	position: relative;
	& > .heading{
		font-size: rem-calc(24) !important;
		font-weight: 500;
		max-width: 856px;
		margin-left: auto;
		margin-right: auto;
		padding-left: $grid-gutter-width / 2;
		padding-right: $grid-gutter-width / 2;
		margin-bottom: 2rem;
	}
	
	.container .heading{
		margin-bottom: 2rem;
	}

	&__map-container {
		width: 100%;
		aspect-ratio: 1/1;
		max-height: 525px;
		
		@include bp($lg) {
		}
	}

	&__wrapper {
		position: relative;
	}

	&__content {
		background-color: $primary-light;
		color: $white;
		position: absolute;
		bottom: 26px;
		right: 26px;
		width: 270px;

		a{
			color: $white;
		}

		padding: {
			left: 35px;
			right: 26px;
			top: 16px;
			bottom: 24px;
		}

		&,
		p {
			line-height: 24px;
		}

		p {
			margin: 0;
		}

		&:before {
			background-color: $primary-light;
			content: "";
			height: 26px;
			left: 26px;
			position: absolute;
			right: 0;
			top: -26px;
			transition: all 0.5s;
		}
		
		.title {
			font-weight: 700;
		}
	}
}
var BasicMap = class BasicMap {
	/**
	 * Create and initialise objects of this class
	 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor
	 * @param {object} block
	 */
	constructor() {
		this.blocks = document.querySelectorAll('.block-basic-map');
		this.init();
	}

	/**
	 * Example function to run class logic
	 * Can access `this.block`
	 */
	init() {
		const lazyLoadMap = (block) => {
			const io = new IntersectionObserver((entries, observer) => {
				entries.forEach(entry => {
					if (entry.isIntersecting) {
						this.initMap(block);
					}
				})
			}, { threshold: [0.4] });

			io.observe(block);
		}

		this.blocks.forEach(lazyLoadMap);
	}

	initMap(block) {
		if (!mapboxgl) {
			console.error(mapboxgl);
			return;
		}

		const mapContainer = block.querySelector('.block-basic-map__map-container');

		// Create a new token - https://account.mapbox.com/
		mapboxgl.accessToken = 'pk.eyJ1Ijoic3RyYXRlZ2lxIiwiYSI6ImNsY2l2eW93cDA0dDIzc203Z2RkbjhqNDkifQ.J4ldDc76kIiyyaP1P8n_Rg';

		let lng = parseFloat(mapContainer.getAttribute('data-lng'));
		let lat = parseFloat(mapContainer.getAttribute('data-lat'));
		let zoom = parseFloat(mapContainer.getAttribute('data-zoom'));

		this.map = new mapboxgl.Map({
			container: mapContainer,
			style: 'mapbox://styles/mapbox/streets-v11',
			center: [lng, lat],
			zoom: zoom,
			cooperativeGestures: true
		})

		

		// if less than 768px, pan the map down a bit
		if (window.innerWidth < 768) {
			this.map.panBy([0, 75]);
		}

		new mapboxgl.Marker({
			color: "#FF2C31",
			anchor: "bottom",
		}).setLngLat([lng, lat])
			.addTo(this.map);

		// Add zoom and rotation controls to the map.
		this.map.addControl(new mapboxgl.NavigationControl());
	}
}

new BasicMap();
This component is not currently used on any pages.
There are is no readme file with this component.