JavaScript script that changes Google Maps formatted links to iOS formatted links only on iOS devices.
- Checks for an iOS Device via User Agent String (checks for iPhone, iPod and iPad)
- Get's all anchor tags
- Get's href of each anchor
- Changes url from "maps.google.com" to "maps.apple.com"
- Place <script type="text/javascript" src="iOSifyMaps.js"></script> tag referring to js file right BEFORE </body> tag
- Use the following JavaScript after including this JS file: <script>document.getElementsByTagName('a').iOSifyMaps();</script>
- For more efficient JS, add an id to the targeted element and use getElementByID: <script>document.getElementByID('mapsLink').iOSifyMaps();</script>
- This can also be used with jQuery: <script>$('a[href*="maps.google.com"]').iOSifyMaps();</script>