Convert Google Maps links to Apple Maps on iOS

	// Change Google Maps links to Apple Maps on iOS
	var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
	if( !! iOS ) {
		var links = document.body.querySelectorAll('.map-link');
		links.forEach( function(e) {
			var url = e.getAttribute('href').replace('google', 'apple');
			e.setAttribute('href', url );
		});
	}
<a class="map-link" href="https://maps.google.com/?q=6750+West+Loop+South%2C+Suite+920+Bellaire+TX+77401">link to map</a>

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk