Files
librenms-librenms/resources/views/components/geo-map.blade.php
Tony Murray 0d246a6ffc Custom Maps: geo map and color backgrounds (#16020)
* Custom Maps: geo map and color background
tabs blade component
geo-map blade component and related script enhancements

* Update css/js

* style fixes

* update db_schema.yaml

* fix db_schema hand edit

* ignore phpstan being wrong

* Handle null

* another possible null spot

* Use standard file cache for custom map background images

* Create map->image as jpeg so we can compress it

* whitespace fix

* Fix background cancel button when other type is selected than the saved type

* Save and restore layer

* Map must exist before creating static image

* Don't show set as image button for Google and Bing.
Bing gives an odd error, but Google won't work.
2024-05-13 08:12:59 -05:00

34 lines
956 B
PHP

@props([
'id' => 'geo-map',
'init' => true,
'width' => '200px',
'height' => '100px',
'lat' => null,
'lng' => null,
'zoom' => null,
'layer' => null,
'readonly' => false,
'config' => [],
])
@php
$config['readonly'] = $readonly;
$config['lat'] = $lat ?? $config['lat'] ?? 40;
$config['lng'] = $lng ?? $config['lng'] ?? 40;
$config['zoom'] = $zoom ?? $config['zoom'] ?? 3;
$config['layer'] = $layer ?? $config['layer'] ?? null;
$config['engine'] ??= \LibreNMS\Config::get('geoloc.engine');
$config['api_key'] ??= \LibreNMS\Config::get('geoloc.api_key');
$config['tile_url'] ??= \LibreNMS\Config::get('leaflet.tile_url', '{s}.tile.openstreetmap.org');
@endphp
<div id="{{ $id }}" style="width: {{ $width }};height: {{ $height }}" {{ $attributes }}></div>
@if($init)
<script>
loadjs('js/leaflet.js', function () {
init_map(@json($id), @json($config))
})
</script>
@endif