This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
generated from filamentphp/plugin-skeleton
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fdf2e23
commit 2818181
Showing
8 changed files
with
147 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
@import '../../node_modules/ol/ol.css'; | ||
@import '../../node_modules/ol-geocoder/dist/ol-geocoder.min.css'; | ||
|
||
.gcd-txt-control { | ||
color: #09090b !important; | ||
.open-street-map { | ||
position: relative; | ||
.gcd-txt-control { | ||
color: #09090b !important; | ||
} | ||
|
||
.center { | ||
z-index: 9999 !important; | ||
position: absolute; | ||
border: solid 1px black; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
width: 20px; | ||
height: 20px; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Traineratwot\FilamentOpenStreetMap\Rules; | ||
|
||
use Closure; | ||
use Exception; | ||
use Illuminate\Contracts\Validation\ValidationRule; | ||
use Illuminate\Translation\PotentiallyTranslatedString; | ||
use MatanYadaev\EloquentSpatial\Objects\Point; | ||
|
||
class GeoPoint implements ValidationRule | ||
{ | ||
/** | ||
* Run the validation rule. | ||
* | ||
* @param Closure(string): PotentiallyTranslatedString $fail | ||
*/ | ||
public function validate(string $attribute, mixed $value, Closure $fail): void | ||
{ | ||
try { | ||
$point = null; | ||
if ($value instanceof Point) { | ||
$point = [ | ||
'latitude' => $value->latitude, | ||
'longitude' => $value->longitude, | ||
]; | ||
} | ||
if (is_string($value)) { | ||
$_value = explode(',', $value); | ||
if (count($_value) !== 2) { | ||
$fail("The {$attribute} must be a valid geo point."); | ||
} | ||
|
||
$point = [ | ||
'latitude' => (float)$_value[0], | ||
'longitude' => (float)$_value[1], | ||
]; | ||
} | ||
if (is_array($value)) { | ||
if (isset($value['type']) && $value['type'] === 'Point') { | ||
$point = [ | ||
'latitude' => $value['coordinates'][1], | ||
'longitude' => $value['coordinates'][0], | ||
]; | ||
} else if (count($value) !== 2) { | ||
$fail("The {$attribute} must be a valid geo point."); | ||
} else { | ||
$point = [ | ||
'latitude' => (float)$value[0], | ||
'longitude' => (float)$value[1], | ||
]; | ||
} | ||
} | ||
if (!is_numeric($point['latitude']) || !is_numeric($point['longitude'])) { | ||
$fail("The {$attribute} must be a valid geo point."); | ||
} | ||
if ($point['latitude'] < -90 || $point['latitude'] > 90) { | ||
$fail("The {$attribute} must be a valid geo point."); | ||
} | ||
if ($point['longitude'] < -180 || $point['longitude'] > 180) { | ||
$fail("The {$attribute} must be a valid geo point."); | ||
} | ||
} catch (Exception $e) { | ||
$fail("The {$attribute} must be a valid geo point."); | ||
} | ||
} | ||
} |