Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tacky Lights Navigator. This small bit of HTML & Javascript takes a series of addresses, and converts that into an ordered list. Each item in the list is an Apple Maps navigation link from [Your Current Location] to [That House]. This file is designed to be hosted in Dropbox and then added to your home screen on your iPhone.
<html>
<head>
<title>Tacky Lights</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<meta name="viewport" content="width=device-width" />
<!--<link rel="apple-touch-icon-precomposed" sizes="120x120" href="put-your-holiday-icon-here" />-->
</head>
<body>
<ol id="list"></ol>
<script type="text/javascript">
var addresses = [];
addresses.push("10424 Marbury Terrace, Glen Allen, VA");
addresses.push("1021 E Cary St, Richmond, VA 23219");
addresses.push("1508 Grove Avenue, Richmond, VA");
addresses.push("Monument Avenue, Richmond, VA");
addresses.push("6421 Fitzhugh Avenue, Richmond, VA");
addresses.push("Pee, 7035 Three Chopt Road, Richmond, VA");
addresses.push("8202 Shelley Road, Richmond, VA");
addresses.push("9215 Venetian Way, Richmond, VA");
addresses.push("9604 Asbury Court, Richmond, VA");
addresses.push("9213 Holbrook Drive, Henrico, VA");
addresses.push("Pee, 1420 N Parham Road, Richmond, VA");
addresses.push("2300 Wistar Court, Henrico, VA");
addresses.push("2334 Thousand Oaks Drive, Richmond, VA");
addresses.push("2503 Pine Grove Drive, Richmond, VA");
addresses.push("9004 Covewood Road, Glen Allen, VA");
addresses.push("4623 Packard Road, Glen Allen, VA");
addresses.push("9328 Coleson Road, Glen Allen, VA");
addresses.push("4901 Daffodil Road, Glen Allen, VA");
addresses.push("9300 Howze Road, Glen Allen, VA");
addresses.push("9716 Wendhurst Drive, Glen Allen, VA");
function replaceAll(str, from, to) {
return str.split(from).join(to);
}
$(document).ready(function() {
for (var i=0; i < addresses.length; ++i) {
var from = "Current+Location";
var to = addresses[i];
$("#list").append("<li><a href='http://maps.apple.com/?daddr=" + replaceAll(to, " ", "+") + "&saddr=" + from + "'>" + to.substr(0, to.indexOf(",")) + "</a></li>");
}
});
</script>
</body>
</html>
@bartdorsey

This comment has been minimized.

Copy link

@bartdorsey bartdorsey commented Dec 2, 2014

Why not write the array as an Array literal instead of all the addresses.push syntax.

@cliss

This comment has been minimized.

Copy link
Owner Author

@cliss cliss commented Dec 2, 2014

¯_(ツ)_/¯ no reason, really.

@colmulhall

This comment has been minimized.

Copy link

@colmulhall colmulhall commented Dec 3, 2014

Pretty useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment