Practice Leaflet

This commit is contained in:
Ansley 2024-10-28 17:53:06 +08:00
parent 94a27e13c4
commit d24bdfa22d
7 changed files with 131 additions and 246 deletions

View file

@ -50,7 +50,6 @@
"symfony/filesystem": "^4.0",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.0",
"symfony/mailer": "^4.0",
"symfony/maker-bundle": "^1.0",
"symfony/monolog-bundle": "^3.7",
"symfony/process": "^4.0",

237
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3da24a255bf74ac8f6423361afa08210",
"content-hash": "da765755121aaeb5c5a43aa74d7eeb76",
"packages": [
{
"name": "composer/package-versions-deprecated",
@ -1827,73 +1827,6 @@
},
"time": "2023-07-19T09:04:27+00:00"
},
{
"name": "egulias/email-validator",
"version": "3.2.6",
"source": {
"type": "git",
"url": "https://github.com/egulias/EmailValidator.git",
"reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7",
"reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7",
"shasum": ""
},
"require": {
"doctrine/lexer": "^1.2|^2",
"php": ">=7.2",
"symfony/polyfill-intl-idn": "^1.15"
},
"require-dev": {
"phpunit/phpunit": "^8.5.8|^9.3.3",
"vimeo/psalm": "^4"
},
"suggest": {
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Egulias\\EmailValidator\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eduardo Gulias Davis"
}
],
"description": "A library for validating emails against several RFCs",
"homepage": "https://github.com/egulias/EmailValidator",
"keywords": [
"email",
"emailvalidation",
"emailvalidator",
"validation",
"validator"
],
"support": {
"issues": "https://github.com/egulias/EmailValidator/issues",
"source": "https://github.com/egulias/EmailValidator/tree/3.2.6"
},
"funding": [
{
"url": "https://github.com/egulias",
"type": "github"
}
],
"time": "2023-06-01T07:04:22+00:00"
},
{
"name": "friendsofphp/proxy-manager-lts",
"version": "v1.0.5",
@ -4934,87 +4867,6 @@
],
"time": "2021-11-22T14:10:53+00:00"
},
{
"name": "symfony/mailer",
"version": "v4.4.49",
"source": {
"type": "git",
"url": "https://github.com/symfony/mailer.git",
"reference": "554b8c0dc2db9d74e760fd6b726f527364f03302"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mailer/zipball/554b8c0dc2db9d74e760fd6b726f527364f03302",
"reference": "554b8c0dc2db9d74e760fd6b726f527364f03302",
"shasum": ""
},
"require": {
"egulias/email-validator": "^2.1.10|^3",
"php": ">=7.1.3",
"psr/log": "^1|^2|^3",
"symfony/event-dispatcher": "^4.3",
"symfony/mime": "^4.4.21|^5.2.6",
"symfony/polyfill-php80": "^1.16",
"symfony/service-contracts": "^1.1|^2"
},
"conflict": {
"symfony/http-kernel": "<4.4",
"symfony/sendgrid-mailer": "<4.4"
},
"require-dev": {
"symfony/amazon-mailer": "^4.4|^5.0",
"symfony/google-mailer": "^4.4|^5.0",
"symfony/http-client-contracts": "^1.1|^2",
"symfony/mailchimp-mailer": "^4.4|^5.0",
"symfony/mailgun-mailer": "^4.4|^5.0",
"symfony/messenger": "^4.4|^5.0",
"symfony/postmark-mailer": "^4.4|^5.0",
"symfony/sendgrid-mailer": "^4.4|^5.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Mailer\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Helps sending emails",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/mailer/tree/v4.4.49"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-11-04T06:30:35+00:00"
},
{
"name": "symfony/maker-bundle",
"version": "v1.36.3",
@ -5103,91 +4955,6 @@
],
"time": "2021-11-22T18:44:03+00:00"
},
{
"name": "symfony/mime",
"version": "v5.4.43",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
"reference": "a02711d6ce461edada8c0f8641aa536709b99b47"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/a02711d6ce461edada8c0f8641aa536709b99b47",
"reference": "a02711d6ce461edada8c0f8641aa536709b99b47",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3",
"symfony/polyfill-intl-idn": "^1.10",
"symfony/polyfill-mbstring": "^1.0",
"symfony/polyfill-php80": "^1.16"
},
"conflict": {
"egulias/email-validator": "~3.0.0",
"phpdocumentor/reflection-docblock": "<3.2.2",
"phpdocumentor/type-resolver": "<1.4.0",
"symfony/mailer": "<4.4",
"symfony/serializer": "<5.4.35|>=6,<6.3.12|>=6.4,<6.4.3"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3.1|^4",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
"symfony/process": "^5.4|^6.4",
"symfony/property-access": "^4.4|^5.1|^6.0",
"symfony/property-info": "^4.4|^5.1|^6.0",
"symfony/serializer": "^5.4.35|~6.3.12|^6.4.3"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Mime\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Allows manipulating MIME messages",
"homepage": "https://symfony.com",
"keywords": [
"mime",
"mime-type"
],
"support": {
"source": "https://github.com/symfony/mime/tree/v5.4.43"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-08-13T10:38:38+00:00"
},
{
"name": "symfony/monolog-bridge",
"version": "v5.2.12",
@ -8204,6 +7971,6 @@
"php": "^7.1.3",
"ext-iconv": "*"
},
"platform-dev": {},
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

View file

@ -687,15 +687,14 @@ catalyst_auth:
- id: entity.list
label: List
- id: send_EDA
label: sendeda
- id: leaflet
label: Leaflet
acls:
- id: eda.menu
- id: leaflet.menu
label: Menu
- id: eda.update
- id: leaflet.update
label: Update
- id: eda.list
label: List
api:

View file

@ -311,7 +311,7 @@ catalyst_menu:
acl: entity.menu
label: EntityTypes
- id: send_EDA
acl: eda.menu
label: Notifs
parent: entity_list
- id: leaflet
acl: leaflet.menu
label: Leaflet

View file

@ -0,0 +1,4 @@
leaflet:
path: /leaflet
controller: App\Controller\LeafletController::index
methods: [GET]

View file

@ -0,0 +1,27 @@
<?php
// src/Controller/LeafletController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
use Catalyst\MenuBundle\Annotation\Menu;
class LeafletController extends AbstractController
{
/**
* @Menu(selected="leaflet")
* @IsGranted("leaflet.menu")
*/
public function index(): Response
{
return $this->render('leaflet/index.html.twig', [
'message' => 'Hello from LeafletController!',
]);
}
}

View file

@ -0,0 +1,89 @@
{% extends 'base.html.twig' %}
{% block title %}Leaflet Map with Layers{% endblock %}
{% block stylesheets %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
<style>
#map {
height: 500px; /* You can adjust the height here */
width: 100%;
}
</style>
{% endblock %}
{% block body %}
<h2>Leaflet Map</h2>
<div id="map" class="w-full h-96 mb-4"></div>
<div id="coordinates" class="text-gray-600 text-sm mt-4"></div>
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
<script>
// Base layers: Streets and Satellite
var streets = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
});
var satellite = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 17,
});
// Initialize the map
var map = L.map('map', {
center: [14.5995, 120.9842], // Latitude, Longitude of Manila
zoom: 13,
layers: [streets] // Set default layer
});
// Base layers for diff map sets
var baseMaps = {
"Streets": streets,
"Satellite": satellite
};
// Switch between base layers
L.control.layers(baseMaps).addTo(map);
// Add markers for cities
var manilaMarker = L.marker([14.5995, 120.9842]).addTo(map)
.bindPopup("<b>Manila</b><br>Capital of the Philippines").openPopup();
var sanJuanMarker = L.marker([14.6042, 121.0293]).addTo(map)
.bindPopup("<b>San Juan City</b><br>Known for historical sites.");
var quezonMarker = L.marker([14.6760, 121.0437]).addTo(map)
.bindPopup("<b>Quezon City</b><br>Largest city in Metro Manila.");
// Add click event listener for adding new markers
map.on('click', function(e) {
var lat = e.latlng.lat; // Get latitude
var lng = e.latlng.lng; // Get longitude
// Create a new marker
var newMarker = L.marker([lat, lng]).addTo(map);
// Create a delete button inside the popup
var deleteButton = `<button onclick="deleteMarker(${lat}, ${lng})"
style='background-color: red; color: white; padding: 5px;'>Delete Marker</button>`;
// Add a popup to the marker with the "Save Marker" and "Delete" button
newMarker.bindPopup("<b>Save Marker</b><br>" + deleteButton).openPopup();
// Update the coordinates in the div
document.getElementById('coordinates').innerHTML =
'Coordinates: Latitude ' + lat + ', Longitude ' + lng;
});
// Function to delete marker based on lat/lng
function deleteMarker(lat, lng) {
map.eachLayer(function (layer) {
if (layer instanceof L.Marker) {
if (layer.getLatLng().lat === lat && layer.getLatLng().lng === lng) {
map.removeLayer(layer); // Remove the marker
}
}
});
}
</script>
{% endblock %}