[Swift-commit] r7619 - www/usage

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Tue Feb 25 10:46:03 CST 2014


Author: davidk
Date: 2014-02-25 10:46:03 -0600 (Tue, 25 Feb 2014)
New Revision: 7619

Added:
   www/usage/heatmap.php
Modified:
   www/usage/locations.php
Log:
Adjust locations.php parameters (turn off panning, zoom controls, etc)
Add Swift usage heatmap


Added: www/usage/heatmap.php
===================================================================
--- www/usage/heatmap.php	                        (rev 0)
+++ www/usage/heatmap.php	2014-02-25 16:46:03 UTC (rev 7619)
@@ -0,0 +1,101 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Heatmaps</title>
+    <style>
+      html, body, #map-canvas {
+        height: 100%;
+        margin: 0px;
+        padding: 0px
+      }
+      #panel {
+        position: absolute;
+        top: 5px;
+        left: 50%;
+        margin-left: -180px;
+        z-index: 5;
+        background-color: #fff;
+        padding: 5px;
+        border: 1px solid #999;
+      }
+    </style>
+    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=visualization"></script>
+    <script>
+
+var map, pointarray, heatmap;
+
+var locationData = [
+   <?php
+      $lines = file('http://swiftlang.org/usage/latlons');
+      foreach($lines as $line_num => $line) {
+         list($city, $lat, $lon, $num) = split(',', $line);
+         $num = rtrim($num);
+         if(!is_numeric($lat) || !is_numeric($lon)) { continue; }
+         echo "new google.maps.LatLng($lat, $lon),\n";
+      }
+   ?>
+];
+
+var latlngbounds = new google.maps.LatLngBounds();     
+<?php
+foreach($lines as $line_num => $line) {
+         list($city, $lat, $lon, $num) = split(',', $line);
+         $num = rtrim($num);
+         if(!is_numeric($lat) || !is_numeric($lon)) { continue; }   
+         echo "latlngbounds.extend( new google.maps.LatLng($lat, $lon));\n";
+}
+?>
+
+function initialize() {
+  var mapOptions = {
+    zoom: 8,
+    center: new google.maps.LatLng(37.774546, -122.433523),
+    mapTypeId: google.maps.MapTypeId.SATELLITE,
+    panControl: false,
+    zoomControl: false,
+    scaleControl: false,
+    streetViewControl: false,
+    draggable: false,
+  };
+
+  map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
+  map.fitBounds(latlngbounds);
+
+  var pointArray = new google.maps.MVCArray(locationData);
+
+  heatmap = new google.maps.visualization.HeatmapLayer({
+    data: pointArray
+  });
+  heatmap.set('opacity', 1.0);
+  heatmap.set('radius', 15);
+
+  var gradient = [
+    'rgba(0, 255, 255, 0)',
+    'rgba(0, 255, 255, 1)',
+    'rgba(0, 191, 255, 1)',
+    'rgba(0, 127, 255, 1)',
+    'rgba(0, 63, 255, 1)',
+    'rgba(0, 0, 255, 1)',
+    'rgba(0, 0, 223, 1)',
+    'rgba(0, 0, 191, 1)',
+    'rgba(0, 0, 159, 1)',
+    'rgba(0, 0, 127, 1)',
+    'rgba(63, 0, 91, 1)',
+    'rgba(127, 0, 63, 1)',
+    'rgba(191, 0, 31, 1)',
+    'rgba(255, 0, 0, 1)'
+  ]
+  heatmap.set('gradient', gradient);
+
+  heatmap.setMap(map);
+}
+
+google.maps.event.addDomListener(window, 'load', initialize);
+
+    </script>
+  </head>
+  <body>
+    <div id="map-canvas"></div>
+  </body>
+</html>

Modified: www/usage/locations.php
===================================================================
--- www/usage/locations.php	2014-02-25 04:34:37 UTC (rev 7618)
+++ www/usage/locations.php	2014-02-25 16:46:03 UTC (rev 7619)
@@ -11,7 +11,7 @@
   <script type="text/javascript">
     var locations = [
     <?php
-       $lines = file('http://www.ci.uchicago.edu/swift/wwwdev/usage/latlons');
+       $lines = file('http://swiftlang.org/usage/latlons');
        foreach($lines as $line_num => $line) {
            list($city, $lat, $lon, $num) = split(',', $line);
            $num = rtrim($num);
@@ -24,7 +24,7 @@
     var latlngbounds = new google.maps.LatLngBounds(); 
 
     <?php
-       $lines = file('http://www.ci.uchicago.edu/swift/wwwdev/usage/latlons');
+       $lines = file('http://swiftlang.org/usage/latlons');
        foreach($lines as $line_num => $line) {
            if(empty($lat) || empty($lon)){ continue; }
            list($city, $lat, $lon, $num) = split(',', $line);
@@ -37,7 +37,12 @@
 
     var map = new google.maps.Map(document.getElementById('map'), {
       zoom: 8,
-      mapTypeId: google.maps.MapTypeId.HYBRID
+      mapTypeId: google.maps.MapTypeId.HYBRID,
+      panControl: false,
+      zoomControl: false,
+      scaleControl: false,
+      streetViewControl: false,
+      draggable: false,
     });
     map.fitBounds(latlngbounds);
 




More information about the Swift-commit mailing list