Skip to content
Browse files

Merge branch 'master' of github.com:hubgit/radibus

  • Loading branch information...
2 parents c7285b3 + 927e631 commit afb56525ad325aba852ec70970efb1b72964ec45 root committed Aug 8, 2010
Showing with 23 additions and 10 deletions.
  1. +22 −9 script.js
  2. +1 −1 stops_mysql.php
View
31 script.js
@@ -5,6 +5,7 @@ var App = {
markers: [],
lines: [],
routes: [],
+ bookends: [],
color: 0,
init: function(){
@@ -45,10 +46,14 @@ var App = {
App.lines[i].setMap(null);
App.lines = [];
+ for (i in App.bookends)
+ App.bookends[i].setMap(null);
+ App.bookends = [];
+
App.color = 0;
}
- App.markers.push(new google.maps.Marker({ position: location, map: App.map, draggable: true, icon: "http://chart.apis.google.com/chart?chst=d_map_spin&chld=1|0|FFFF77|10|_|" + (App.markers.length ? "end" : "start") }));
+ App.markers.push(new google.maps.Marker({ position: location, map: App.map, draggable: true, icon: "http://chart.apis.google.com/chart?chst=d_map_spin&chld=1|0|FFFFFF|10|_|" + (App.markers.length ? "end" : "start") }));
if (App.markers.length == 2){
var positions = [];
@@ -78,26 +83,34 @@ var App = {
App.routes[routeId] = [];
var route = data["stops"][routeId];
+ //var color = "#" + Math.round(0xffffff * Math.random()).toString(16);
+ var color = App.colors[App.color++];
+
+ var count = 0;
+
for (var i in route){
var position = new google.maps.LatLng(parseFloat(route[i]["Latitude"]), parseFloat(route[i]["Longitude"]));
App.routes[routeId].push(position);
App.bounds.extend(position);
- //new google.maps.Marker({ position: position, map: App.map });
+
+ if (count++ == 0)
+ App.bookends.push(new google.maps.Marker({ position: position, map: App.map, draggable: true, icon: "http://chart.apis.google.com/chart?chst=d_map_spin&chld=1|0|" + color + "|10|_|" + routeId }));
+
}
- App.drawRoute(routeId);
+ if (count > 1)
+ App.bookends.push(new google.maps.Marker({ position: position, map: App.map, draggable: true, icon: "http://chart.apis.google.com/chart?chst=d_map_spin&chld=1|0|" + color + "|10|_|" + routeId }));
+
+ App.drawRoute(routeId, color);
}
App.map.fitBounds(App.bounds);
},
- drawRoute: function(routeId){
- //var color = "#" + Math.round(0xffffff * Math.random()).toString(16);
- var color = "#" + App.colors[App.color++];
-
+ drawRoute: function(routeId, color){
var line = new google.maps.Polyline({
path: App.routes[routeId],
- strokeColor: color,
+ strokeColor: "#" + color,
strokeOpacity: 0.5,
strokeWeight: 4
});
@@ -111,7 +124,7 @@ var App = {
listRoute: function(routeId, color){
var li = $("<li class='route'/>").attr("id", "route-" + routeId).mouseover(App.highlightRoute).mouseout(App.unhighlightRoute);
li.append(
- $("<span class='legend'/>").css("background-color", color)
+ $("<span class='legend'/>").css("background-color", "#" + color)
);
li.append(
$("<span class='route-text'/>").text(routeId)
View
2 stops_mysql.php
@@ -20,7 +20,7 @@
$sql = "SELECT id, (%d * acos(cos(radians(%f)) * cos(radians(latitude)) * cos(radians(longitude) - radians(%f)) + sin(radians(%f)) * sin(radians(latitude)))) AS distance,
latitude as Latitude, longitude as Longitude, route as Route, run as Run, `order` as `Order`
- FROM stops HAVING distance < (%f * 60) ORDER BY distance LIMIT 0,1000";
+ FROM stops HAVING distance < (%f * 70) LIMIT 0,10000";
$factor = 3959; // using 3959 miles as Earth's radius
$result = $db->query($sql, $factor, $lat, $lon, $lat, $radius);

0 comments on commit afb5652

Please sign in to comment.
Something went wrong with that request. Please try again.