Permalink
Browse files

update 2 city data

  • Loading branch information...
1 parent 663d18d commit df6a6e43688e6adb34d226316a869e11d5fe67e5 @lishugo committed Feb 11, 2011
Showing with 40 additions and 9 deletions.
  1. +31 −0 city_stats.js
  2. +9 −9 rentbuy.html
View
@@ -0,0 +1,31 @@
+var city_stats = [
+ { id: "beijing", code: "Th", population: 19720000, price_per_m:22650, annual_rent:36000, price_rent_ratio:47, salary:48444, lat: 39.904214, lon: 116.407413 },
+ { id: "shanghai", code: "SA", population: 19213200, price_per_m:23478, annual_rent:9233.23, price_rent_ratio:52, salary:42789, lat: 31.230393, lon: 121.473704 },
+/* { id: "guangzhou", code: "Th", date: "2009-03-20T00:00:00-07:00", lat: 37.776394, lon: -122.160752 },
+ { id: "shenzhen", code: "Bu", date: "2009-03-20T00:00:00-07:00", lat: 37.739572, lon: -122.153254 },
+ { id: "tianjin", code: "Va", date: "2009-03-19T23:30:00-07:00", lat: 37.810612, lon: -122.283648 },
+ { id: "nanjing", code: "SA", date: "2009-03-19T23:09:00-07:00", lat: 37.804087, lon: -122.271248 },
+ { id: "hangzhou", code: "Ro", date: "2009-03-19T23:00:00-07:00", lat: 37.771985, lon: -122.148367 },
+ { id: "chengdu", code: "SA", date: "2009-03-19T22:30:00-07:00", lat: 37.82387, lon: -122.257414 },
+ { id: "dalian", code: "Th", date: "2009-03-19T22:30:00-07:00", lat: 37.812051, lon: -122.207804 },
+ { id: "qingdao", code: "SA", date: "2009-03-19T22:20:00-07:00", lat: 37.806634, lon: -122.287244 },
+ { id: "shenyang", code: "VT", date: "2009-03-19T22:15:00-07:00", lat: 37.728821, lon: -122.17316 }
+other cities
+ */
+ ];
+
+var codes = [
+ { code: "AA", name: "Aggravated Assault", category: "violent" },
+ { code: "Mu", name: "Murder", category: "violent" },
+ { code: "Ro", name: "Robbery", category: "violent" },
+ { code: "SA", name: "Simple Assault", category: "violent" },
+ { code: "Ar", name: "Arson", category: "property" },
+ { code: "Bu", name: "Burglary", category: "property" },
+ { code: "Th", name: "Theft", category: "property" },
+ { code: "Va", name: "Vandalism", category: "property" },
+ { code: "VT", name: "Vehicle Theft", category: "property" },
+ { code: "Al", name: "Alcohol", category: "quality" },
+ { code: "DP", name: "Disturbing the Peace", category: "quality" },
+ { code: "Na", name: "Narcotics", category: "quality" },
+ { code: "Pr", name: "Prostitution", category: "quality" }
+];
View
@@ -3,7 +3,7 @@
<title>rent or buy</title>
<script src="protovis-d3.2.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAYZ9eMYFYusxZt-1RKXLI7RQGpXqX26B62_lhdlIUxPTUm0CSORRw1BkwdprB1xQ3Xa8KfbgKAacxlw" type="text/javascript"></script>
- <script src="house.js" type="text/javascript"></script>
+ <script src="city_stats.js" type="text/javascript"></script>
<style type="text/css">
body {
@@ -29,8 +29,8 @@
codes.forEach(function(x) colors[x.code] = colors[x.category]);
-function Canvas(rentbuy) {
- this.rentbuy = rentbuy;
+function Canvas(city_stats) {
+ this.city_stats = city_stats;
}
Canvas.prototype = pv.extend(GOverlay);
@@ -46,8 +46,8 @@
if (!force) return;
var c = this.canvas, m = this.map, r = 20;
- /* Get the pixel locations of the rentbuy. */
- var pixels = this.rentbuy.map(function(d) {
+ /* Get the pixel locations of the city_stats. */
+ var pixels = this.city_stats.map(function(d) {
return m.fromLatLngToDivPixel(new GLatLng(d.lat, d.lon));
});
@@ -66,7 +66,7 @@
.left(-x.min)
.top(-y.min)
.add(pv.Panel)
- .data(this.rentbuy)
+ .data(this.city_stats)
.add(pv.Dot)
.left(function() pixels[this.parent.index].x)
.top(function() pixels[this.parent.index].y)
@@ -80,13 +80,13 @@
};
/* Restrict minimum and maximum zoom levels. */
-G_NORMAL_MAP.getMinimumResolution = function() 11;
+G_NORMAL_MAP.getMinimumResolution = function() 4;
G_NORMAL_MAP.getMaximumResolution = function() 14;
var map = new GMap2(document.getElementById("map"));
-map.setCenter(new GLatLng(37.78, -122.22), 12);
+map.setCenter(new GLatLng(35, 112), 5);
map.setUI(map.getDefaultUI());
-map.addOverlay(new Canvas(rentbuy));
+map.addOverlay(new Canvas(city_stats));
</script>
</head>

0 comments on commit df6a6e4

Please sign in to comment.