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:
Neil Lathwood
2018-12-16 14:56:29 +00:00
committed by Tony Murray
parent fad0bffc43
commit dd695dde53
5 changed files with 8 additions and 8 deletions

View File

@@ -141,7 +141,8 @@ if ($device['location_id']) {
$("#toggle-map").on("shown.bs.collapse", function () {
if (device_marker == null) {
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_map.setZoom(18);
';

View File

@@ -307,7 +307,7 @@ function loadScript(src, callback) {
script.src = src;
}
function init_map(id, engine, api_key) {
function init_map(id, engine, api_key, config) {
var leaflet = L.map(id);
var baseMaps = {};
leaflet.setView([0, 0], 15);
@@ -361,7 +361,7 @@ function init_map(id, engine, api_key) {
roads.addTo(leaflet);
});
} 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,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
@@ -435,7 +435,6 @@ function update_location(id, latlng, callback) {
function http_fallback(link) {
var url = link.getAttribute('href');
console.log(url);
try {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
@@ -446,7 +445,6 @@ function http_fallback(link) {
url = url.replace(/^https:\/\//, 'http://');
}
} catch (e) {
// console.log(e);
url = url.replace(/^https:\/\//, 'http://');
}

View File

@@ -137,7 +137,7 @@ foreach ((array)$config['webui']['custom_css'] as $custom_css) {
}
?>
<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">
<!-- Begin

View File

@@ -69,7 +69,7 @@
<script src="js/lazyload.js"></script>
@endif
<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">
<!-- Begin

View File

@@ -148,7 +148,8 @@
locationId = $btn.data('id');
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);
}