mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fixed openstreetmap support in device not using custom tiles (#9536)
* Fixed openstreetmap support in device not using custom tiles * Updated blade template for locations * Removed console.log()
This commit is contained in:
committed by
Tony Murray
parent
fad0bffc43
commit
dd695dde53
@@ -141,7 +141,8 @@ if ($device['location_id']) {
|
|||||||
$("#toggle-map").on("shown.bs.collapse", function () {
|
$("#toggle-map").on("shown.bs.collapse", function () {
|
||||||
if (device_marker == null) {
|
if (device_marker == null) {
|
||||||
device_location = new L.LatLng(' . (float)$location->lat . ', ' . (float)$location->lng . ');
|
device_location = new L.LatLng(' . (float)$location->lat . ', ' . (float)$location->lng . ');
|
||||||
device_map = init_map("location-map", "' . $maps_engine . '", "' . $maps_api . '");
|
config = {"tile_url": "'.Config::get('leaflet.tile_url', '{s}.tile.openstreetmap.org').'"};
|
||||||
|
device_map = init_map("location-map", "' . $maps_engine . '", "' . $maps_api . '", config);
|
||||||
device_marker = init_map_marker(device_map, device_location);
|
device_marker = init_map_marker(device_map, device_location);
|
||||||
device_map.setZoom(18);
|
device_map.setZoom(18);
|
||||||
';
|
';
|
||||||
|
@@ -307,7 +307,7 @@ function loadScript(src, callback) {
|
|||||||
script.src = src;
|
script.src = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_map(id, engine, api_key) {
|
function init_map(id, engine, api_key, config) {
|
||||||
var leaflet = L.map(id);
|
var leaflet = L.map(id);
|
||||||
var baseMaps = {};
|
var baseMaps = {};
|
||||||
leaflet.setView([0, 0], 15);
|
leaflet.setView([0, 0], 15);
|
||||||
@@ -361,7 +361,7 @@ function init_map(id, engine, api_key) {
|
|||||||
roads.addTo(leaflet);
|
roads.addTo(leaflet);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
var osm = L.tileLayer('//' + config.tile_url + '/{z}/{x}/{y}.png', {
|
||||||
maxZoom: 19,
|
maxZoom: 19,
|
||||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||||
});
|
});
|
||||||
@@ -435,7 +435,6 @@ function update_location(id, latlng, callback) {
|
|||||||
|
|
||||||
function http_fallback(link) {
|
function http_fallback(link) {
|
||||||
var url = link.getAttribute('href');
|
var url = link.getAttribute('href');
|
||||||
console.log(url);
|
|
||||||
try {
|
try {
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
xhr.open('GET', url, false);
|
xhr.open('GET', url, false);
|
||||||
@@ -446,7 +445,6 @@ function http_fallback(link) {
|
|||||||
url = url.replace(/^https:\/\//, 'http://');
|
url = url.replace(/^https:\/\//, 'http://');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// console.log(e);
|
|
||||||
url = url.replace(/^https:\/\//, 'http://');
|
url = url.replace(/^https:\/\//, 'http://');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -137,7 +137,7 @@ foreach ((array)$config['webui']['custom_css'] as $custom_css) {
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<script src="js/select2.min.js"></script>
|
<script src="js/select2.min.js"></script>
|
||||||
<script src="js/librenms.js?ver=20181205"></script>
|
<script src="js/librenms.js?ver=20181211"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
<!-- Begin
|
<!-- Begin
|
||||||
|
@@ -69,7 +69,7 @@
|
|||||||
<script src="js/lazyload.js"></script>
|
<script src="js/lazyload.js"></script>
|
||||||
@endif
|
@endif
|
||||||
<script src="{{ asset('js/select2.min.js') }}"></script>
|
<script src="{{ asset('js/select2.min.js') }}"></script>
|
||||||
<script src="{{ asset('js/librenms.js?ver=20181205') }}"></script>
|
<script src="{{ asset('js/librenms.js?ver=20181211') }}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
<!-- Begin
|
<!-- Begin
|
||||||
|
@@ -148,7 +148,8 @@
|
|||||||
locationId = $btn.data('id');
|
locationId = $btn.data('id');
|
||||||
|
|
||||||
if (locationMap === null) {
|
if (locationMap === null) {
|
||||||
locationMap = init_map('location-edit-map', '{{ $maps_engine }}', '{{ $maps_api }}');
|
config = {"tile_url": "{{ Config::get('leaflet.tile_url', '{s}.tile.openstreetmap.org') }}"};
|
||||||
|
locationMap = init_map('location-edit-map', '{{ $maps_engine }}', '{{ $maps_api }}', config);
|
||||||
locationMarker = init_map_marker(locationMap, location);
|
locationMarker = init_map_marker(locationMap, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user