Skip to content

Instantly share code, notes, and snippets.

@kento1218
Created April 24, 2011 18:31
Show Gist options
  • Select an option

  • Save kento1218/939779 to your computer and use it in GitHub Desktop.

Select an option

Save kento1218/939779 to your computer and use it in GitHub Desktop.
Plot location info in iPhone consolidated.db
import sqlite3
import sys
import json
import datetime
def main():
data = []
dbfile = sys.argv[1]
conn = sqlite3.connect(dbfile)
sql = 'select Timestamp, Latitude, Longitude from CellLocation'
for row in conn.execute(sql):
times = datetime.datetime.fromtimestamp(1000000000 + row[0])
timestr = times.strftime('%Y/%m/%d %H:%M:%S')
data.append({'time':timestr, 'lat':row[1], 'lng':row[2]})
print 'data=%s' % (json.dumps(data))
conn.close()
if __name__ == '__main__':
main()
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<!-- data.js contains output of celllocation.py -->
<script type="text/javascript" src="data.js"></script>
<script type="text/javascript">
function init() {
var myLatlng = new google.maps.LatLng(36.0,135.5);
var myOptions = {
zoom: 5,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
for(i = 0; i < data.length; i++) {
row = data[i]
var marker = new google.maps.Marker({
position: new google.maps.LatLng(row.lat, row.lng),
title:row.time,
map: map
});
}
}
</script>
<body onload="init()">
<div style="width: 100%; height: 100%;" id="map_canvas"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment