Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JC5 committed Apr 29, 2020
1 parent 4d39079 commit 15ae920
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/Http/Middleware/SecureHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function handle(Request $request, Closure $next)
"base-uri 'self'",
"font-src 'self' data:",
"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'",
];

Expand Down
13 changes: 8 additions & 5 deletions app/Http/Requests/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ protected function appendLocationData(array $data, ?string $prefix): array
$latitudeKey = $this->getLocationKey($prefix, 'latitude');
$zoomLevelKey = $this->getLocationKey($prefix, 'zoom_level');
$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 (
('POST' === $this->method() && $this->routeIs('*.store'))
&& ($this->has($longitudeKey) && $this->has($latitudeKey) && $this->has($zoomLevelKey))
Expand All @@ -322,12 +323,14 @@ protected function appendLocationData(array $data, ?string $prefix): array
$data['latitude'] = $this->nullableString($latitudeKey);
$data['zoom_level'] = $this->nullableString($zoomLevelKey);
}
if (null === $data['longitude'] || null === $data['latitude'] || null === $data['zoom_level']) {
Log::debug('One of the fields is NULL, wont save.');
if (false === $hasLocation || null === $data['longitude'] || null === $data['latitude'] || null === $data['zoom_level']) {
Log::debug('One of the fields is NULL or hasLocation is false, wont save.');
$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']));

return $data;
Expand Down
6 changes: 3 additions & 3 deletions public/v1/js/ff/accounts/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ $(function () {
dragging: false
}).setView([latitude, longitude], zoomLevel);

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{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>',
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18,
id: 'mapbox.streets',
id: 'mapbox/streets-v11',
accessToken: mapboxToken
}).addTo(mymap);
L.marker([latitude, longitude]).addTo(mymap);
Expand Down
6 changes: 3 additions & 3 deletions public/v1/js/ff/tags/show.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ $(function () {
dragging: false
}).setView([latitude, longitude], zoomLevel);

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{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>',
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18,
id: 'mapbox.streets',
id: 'mapbox/streets-v11',
accessToken: mapboxToken
}).addTo(mymap);
L.marker([latitude, longitude]).addTo(mymap);
Expand Down
4 changes: 2 additions & 2 deletions resources/views/v1/form/location.twig
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@
// make map:
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}', {
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>',
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: mapboxToken
Expand Down

0 comments on commit 15ae920

Please sign in to comment.