-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add geolocation feature with map integration
Integrated the Symfony UX Map and Leaflet Map to enable interactive geolocation features. This involves adding a component to display user coordinates and a map centered on their location. Configuration files and templates were updated accordingly to support this new functionality.
- Loading branch information
Showing
15 changed files
with
327 additions
and
2 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ux_map: | ||
# https://symfony.com/bundles/ux-map/current/index.html#available-renderers | ||
renderer: '%env(resolve:default::UX_MAP_DSN)%' |
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
Empty file.
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,34 @@ | ||
<?php | ||
|
||
namespace App\Twig\Component; | ||
|
||
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; | ||
use Symfony\UX\LiveComponent\Attribute\LiveArg; | ||
use Symfony\UX\LiveComponent\Attribute\LiveListener; | ||
use Symfony\UX\LiveComponent\Attribute\LiveProp; | ||
use Symfony\UX\LiveComponent\DefaultActionTrait; | ||
use Symfony\UX\LiveComponent\ComponentToolsTrait; | ||
|
||
#[AsLiveComponent('Geolocation')] | ||
class Geolocation | ||
{ | ||
use DefaultActionTrait; | ||
use ComponentToolsTrait; | ||
|
||
#[LiveProp()] | ||
public int $zoom = 3; | ||
|
||
#[LiveProp()] | ||
public float $latitude = 0.0; | ||
|
||
#[LiveProp()] | ||
public float $longitude = 0.0; | ||
|
||
#[LiveListener('geolocation:position')] | ||
public function onPosition(#[LiveArg] float $latitude, #[LiveArg] float $longitude): void | ||
{ | ||
$this->latitude = $latitude; | ||
$this->longitude = $longitude; | ||
$this->zoom = 12; | ||
} | ||
} |
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,25 @@ | ||
<div | ||
data-controller="pwa--geolocation live" | ||
{{ attributes }} | ||
class="rounded-lg border border-gray-200 bg-white p-6 shadow-sm dark:border-gray-700 dark:bg-gray-800 bg-gray-50 hover:bg-gray-100" | ||
> | ||
<button | ||
data-action="click->pwa--geolocation#watch" | ||
data-pwa--geolocation-params-param='{"enableHighAccuracy":true, "maximumAge": 500, "timeout": 1000}' | ||
class="text-white bg-blue-600 hover:bg-blue-700 focus:ring-4 focus:ring-blue-300 focus:outline-none font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-500 dark:hover:bg-blue-600 dark:focus:ring-blue-800" | ||
> | ||
Tell me where I am | ||
</button> | ||
<dl> | ||
<dt class="font-medium text-gray-500 dark:text-gray-400">Latitude</dt> | ||
<dd class="text-gray-900 dark:text-white">{{ this.latitude }}</dd> | ||
<dt class="font-medium text-gray-500 dark:text-gray-400">Longitude</dt> | ||
<dd class="text-gray-900 dark:text-white">{{ this.longitude }}</dd> | ||
</dl> | ||
<twig:ux:map | ||
:center="[this.latitude, this.longitude]" | ||
:zoom="this.zoom" | ||
class="w-full h-96 mt-4" | ||
:markers='[{"position": [this.latitude, this.longitude], "title": "Your location"}]' | ||
/> | ||
</div> |
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,16 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block title %}i18n{% endblock %} | ||
|
||
{% block body %} | ||
<section class="bg-white dark:bg-gray-900"> | ||
<div class="py-8 px-4 mx-auto max-w-screen-xl sm:py-16 lg:px-6 "> | ||
<h2 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white"> | ||
i18n | ||
</h2> | ||
<p class="mb-3 font-light text-gray-500 dark:text-gray-400 sm:text-xl"> | ||
TO BE COMPLETED | ||
</p> | ||
</div> | ||
</section> | ||
{% endblock %} |
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,16 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block title %}Presentation{% endblock %} | ||
|
||
{% block body %} | ||
<section class="bg-white dark:bg-gray-900"> | ||
<div class="py-8 px-4 mx-auto max-w-screen-xl sm:py-16 lg:px-6 "> | ||
<h2 class="mb-4 text-4xl tracking-tight font-extrabold text-gray-900 dark:text-white"> | ||
Presentation | ||
</h2> | ||
<p class="mb-3 font-light text-gray-500 dark:text-gray-400 sm:text-xl"> | ||
TO BE COMPLETED | ||
</p> | ||
</div> | ||
</section> | ||
{% endblock %} |
Oops, something went wrong.