Map should be better displayed on small screens, particularly legends

This commit is contained in:
echarp 2019-04-20 15:16:21 +02:00
parent f065d38723
commit 08080d7144
4 changed files with 35 additions and 23 deletions

View File

@ -4,6 +4,8 @@ $(document).on 'turbolinks:load', ->
idx = 0 idx = 0
$('#map.list').each -> $('#map.list').each ->
map = L.map 'map' map = L.map 'map'
# Set some initial bounds, in case nothing else is displayed
map.fitBounds [ [60, -20], [30, 30] ]
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a>' attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a>'
@ -21,27 +23,29 @@ $(document).on 'turbolinks:load', ->
url += location.search url += location.search
$.getJSON url, (json) -> $.getJSON url, (json) ->
if json # Display the layer only if some items are present
layer = L.markerClusterGroup(maxClusterRadius: 30).addLayer L.geoJson json, return unless json?.length
pointToLayer: (feature, latlng) ->
# Marker with the proper icon
marker = L.AwesomeMarkers.icon
prefix: 'fa',
icon: feature.properties.icon || 'calendar',
markerColor: markerColor
L.marker latlng, icon: marker
,
onEachFeature: (feature, layer) ->
# Does this feature have a property named popupContent?
if (feature.properties && feature.properties.popupContent)
layer.bindPopup feature.properties.popupContent
map.addLayer layer layer = L.markerClusterGroup(maxClusterRadius: 30).addLayer L.geoJson json,
controls.addOverlay layer, text + ' - ' + json.length pointToLayer: (feature, latlng) ->
# Marker with the proper icon
marker = L.AwesomeMarkers.icon
prefix: 'fa',
icon: feature.properties.icon || 'calendar',
markerColor: markerColor
L.marker latlng, icon: marker
onEachFeature: (feature, layer) ->
# Does this feature have a property named popupContent?
if (feature.properties && feature.properties.popupContent)
layer.bindPopup feature.properties.popupContent
if (/maps\//.test(location.href) || /maps.json/.test url) && layer.getBounds()._northEast && layer.getBounds()._southWest map.addLayer layer
# Automatic focus to all displayed events controls.addOverlay layer, text + ' - ' + json.length
map.fitBounds layer.getBounds()
if (/maps\//.test(location.href) || /maps.json/.test url) &&
layer.getBounds()._northEast && layer.getBounds()._southWest
# Automatic focus to all displayed events
map.fitBounds layer.getBounds()
$('#map.event, #map.orga').each -> $('#map.event, #map.orga').each ->
coord = [$(this).data('latitude'), $(this).data('longitude')] coord = [$(this).data('latitude'), $(this).data('longitude')]

View File

@ -2,6 +2,8 @@
height: 60em height: 60em
box-shadow: 0 0 1em SteelBlue box-shadow: 0 0 1em SteelBlue
transition: none transition: none
padding-left: 4em
list-style-type: none
* *
/* Popup are better displayed with this: */ /* Popup are better displayed with this: */
max-width: initial max-width: initial
@ -10,8 +12,11 @@
height: 20em height: 20em
li li
a
display: inline-block
.awesome-marker .awesome-marker
display: inline-block !important display: inline-block !important
position: relative !important
.tags #map .tags #map
width: 40% width: 40%
@ -19,9 +24,8 @@
margin: 1.6em 2% margin: 1.6em 2%
display: inline-block display: inline-block
// Left align the map controls place in the top right corner // Left align the map controls placed in the top right corner
section.leaflet-control-layers-list label section.leaflet-control-layers-list label
text-align: left
.awesome-marker .awesome-marker
height: auto !important height: auto !important
display: inline-block !important display: inline-block !important

View File

@ -38,7 +38,7 @@
nav nav
display: none display: none
img.logo img.logo
margin-right: 0 max-width: 12vw
form#orga_search form#orga_search
display: none display: none
@ -124,6 +124,10 @@
.radios .radios
margin-left: auto margin-left: auto
#map section
input, .awesome-marker
display: none !important
body.mce-content-body body.mce-content-body
padding: 1px 0 padding: 1px 0
.mce-btn-group .mce-btn .mce-btn-group .mce-btn

View File

@ -15,5 +15,5 @@
= link_to map_path kind.name, format: :json do = link_to map_path kind.name, format: :json do
.awesome-marker{ class: "awesome-marker-icon-#{cs[idx % cs.length]}" } .awesome-marker{ class: "awesome-marker-icon-#{cs[idx % cs.length]}" }
%i.icon-white.fa{ class: "fa-#{kind.icon}" } %i.icon-white.fa{ class: "fa-#{kind.icon}" }
= Kind.human_attribute_name("name_#{kind.name}") = Kind.human_attribute_name "name_#{kind.name}"
- idx += 1 - idx += 1