This commit is contained in:
James Cole 2020-04-29 06:37:02 +02:00
parent 4d3907948d
commit 15ae9203b6
5 changed files with 17 additions and 14 deletions

View File

@ -58,7 +58,7 @@ class SecureHeaders
"base-uri 'self'", "base-uri 'self'",
"font-src 'self' data:", "font-src 'self' data:",
"connect-src 'self'", "connect-src 'self'",
sprintf("img-src 'self' data: https://api.tiles.mapbox.com %s", $trackingScriptSrc), sprintf("img-src 'self' data: https://a.tile.openstreetmap.org https://b.tile.openstreetmap.org https://c.tile.openstreetmap.org https://api.tiles.mapbox.com %s", $trackingScriptSrc),
"manifest-src 'self'", "manifest-src 'self'",
]; ];

View File

@ -297,8 +297,9 @@ class Request extends FormRequest
$latitudeKey = $this->getLocationKey($prefix, 'latitude'); $latitudeKey = $this->getLocationKey($prefix, 'latitude');
$zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level'); $zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level');
$hasLocationKey = $this->getLocationKey($prefix, 'has_location'); $hasLocationKey = $this->getLocationKey($prefix, 'has_location');
$hasLocation = $this->boolean($hasLocationKey);
// for a POST (store, all fields must be present and accounted for: // for a POST (store), all fields must be present and accounted for:
if ( if (
('POST' === $this->method() && $this->routeIs('*.store')) ('POST' === $this->method() && $this->routeIs('*.store'))
&& ($this->has($longitudeKey) && $this->has($latitudeKey) && $this->has($zoomLevelKey)) && ($this->has($longitudeKey) && $this->has($latitudeKey) && $this->has($zoomLevelKey))
@ -322,12 +323,14 @@ class Request extends FormRequest
$data['latitude'] = $this->nullableString($latitudeKey); $data['latitude'] = $this->nullableString($latitudeKey);
$data['zoom_level'] = $this->nullableString($zoomLevelKey); $data['zoom_level'] = $this->nullableString($zoomLevelKey);
} }
if (null === $data['longitude'] || null === $data['latitude'] || null === $data['zoom_level']) { if (false === $hasLocation || null === $data['longitude'] || null === $data['latitude'] || null === $data['zoom_level']) {
Log::debug('One of the fields is NULL, wont save.'); Log::debug('One of the fields is NULL or hasLocation is false, wont save.');
$data['store_location'] = false; $data['store_location'] = false;
$data['update_location'] = false; $data['update_location'] = true; // update is always true, but the values are null:
$data['longitude'] = null;
$data['latitude'] = null;
$data['zoom_level'] = null;
} }
Log::debug(sprintf('Returning longitude: "%s", latitude: "%s", zoom level: "%s"', $data['longitude'], $data['latitude'], $data['zoom_level'])); Log::debug(sprintf('Returning longitude: "%s", latitude: "%s", zoom level: "%s"', $data['longitude'], $data['latitude'], $data['zoom_level']));
return $data; return $data;

View File

@ -84,10 +84,10 @@ $(function () {
dragging: false dragging: false
}).setView([latitude, longitude], zoomLevel); }).setView([latitude, longitude], zoomLevel);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18, maxZoom: 18,
id: 'mapbox.streets', id: 'mapbox/streets-v11',
accessToken: mapboxToken accessToken: mapboxToken
}).addTo(mymap); }).addTo(mymap);
L.marker([latitude, longitude]).addTo(mymap); L.marker([latitude, longitude]).addTo(mymap);

View File

@ -40,10 +40,10 @@ $(function () {
dragging: false dragging: false
}).setView([latitude, longitude], zoomLevel); }).setView([latitude, longitude], zoomLevel);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18, maxZoom: 18,
id: 'mapbox.streets', id: 'mapbox/streets-v11',
accessToken: mapboxToken accessToken: mapboxToken
}).addTo(mymap); }).addTo(mymap);
L.marker([latitude, longitude]).addTo(mymap); L.marker([latitude, longitude]).addTo(mymap);

View File

@ -111,8 +111,8 @@
// make map: // make map:
mymap = L.map('{{ name }}_map').setView({lat: locations.{{ name }}.latitude, lng: locations.{{ name }}.longitude}, locations.{{ name }}.zoom_level); mymap = L.map('{{ name }}_map').setView({lat: locations.{{ name }}.latitude, lng: locations.{{ name }}.longitude}, locations.{{ name }}.zoom_level);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>', attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18, maxZoom: 18,
id: 'mapbox.streets', id: 'mapbox.streets',
accessToken: mapboxToken accessToken: mapboxToken