Permalink
Browse files

Colorized routes.

  • Loading branch information...
1 parent 4560016 commit ef690a40d059f397c9ede12dd3ae2b378cd0dab3 @jchambers committed Feb 12, 2012
Showing with 20 additions and 1 deletion.
  1. +20 −1 WebContent/index.html
View
@@ -5,11 +5,14 @@
<link rel="stylesheet" type="text/css" href="./style.css"/>
+ <script type="text/javascript" src="./color.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBh5tr_9rX67c3tr5L9yJKhdkZcIXteC2k&amp;sensor=false"></script>
<script type="text/javascript" src="./jquery-1.7.1.js"></script>
<script type="text/javascript">
+ var routeColors = {};
var visibleLines = [];
+ var circle = null;
function initialize() {
var map = new google.maps.Map(document.getElementById("map"), {
@@ -29,12 +32,27 @@
var center = map.getCenter();
+ if(circle) {
+ circle.setMap(null);
+ }
+
+ circle = new google.maps.Circle({
+ "center": center,
+ "radius": 500,
+ "map": map
+ });
+
$.get("./route", {
"latitude": center.lat(),
"longitude": center.lng(),
"distance": 500
}, function(data) {
for(var i = 0; i < data.length; i++) {
+ // Choose a color for this route if we haven't seen it before
+ if(!routeColors[data[i]["id"]]) {
+ routeColors[data[i]["id"]] = generateNextColor(0.95, 0.85);
+ }
+
if(data[i]["shapes"].length > 0) {
var points = [];
@@ -45,7 +63,8 @@
}
var polyline = new google.maps.Polyline({
- "path": points
+ "path": points,
+ "strokeColor": routeColors[data[i]["id"]]
});
visibleLines[i] = polyline;

0 comments on commit ef690a4

Please sign in to comment.