Fix map url
This commit is contained in:
parent
393a1195a5
commit
8f595af9a1
@ -5,7 +5,7 @@
|
||||
* by https://t.me/ibnux
|
||||
**/
|
||||
|
||||
_admin();
|
||||
_admin();
|
||||
$ui->assign('_system_menu', 'map');
|
||||
|
||||
$action = $routes['1'];
|
||||
@ -22,14 +22,16 @@ switch ($action) {
|
||||
$customerData = [];
|
||||
|
||||
foreach ($c as $customer) {
|
||||
$customerData[] = [
|
||||
'id' => $customer->id,
|
||||
'name' => $customer->fullname,
|
||||
'balance' => $customer->balance,
|
||||
'address' => $customer->address,
|
||||
'info' => Lang::T("Username") . ": " . $customer->username . " - " . Lang::T("Full Name") . ": " . $customer->fullname . " - " . Lang::T("Email") . ": " . $customer->email . " - " . Lang::T("Phone") . ": " . $customer->phonenumber . " - " . Lang::T("Service Type") . ": " . $customer->service_type,
|
||||
'coordinates' => '[' . $customer->coordinates . ']',
|
||||
];
|
||||
if (!empty($customer->coordinates)) {
|
||||
$customerData[] = [
|
||||
'id' => $customer->id,
|
||||
'name' => $customer->fullname,
|
||||
'balance' => $customer->balance,
|
||||
'address' => $customer->address,
|
||||
'info' => Lang::T("Username") . ": " . $customer->username . " - " . Lang::T("Full Name") . ": " . $customer->fullname . " - " . Lang::T("Email") . ": " . $customer->email . " - " . Lang::T("Phone") . ": " . $customer->phonenumber . " - " . Lang::T("Service Type") . ": " . $customer->service_type,
|
||||
'coordinates' => '[' . $customer->coordinates . ']',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$ui->assign('customers', $customerData);
|
||||
|
@ -1,18 +1,19 @@
|
||||
{include file="sections/header.tpl"}
|
||||
|
||||
<!-- Map container div -->
|
||||
<div id="map" style="width: 800px; height: 600px; margin: 20px auto"></div>
|
||||
<div id="map" style="width: '100%'; height: 600px; margin: 20px auto"></div>
|
||||
|
||||
{literal}
|
||||
<script>
|
||||
window.onload = function() {
|
||||
<script>
|
||||
window.onload = function() {
|
||||
var map = L.map('map').setView([51.505, -0.09], 13);
|
||||
var group = L.featureGroup().addTo(map);
|
||||
|
||||
|
||||
var customers = {/literal}{$customers|json_encode}{literal};
|
||||
|
||||
L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
subdomains: 'abcd',
|
||||
maxZoom: 20
|
||||
}).addTo(map);
|
||||
@ -27,20 +28,20 @@
|
||||
|
||||
// Create a popup for the marker
|
||||
var popupContent = "<strong>Customer Name</strong>: " + name + "<br>" +
|
||||
"<strong>Customer Info</strong>: " + info + "<br>" +
|
||||
"<strong>Customer Balance</strong>: " + balance + "<br>" +
|
||||
"<strong>Address</strong>: " + address + "<br>" +
|
||||
"<strong>Coordinates</strong>: " + coordinates + "<br>" +
|
||||
"<a href='{$_url}customers/view/"+ customer.id +"'>More Info</a><br>";
|
||||
"<strong>Customer Info</strong>: " + info + "<br>" +
|
||||
"<strong>Customer Balance</strong>: " + balance + "<br>" +
|
||||
"<strong>Address</strong>: " + address + "<br>" +
|
||||
"<strong>Coordinates</strong>: " + coordinates + "<br>" +
|
||||
"<a href='{/literal}{$_url}{literal}customers/view/"+ customer.id +"'>More Info</a><br>";
|
||||
|
||||
// Add marker to map
|
||||
var marker = L.marker(JSON.parse(coordinates)).addTo(group);
|
||||
// Add marker to map
|
||||
var marker = L.marker(JSON.parse(coordinates)).addTo(group);
|
||||
marker.bindTooltip(name).bindPopup(popupContent);
|
||||
});
|
||||
|
||||
map.fitBounds(group.getBounds());
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
{/literal}
|
||||
|
||||
{include file="sections/footer.tpl"}
|
||||
{include file="sections/footer.tpl"}
|
Loading…
x
Reference in New Issue
Block a user