Show geocoords for known locations.

This commit is contained in:
Tim Schumacher 2014-07-09 13:09:49 +02:00
parent d443179701
commit df74c9f263
4 changed files with 61 additions and 44 deletions

View file

@ -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;
}
}
}

View file

@ -50,7 +50,16 @@ $(document).ready(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');
});

View file

@ -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"
%}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% 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"
%}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}

View file

@ -77,19 +77,19 @@
<div class="field">
<label class="control-label required" for="event_location">Ort</label>
<div class="ui left labeled icon input attached-label">
<div class="ui left labeled icon input attached-{% if entity.location.lat|default(0) > 0 %}geo-{% endif %}label">
<input type="text"
id="event_location"
name="location"
maxlength="255"
value="{{ entity.location.name|default('') }}"
class="form-control">
<input type="hidden" name="location_lat">
<input type="hidden" name="location_lon">
<input type="hidden" name="location_lat" value="{{ entity.location.lat|default('') }}">
<input type="hidden" name="location_lon" value="{{ entity.location.lon|default('') }}">
<i class="icon map marker"></i>
<div class="ui bottom attached label">
Du kannst zu diesem Ort auch Geokoordinaten <a href="#" class="add_geo">hinterlegen</a>.<br />
<span class="coords"></span>
<span class="coords">{% if entity.location.lat|default(0) > 0 %}Folgende Koordinaten sind angegeben: lat:{{ entity.location.lat }}, lon:{{ entity.location.lon }}{% endif %}</span>
</div>
<div class="ui modal geo chooser">
<i class="close icon"></i>