Map on mainpage
This commit is contained in:
parent
230f1e6a36
commit
3fa4bdaafd
Binary file not shown.
|
@ -16,6 +16,8 @@
|
|||
|
||||
{% block content %}
|
||||
|
||||
{{ form.media }}
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
|
|
|
@ -111,6 +111,7 @@ def deleteEvent( request, pk ):
|
|||
|
||||
from django.views.generic.edit import UpdateView, CreateView
|
||||
|
||||
from location_field.widgets import LocationWidget
|
||||
|
||||
class EventForm( ModelForm ):
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -121,10 +122,11 @@ class EventForm( ModelForm ):
|
|||
|
||||
class Meta:
|
||||
model = Event
|
||||
fields= ['title', 'type', 'date','time', 'meeting_time', 'location', 'desc', ]
|
||||
fields= [ 'type', 'title', 'date','time', 'meeting_time', 'location', 'map_location', 'desc', ]
|
||||
|
||||
widgets = {
|
||||
'location' : TextInput(),
|
||||
'map_location' : LocationWidget(),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
box-shadow: 0 0 7px 0 rgba(26, 26, 26, 0.4);
|
||||
padding: 33px 0 33px;
|
||||
background: white;
|
||||
top: 41%;
|
||||
top: 70%;
|
||||
border-radius: 4px;
|
||||
}
|
||||
#contact .map .box_wrapp .box_cont{
|
||||
|
@ -166,6 +166,7 @@
|
|||
box-shadow: none;
|
||||
border-radius: 3px;
|
||||
margin: 0 auto;
|
||||
margin-top: 20px;
|
||||
display: block;
|
||||
width: 56%;
|
||||
-webkit-transition: background linear .2s, box-shadow linear .2s;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
{% endaddtoblock %}
|
||||
|
||||
|
@ -74,6 +75,7 @@
|
|||
|
||||
{% addtoblock "css" strip %}<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/lib/animate.css" media="screen, projection">{% endaddtoblock %}
|
||||
{% addtoblock "css" strip %}<link rel="stylesheet" href="{{STATIC_URL}}/css/coming-soon.css" type="text/css" media="screen" />{% endaddtoblock %}
|
||||
{% addtoblock "css" strip %}<link rel="stylesheet" href="{{STATIC_URL}}/css/contact.css" type="text/css" media="screen" />{% endaddtoblock %}
|
||||
|
||||
{% if event %}
|
||||
|
||||
|
@ -159,5 +161,103 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% addtoblock "js" %}
|
||||
<script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false&language=de"></script>
|
||||
<script type="text/javascript" src="{{STATIC_URL}}/js/jquery-ui-1.10.0.custom.min.js" ></script>
|
||||
|
||||
{% if hasNextConcertInfo %}
|
||||
<script type="text/javascript">
|
||||
// Kartenparameter beim Laden der Seite festlegen
|
||||
$(document).ready(function() {
|
||||
// Das Element für die Anzeige suchen
|
||||
var m = $("#map")[0];
|
||||
// Mittelpunkt der Karte
|
||||
var myLatlng = new google.maps.LatLng(49.340174,10.890595);
|
||||
var myOptions = {
|
||||
zoom: 10,
|
||||
center: myLatlng,
|
||||
mapTypeId: google.maps.MapTypeId.ROAD,
|
||||
}
|
||||
var directionsService = new google.maps.DirectionsService();
|
||||
var directionsDisplay = new google.maps.DirectionsRenderer();
|
||||
var map = new google.maps.Map(m, myOptions);
|
||||
|
||||
directionsDisplay.setMap( map );
|
||||
|
||||
var request = {
|
||||
origin: "{{routeInfo.origin}}",
|
||||
destination: "{{routeInfo.destination}}",
|
||||
travelMode: google.maps.DirectionsTravelMode.DRIVING
|
||||
}
|
||||
|
||||
directionsService.route(request, function(response, status) {
|
||||
if (status == google.maps.DirectionsStatus.OK) {
|
||||
directionsDisplay.setDirections(response);
|
||||
|
||||
var leg = response.routes[0].legs[0];
|
||||
|
||||
$("#route_duration").html( leg.duration.text );
|
||||
$("#route_distance").html( leg.distance.text ) ;
|
||||
}
|
||||
});
|
||||
|
||||
$("#map_box a").click( function() {
|
||||
$("#map_box").hide();
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% endaddtoblock %}
|
||||
|
||||
|
||||
|
||||
{% addtoblock "css" %}
|
||||
<style>
|
||||
#map {
|
||||
width: 100%;
|
||||
height: 480px;
|
||||
}
|
||||
#map_box a {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
</style>
|
||||
{% endaddtoblock %}
|
||||
|
||||
{% if hasNextConcertInfo %}
|
||||
<div id="contact">
|
||||
<div id="map"></div>
|
||||
|
||||
<div id="map_box" class="row map">
|
||||
<div class="container">
|
||||
<div id="route_info_box" class="span5 box_wrapp">
|
||||
<div class="box_cont">
|
||||
<div class="head">
|
||||
<h6>Fahrt zum Konzert:</h6>
|
||||
</div>
|
||||
Nächstes Konzert ist in {{nextConcert.location}} am {{nextConcert.date}} um {{nextConcert.time | time:"H:i" }} <br/>
|
||||
{% if nextConcert.meeting_time %} Treffpunkt ist um {{ nextConcert.meeting_time | time:"H:i" }} <br/> {% endif %}
|
||||
|
||||
<table>
|
||||
<tr> <td> Fahrzeit:</td> <td> <span id="route_duration"></span> </td> </tr>
|
||||
<tr> <td> Strecke: </td> <td> <span id="route_distance"></span> </td> </tr>
|
||||
</table>
|
||||
<a class="btn" >Schliessen</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from django.contrib.auth.decorators import login_required
|
|||
|
||||
|
||||
from eventplanner.models import Event, EventParticipation
|
||||
from musicians.models import Musician
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
|
@ -36,6 +37,28 @@ def home_view(request):
|
|||
context['hasParticipationSetForAllEvents'] = True
|
||||
|
||||
|
||||
|
||||
nextConcerts = Event.objects.filter( date__gte = datetime.now(), type = 'Conc' ).order_by('date')[:1]
|
||||
if len( nextConcerts) > 0 :
|
||||
nextConcert = nextConcerts[0]
|
||||
|
||||
routeInfo = dict()
|
||||
|
||||
user = Musician.objects.get( user = request.user );
|
||||
routeInfo['origin'] = user.street + ", " + str( user.zip_code ) + " " + user.city
|
||||
|
||||
if nextConcert.map_location:
|
||||
# map_location has format "lat,longitute,zoomlevel"
|
||||
routeInfo['destination'] = ",".join( nextConcert.map_location.split(",")[:2] )
|
||||
else:
|
||||
routeInfo['destination'] = nextConcert.location
|
||||
|
||||
context['routeInfo'] = routeInfo
|
||||
context['nextConcert'] = nextConcert
|
||||
context['hasNextConcertInfo'] = True
|
||||
else:
|
||||
context['hasNextConcertInfo'] = False
|
||||
|
||||
return render( request, 'website/mainpage.html', context )
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue