This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Parser { | |
public Route parse(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. **/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; |
OlderNewer