Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions plotmap/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
</head>
<body>
<div id="plotmap" style="width:1000px;height:600px;"></div>
<input id="dataid" type="hidden" value="0"/>
<input id="dataid" type="hidden" value="-1"/>
<script>
var lat={{data.lat}};
var lang={{data.lang}};
var name='{{data.name}}';
var myCenter=new google.maps.LatLng(lat,lang);
myTrip1=[myCenter];
myTrip2=[];
myTrip3=[];
var mapProp = {
center:myCenter,
zoom:10,
Expand Down Expand Up @@ -55,6 +56,7 @@
function plotmaps()
{
incr=document.getElementById("dataid").value;

$.ajax({
url:'/ajax',
type: "POST",
Expand All @@ -65,10 +67,19 @@
else
{
item=JSON.parse(data);
document.getElementById("dataid").value=item['incr'];
x=new google.maps.LatLng(item['lat'],item['long']);
plotnew(myTrip1,x,item['name'],item['lat'],item['long']);
plotnew(myTrip2,x,item['name'],item['lat'],item['long']);
incr = parseInt(incr) + 1;
document.getElementById("dataid").value=incr;
var i =1
for(each in item){
x=new google.maps.LatLng(item[each]['lat'],item[each]['long']);
if(i == 1){myTrip1.push(x);path1(myTrip1,x,item[each]['name'],item[each]['lat'],item[each]['long'])}
if(i == 2){myTrip2.push(x);path1(myTrip2,x,item[each]['name'],item[each]['lat'],item[each]['long'])}
if(i == 3){myTrip3.push(x);path1(myTrip3,x,item[each]['name'],item[each]['lat'],item[each]['long'])}
i = i + 1;
}
//x=new google.maps.LatLng(item['lat'],item['long']);
//plotnew(myTrip1,x,item['name'],item['lat'],item['long']);
//plotnew(myTrip2,x,item['name'],item['lat'],item['long']);
}
}

Expand Down
51 changes: 39 additions & 12 deletions plotmap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,49 @@ def getLocation(request,incr=0):
incr=request.POST.get('incr', False)
incr=int(incr)+1
id1=request.POST.get('id', False)
path1=path.objects.get(id=id1)
data=data=path1.pathid.all()
dic={}
len1=len(path1.pathid.all())
print len1
path1=path.objects.get(id=1)
path2=path.objects.get(id=2)
path3=path.objects.get(id=3)
#data=data=path1.pathid.all()
#dic={}
#len1=len(path1.pathid.all())
#print len1
lst=[]
if (incr < len1):
print incr
if (incr < len(path1.pathid.all())):
data=path1.pathid.all()[incr]
dic['id']=data.id
dic['incr']=incr
dic['name']=data.name
dic['lat']=float(data.lat)
dic['long']=float(data.lang)
return HttpResponse(json.dumps(dic))
dic1 = {}
dic1['id']=data.id
dic1['incr']=incr
dic1['name']=data.name
dic1['lat']=float(data.lat)
dic1['long']=float(data.lang)
lst.append(dic1)
else:
return HttpResponse("Finished")
if (incr < len(path2.pathid.all())):
data=path2.pathid.all()[incr]
dic2 = {}
dic2['id']=data.id
dic2['incr']=incr
dic2['name']=data.name
dic2['lat']=float(data.lat)
dic2['long']=float(data.lang)
lst.append(dic2)
if (incr < len(path3.pathid.all())):
data=path3.pathid.all()[incr]
dic3 = {}
dic3['id']=data.id
dic3['incr']=incr
dic3['name']=data.name
dic3['lat']=float(data.lat)
dic3['long']=float(data.lang)
lst.append(dic3)
print lst
return HttpResponse(json.dumps(lst))

# else:
# return HttpResponse("Finished")