diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss index a2e4819..16890e1 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss @@ -35,6 +35,9 @@ form .ui.form { .attached-label > input, .attached-label > textarea { margin-bottom: 2rem; } + .attached-geo-label > input, .attached-geo-label > textarea { + margin-bottom: 3.2rem; + } } } diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/js/events.js b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/js/events.js index 93d9060..fc39c19 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/js/events.js +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/js/events.js @@ -5,52 +5,61 @@ // initializing with settings function addGeoCoordinates(ev) { - return false; + return false; } var map = null; $(document).ready(function () { - $('.icon.link').popup(); - jQuery('input[type=datetime]').datetimepicker({lang: 'de', format: 'Y-m-d H:i'}); + $('.icon.link').popup(); + jQuery('input[type=datetime]').datetimepicker({lang: 'de', format: 'Y-m-d H:i'}); - $('.add_geo').click(addGeoCoordinates); - map = L.map('map'); + $('.add_geo').click(addGeoCoordinates); + map = L.map('map'); - // add an OpenStreetMap tile layer - L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors' - }).addTo(map); + // add an OpenStreetMap tile layer + L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { + attribution: '© OpenStreetMap contributors' + }).addTo(map); - map.setView([51.505, -0.09], 0); + map.setView([51.505, -0.09], 0); - L.Icon.Default.imagePath = '/css/images'; - var popup = L.popup(); + L.Icon.Default.imagePath = '/css/images'; + var popup = L.popup(); - var marker = L.marker(); + var marker = L.marker(); - function onMapClick(e) { - marker - .setLatLng(e.latlng) - //.setContent("You clicked the map at " + e.latlng.toString()) - .addTo(map); - } - - map.on('click', onMapClick); - - $('.geo.chooser').modal('setting', { - closable: false, - onApprove: function () { - var coords = marker.getLatLng(); - $('input[name=location_lat]').val(coords.lat); - $('input[name=location_lon]').val(coords.lng); - $('input[name=location]').css('margin-bottom','3.2rem'); - $('span.coords').text('Folgende Koordinaten sind angegeben: lat:' +coords.lat + ', lon:' + coords.lng); - }, - onDeny: function () { - - }, - onVisible: function () { - map.invalidateSize(true); - map.locate({setView: true}); + function onMapClick(e) { + marker + .setLatLng(e.latlng) + //.setContent("You clicked the map at " + e.latlng.toString()) + .addTo(map); } - }).modal('attach events', '.add_geo', 'show'); + + map.on('click', onMapClick); + + $('.geo.chooser').modal('setting', { + closable: false, + onApprove: function () { + var coords = marker.getLatLng(); + $('input[name=location_lat]').val(coords.lat); + $('input[name=location_lon]').val(coords.lng); + $('input[name=location]').css('margin-bottom', '3.2rem'); + $('span.coords').text('Folgende Koordinaten sind angegeben: lat:' + coords.lat + ', lon:' + coords.lng); + }, + onDeny: function () { + + }, + onVisible: function () { + map.invalidateSize(true); + var lat = parseFloat($('input[name=location_lat]').val()); + var lon = parseFloat($('input[name=location_lon]').val()); + if ((lat > 0) && (lon > 0)) { + map.setView([lat,lon],16); + var latlng = new L.LatLng(lat,lon); + marker.setLatLng(latlng); + marker.addTo(map); + } else { + map.locate({setView: true}); + } + } + }).modal('attach events', '.add_geo', 'show'); }); diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/edit.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/edit.html.twig index b06123f..07d2d67 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/edit.html.twig +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/edit.html.twig @@ -2,7 +2,10 @@ {% block css %} {% stylesheets filter="compass" - "@CalciferBundle/Resources/assets/css/jquery.datetimepicker.scss" %} + "@CalciferBundle/Resources/assets/css/jquery.datetimepicker.scss" + "@CalciferBundle/Resources/assets/css/events.scss" + "@CalciferBundle/Resources/assets/css/leaflet.scss" + %} {% endstylesheets %} {% endblock %} @@ -10,7 +13,9 @@ {% block javascripts %} {% javascripts "@CalciferBundle/Resources/assets/js/jquery.datetimepicker.js" - "@CalciferBundle/Resources/assets/js/events.js" %} + "@CalciferBundle/Resources/assets/js/events.js" + "@CalciferBundle/Resources/assets/js/leaflet.js" + %} {% endjavascripts %} {% endblock %} diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_form.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_form.html.twig index 6af08e2..efed63a 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_form.html.twig +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_form.html.twig @@ -77,19 +77,19 @@