Global Elements
2
Footer Header Services Strip Services Tabs
Components
36
Card Carousel Cards Grid Content Overlap Content Strip Cta Bar Featured Article Featured Blocks Featured Expert Featured Pods Featured Tabs Form Block Full Screen Carousel Full Width Content Heading Strip Hero Hero Featured Links List Location Tabs Logo Carousel Map Block People Grid Quote Block Reviews Carousel Reviews Tabs Service Tiles Services Strip Services Tabs Staggered Content Sticky Accordion Sticky List Sub Navigation Team Carousel Team Filters Team Strip Tile Carousel Tile Grid

Map Block

Our Nearest Office

Gerrards Cross

Parking
Ample parking is situated at the end of Station Road in the public Pay and Display car park, opposite Waitrose. Unfortunately, we do not have visitor parking available at the B P Collins office.

Disabled access to our offices is available.

Field
Field Type
Field Name
Instructions
Block Data
tab
Heading Type
select
heading_type
Heading Text
text
heading_text
Location
post_object
location
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/colours";
@import "../../resources/scss/util/variables";
@import "../../resources/scss/util/mixins";

.block-map-block {

	.heading {
		@include fluid-type(28, 34);
	}

	&__map {
		width: 100%;
		height: rem-calc(300);
		background-color: $veryLightBlue;

		@include bp($lg) {
			height: rem-calc(680);
		}
	}

	&__content {
		width: 100%;
		max-width: 100%;

		@include bp($lg) {
			width: rem-calc(580);
		}
	}

	&__content-inner {
		padding-top: rem-calc(80);
		padding-bottom: rem-calc(80);
		padding-left: 0;
		padding-right: 0;

		@include bp($lg) {
			padding-left: rem-calc(100);
			padding-right: rem-calc(100);
		}
	}

	&__detail-heading {
		font-weight: 700;
		font-size: rem-calc(20);
		margin-bottom: rem-calc(40);
		margin-top: rem-calc(24);
	}

	&__detail {
		color: $darkBlue;
		font-weight: 700;
		text-decoration: none;
		margin-bottom: rem-calc(16);
		line-height: rem-calc(24);

		a {
			color: $darkBlue;
			transition: all 0.2s ease-in-out;
			display: inline-block;
			text-decoration: none;
			position: relative;

			&:hover {
				color: $orange;
			}
		}

		&--phone,
		&--email,
		&--address {
			a {
				padding-left: rem-calc(32);

				&:before {
					content: '';
					position: absolute;
					top: rem-calc(4);
					left: 0;
					width: rem-calc(16);
					height: rem-calc(16);
					background-size: contain;
					background-repeat: no-repeat;
					background-position: center;
				}
			}
		}

		&--phone {
			a {
				&:before {
					background-image: url('#{$asset-path}/icons/icon-phone-navy.svg');
				}
			}
		}

		&--email {
			a {
				&:before {
					background-image: url('#{$asset-path}/icons/icon-envelope-navy.svg');
				}
			}
		}

		&--address {
			a {
				&:before {
					background-image: url('#{$asset-path}/icons/icon-pin-navy.svg');
				}
			}
		}

	}

	&__info {
		border-top: 1px solid $lightBlue;
		padding-top: rem-calc(20);
		margin-top: rem-calc(4);

		p {
			&:last-of-type {
				margin-bottom: 0;
			}
		}
	}

	.marker {
		width: rem-calc(40);
		height: rem-calc(40);
		background-image: url('#{$asset-path}/icons/icon-pin-orange.svg');
		background-size: contain;
		background-position: center;
		background-repeat: no-repeat;
	}
}
class MapBlock {
	/**
	 * 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-map-block');
		this.init();
	}

	/**
	 * Example function to run class logic
	 * Can access `this.block`
	 */
	init() {
		this.blocks.forEach((block) => {

			mapboxgl.accessToken = 'pk.eyJ1IjoiYi1wLWNvbGxpbnMiLCJhIjoiY2x0em1nazQzMDFyaDJrdDR2MWhheGx1cSJ9.xefnuzaGNVh9n9xwW_EA5w';

			let mapBox = block.querySelector(".block-map-block__map");
			let mapBoxID = mapBox.id;
			let lng = mapBox.getAttribute('data-lng');
			let lat = mapBox.getAttribute('data-lat');
			let coords = [lng, lat];

			// console.log(coords);

			var map = new mapboxgl.Map({
				container: mapBoxID,
				style: 'mapbox://styles/b-p-collins/clv6g124w00lk01qv3s2t634d',
				center: coords,
				zoom: 15,
			});

			var el = document.createElement('div');
			el.className = 'marker';

			new mapboxgl.Marker(el)
			.setLngLat(coords)
			.addTo(map);

			map.scrollZoom.disable();
			map.addControl(new mapboxgl.FullscreenControl());
			map.addControl(new mapboxgl.NavigationControl());

		});
	}
}

new MapBlock();

Animation / States

  • As the user scrolls to this component the map from Mapbox will be initialised
  • As the user scrolls to this component the separate text elements will fade in one by one

External Libraries

  • Mapbox
  • ScrollTrigger (GSAP)

Notes (Design / Dev / SEO)

  • The user can select which location to feature within the component by selecting a location stored within the "Locations" post type