Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated crimemap

  • Loading branch information...
commit 00e54f5369ad28b26278da5ed5ef8481df1dfe65 1 parent b0589a3
Bob Roberts authored
View
4 crimemap/mapper/sql/crime.sql
@@ -0,0 +1,4 @@
+INSERT INTO mapper_crime (type, date, longitude, latitude, address) VALUES ('homicide', '2006-01-05', -78.817828, 42.904851, '17 Rapin Place');
+INSERT INTO mapper_crime (type, date, longitude, latitude, address) VALUES ('homicide', '2006-04-17', -78.889458,42.897707, '155 Pennsylvania Street');
+INSERT INTO mapper_crime (type, date, longitude, latitude, address) VALUES ('homicide', '2006-01-10', -78.884766,42.915257, '446 West Ferry');
+INSERT INTO mapper_crime (type, date, longitude, latitude, address) VALUES ('arson', '2006-01-23', -78.849456,42.892344, '54 Grey Street');
View
13 crimemap/settings.py
@@ -78,13 +78,14 @@
ROOT_URLCONF = 'crimemap.urls'
TEMPLATE_DIRS = (
- "./templates/")
+ "./templates/"
+)
INSTALLED_APPS = (
- 'django.contrib.auth',
- 'django.contrib.contenttypes',
- 'django.contrib.sessions',
- 'django.contrib.sites',
- 'django.contrib.messages',
+# 'django.contrib.auth',
+# 'django.contrib.contenttypes',
+# 'django.contrib.sessions',
+# 'django.contrib.sites',
+# 'django.contrib.messages',
'crimemap.mapper',
)
View
BIN  crimemap/settings.pyc
Binary file not shown
View
50 crimemap/templates/crime_by_type.html
@@ -1,3 +1,47 @@
-{% for crime in crime_list %}
-{{crime.longitude}},{{crime.latitude}},{{crime.address}},{{crime.type}},{{crime.date}}
-{% endfor %}
+<html style="height:100%;">
+<head>
+<title>Buffalo Crime Map</title>
+<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;" type="text/javascript">
+</script>
+</head>
+
+<body onload="" onunload="GUnload()" style="height:100%;padding:0;margin:0;">
+<script type="text/javascript">
+var map_long = -78.820000;
+var map_lat = 42.938000;
+var map_zoom = 5;
+var crimes = [{% for crime in crime_list %}[{{crime.longitude}},{{ crime.latitude }},'{{ crime.address }}','{{ crime.type }}','{{ crime.date }}']{% if not forloop.last %},{% endif %}{% endfor %}];
+</script>
+
+<div id="map" style="height:100%;width:100%;">
+</div>
+
+<script type="text/javascript">
+function addCrimeMarker(lng, lat, address, crime_type, crime_date) {
+ var markerpt = new GPoint(lng, lat);
+ var marker = new GMarker(markerpt);
+ var html = '<b>' + crime_type + '</b><br>' + address + '<br>' + crime_date;
+ GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); });
+ map.addOverlay(marker);
+}
+
+if (GBrowserIsCompatible()) {
+ var map_div = document.getElementById("map");
+ var map = new GMap2(map_div);
+
+ map.addControl(new GSmallMapControl());
+ map.addControl(new GMapTypeControl());
+
+ var pt = new GLatLng(top.map_lat, top.map_long);
+ map.setCenter(pt, 17 - top.map_zoom);
+
+ if (crimes) {
+ for (var i=0; i < crimes.length; i++) {
+ addCrimeMarker(crimes[i][0], crimes[i][1], crimes[i][2], crimes[i][3], crimes[i][4]);
+ }
+ }
+}
+</script>
+
+</body>
+</html>
View
1  crimemap/urls.py
@@ -1,7 +1,6 @@
from django.conf.urls.defaults import *
-
urlpatterns = patterns('',
(r'^crime/([A-Za-z]+)', 'crimemap.mapper.views.crime_by_type'),
View
BIN  crimemap/urls.pyc
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.