Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
clementmiao committed Mar 12, 2014
1 parent 794bb69 commit 6e5eb2e
Show file tree
Hide file tree
Showing 13 changed files with 488,464 additions and 80 deletions.
14 changes: 7 additions & 7 deletions chicago_api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@
}
}

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'chicago_api',
'USER': 'clementmiao',
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.postgresql_psycopg2',
# 'NAME': 'chicago_api',
# 'USER': 'clementmiao',
# }
# }

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
Expand Down
1 change: 1 addition & 0 deletions chicago_api/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf.urls import patterns, include, url

from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',
Expand Down
2 changes: 0 additions & 2 deletions chicago_api/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from django.shortcuts import render
from django.http import HttpResponse
from social_data.models import Service, Post
from social_data import twitter

def home(request):
# t = twitter.twitter()
data_list = []
for p in Post.objects.all():
dictionary = {}
Expand Down
77 changes: 77 additions & 0 deletions gmap/templates/gmap/map_sentiment.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{% block api %}
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDpBiWzKU1WaL6QeiDenEPNp0UQhLsLnXs&sensor=false&libraries=visualization"></script>

{% endblock api %}

{% block init_map %}
<script type="text/javascript" src="http://geoxml3.googlecode.com/svn/branches/polys/geoxml3.js"></script>
<script type="text/javascript">

var heatmap;

var map;

var heat_data;

// window.onload = function() {
function initialize() {
var lat_long = new google.maps.LatLng({{latitude}}, {{longitude}});
var mapOptions = {
center: lat_long,
zoom: {{zoom}},
mapTypeId: google.maps.MapTypeId.{{map_type}}
};

map = new google.maps.Map(document.getElementById("{{ html_id }}"), mapOptions);

var kml = "{{ kml }}"

myParser = new geoXML3.parser({map: map});
myParser.parse(kml);

heat_data = []
{% if data %}

function createMarker(latitude, longitude, string, icon, image) {
var marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map,
icon: icon,
animation: google.maps.Animation.DROP,
})
var contentString = string;

if (image != "") {
contentString = '<IMG BORDER="0" ALIGN="Left" SRC=' + image + '>' + contentString
}

var infoWindow = new google.maps.InfoWindow({
content: contentString
});

google.maps.event.addListener(marker, 'click', function() {
infoWindow.open(map,marker);
});
}

{% for p in data %}

createMarker({{p.latitude}},{{p.longitude}}, "{{p.title|escapejs}}", "{{p.icon}}", "{{p.image}}");

var item = new google.maps.LatLng({{p.latitude}}, {{p.longitude}});
heat_data.push(item);

{% endfor %}

var pointArray = new google.maps.MVCArray(heat_data);



{% endif %}


}
google.maps.event.addDomListener(window, 'load', initialize);

</script>
{% endblock init_map %}
4 changes: 3 additions & 1 deletion gmap/templatetags/gmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
register = template.Library()

@register.inclusion_tag('gmap/map.html')
@register.inclusion_tag('gmap/map_sentiment.html')
def gmap(html_id, latitude, longitude, **kwargs):
"""
{% gmap <html_id> <latitude> <longitude> [zoom=<zoom>] [map_type=<map_type>]
Expand All @@ -22,4 +23,5 @@ def gmap(html_id, latitude, longitude, **kwargs):
if m_data:
data['data'] = m_data

return data
return data

27 changes: 27 additions & 0 deletions gmap/templatetags/gmap_sentiment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django import template

register = template.Library()

@register.inclusion_tag('gmap/map_sentiment.html')

def gmap_sentiment(html_id, latitude, longitude, kml, **kwargs):
"""
{% gmap <html_id> <latitude> <longitude> [zoom=<zoom>] [map_type=<map_type>]
[data=[<map_data>] %}
"""
zoom = kwargs.get('zoom', 15)
map_type = kwargs.get('map_type', 'ROADMAP')
m_data = kwargs.get('data')
data = {
'html_id': html_id,
'latitude': latitude,
'longitude': longitude,
'zoom': zoom,
'map_type': map_type,
'kml': kml
}

if m_data:
data['data'] = m_data

return data
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ static==1.0.2
tweepy==2.2
wsgiref==0.1.2
nltk==2.0.4
facepy==0.9.0
Loading

0 comments on commit 6e5eb2e

Please sign in to comment.