Skip to content

Instantly share code, notes, and snippets.

View jd-alexander's full-sized avatar
🏠
Working from home

Joel Dean jd-alexander

🏠
Working from home
View GitHub Profile
* Authors: Joel Dean and Evon Franklin
* Date: 12/31/12
* Time: 8:30 PM
*/
$(document).ready(function(){
//Grabs url path
<div id="nav">
<ul>
<li class="current-menu-item"><a href="about_us.php">About Us</a></li>
<li><a href="work.php">Our Work</a></li>
<li><a href="contact.php">Contact Us</a></li>
</ul>
</div>
/*
Slightly modified by Joel Dean
Created by TheNally
Original post here : http://bit.ly/UI2uBC
*/
$(function(){
var url = window.location.pathname,
urlRegExp = new RegExp(url.replace(/\/$/,''));
$('#nav li a').each(function(){
@jd-alexander
jd-alexander / Parser.java
Created February 11, 2013 14:29
Parser.java written by Hesham Saeed
public interface Parser {
public Route parse();
}
@jd-alexander
jd-alexander / XMLParser.java
Created February 11, 2013 14:31
XMLParser.java written by Hesham Saeed
public class XMLParser {
// names of the XML tags
protected static final String MARKERS = "markers";
protected static final String MARKER = "marker";
protected URL feedUrl;
protected XMLParser(final String feedUrl) {
try {
this.feedUrl = new URL(feedUrl);
@jd-alexander
jd-alexander / Segment.java
Created February 11, 2013 14:32
Segment.java written by Hesham Saeed
public class Segment {
/** Points in this segment. **/
private GeoPoint start;
/** Turn instruction to reach next segment. **/
private String instruction;
/** Length of segment. **/
private int length;
/** Distance covered. **/
private double distance;
@jd-alexander
jd-alexander / Route.java
Created February 11, 2013 14:32
Route.java written by Hesham Saeed
public class Route {
private String name;
private final List<GeoPoint> points;
private List<Segment> segments;
private String copyright;
private String warning;
private String country;
private int length;
private String polyline;
@jd-alexander
jd-alexander / GoogleParser.java
Created February 11, 2013 14:34
GoogleParser.java written by Hesham Saeed
public class GoogleParser extends XMLParser implements Parser {
/** Distance covered. **/
private int distance;
public GoogleParser(String feedUrl) {
super(feedUrl);
}
/**
* Parses a url pointing to a Google JSON object to a Route object.
@jd-alexander
jd-alexander / RouteOverlay.java
Created February 11, 2013 14:35
RouteOverlay.java written by Hesham Saeed
public class RouteOverlay extends Overlay {
/** GeoPoints representing this routePoints. **/
private final List<GeoPoint> routePoints;
/** Colour to paint routePoints. **/
private int colour;
/** Alpha setting for route overlay. **/
private static final int ALPHA = 120;
/** Stroke width. **/
private static final float STROKE = 4.5f;
/** Route path. **/
@jd-alexander
jd-alexander / Map.java
Created February 11, 2013 14:51
Map.java by Hesham Saeed
//this was added to his oncreate method.
MapView mapView = (MapView) findViewById(R.id.mapview); //or you can declare it directly with the API key
Route route = directions(new GeoPoint((int)(26.2*1E6),(int)(50.6*1E6)), new GeoPoint((int)(26.3*1E6),(int)(50.7*1E6)));
RouteOverlay routeOverlay = new RouteOverlay(route, Color.BLUE);
mapView.getOverlays().add(routeOverlay);
mapView.invalidate();
//this function was added to the activity with the map.
private Route directions(final GeoPoint start, final GeoPoint dest) {
Parser parser;